You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/03/03 17:27:43 UTC
svn commit: r1296657 - in /myfaces/core/branches/2.0.x:
impl/src/main/java/org/apache/myfaces/application/
impl/src/main/java/org/apache/myfaces/renderkit/
impl/src/main/java/org/apache/myfaces/view/facelets/
impl/src/main/java/org/apache/myfaces/view/...
Author: lu4242
Date: Sat Mar 3 16:27:42 2012
New Revision: 1296657
URL: http://svn.apache.org/viewvc?rev=1296657&view=rev
Log:
MYFACES-3485 [perf] Use facesContext attribute map instead request map
Modified:
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java Sat Mar 3 16:27:42 2012
@@ -58,7 +58,10 @@ public class StateManagerImpl extends St
@Override
protected Object getComponentStateToSave(FacesContext facesContext)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Entering getComponentStateToSave");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Entering getComponentStateToSave");
+ }
UIViewRoot viewRoot = facesContext.getViewRoot();
if (viewRoot.isTransient())
@@ -68,7 +71,10 @@ public class StateManagerImpl extends St
Object serializedComponentStates = viewRoot.processSaveState(facesContext);
//Locale is a state attribute of UIViewRoot and need not be saved explicitly
- if (log.isLoggable(Level.FINEST)) log.finest("Exiting getComponentStateToSave");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Exiting getComponentStateToSave");
+ }
return serializedComponentStates;
}
@@ -81,7 +87,10 @@ public class StateManagerImpl extends St
@Override
protected Object getTreeStructureToSave(FacesContext facesContext)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Entering getTreeStructureToSave");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Entering getTreeStructureToSave");
+ }
UIViewRoot viewRoot = facesContext.getViewRoot();
if (viewRoot.isTransient())
{
@@ -89,14 +98,20 @@ public class StateManagerImpl extends St
}
TreeStructureManager tsm = new TreeStructureManager();
Object retVal = tsm.buildTreeStructureToSave(viewRoot);
- if (log.isLoggable(Level.FINEST)) log.finest("Exiting getTreeStructureToSave");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Exiting getTreeStructureToSave");
+ }
return retVal;
}
@Override
public UIViewRoot restoreView(FacesContext facesContext, String viewId, String renderKitId)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Entering restoreView - viewId: "+viewId+" ; renderKitId: "+renderKitId);
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Entering restoreView - viewId: " + viewId + " ; renderKitId: " + renderKitId);
+ }
UIViewRoot uiViewRoot = null;
@@ -110,7 +125,10 @@ public class StateManagerImpl extends St
if (sms != null)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Redirect to StateManagementStrategy: "+sms.getClass().getName());
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Redirect to StateManagementStrategy: " + sms.getClass().getName());
+ }
uiViewRoot = sms.restoreView(facesContext, viewId, renderKitId);
}
@@ -121,18 +139,23 @@ public class StateManagerImpl extends St
Object state = responseStateManager.getState(facesContext, viewId);
- if (state != null) {
+ if (state != null)
+ {
Object[] stateArray = (Object[])state;
TreeStructureManager tsm = new TreeStructureManager();
uiViewRoot = tsm.restoreTreeStructure(stateArray[0]);
- if (uiViewRoot != null) {
+ if (uiViewRoot != null)
+ {
facesContext.setViewRoot (uiViewRoot);
uiViewRoot.processRestoreState(facesContext, stateArray[1]);
}
}
}
- if (log.isLoggable(Level.FINEST)) log.finest("Exiting restoreView - "+viewId);
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Exiting restoreView - " + viewId);
+ }
return uiViewRoot;
}
@@ -161,7 +184,10 @@ public class StateManagerImpl extends St
if (sms != null)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Calling saveView of StateManagementStrategy: "+sms.getClass().getName());
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Calling saveView of StateManagementStrategy: " + sms.getClass().getName());
+ }
serializedView = sms.saveView(facesContext);
@@ -169,7 +195,8 @@ public class StateManagerImpl extends St
// additional operations for save the state if is necessary.
if (StateCacheUtils.isMyFacesResponseStateManager(responseStateManager))
{
- StateCacheUtils.getMyFacesResponseStateManager(responseStateManager).saveState(facesContext, serializedView);
+ StateCacheUtils.getMyFacesResponseStateManager(responseStateManager).
+ saveState(facesContext, serializedView);
}
return serializedView;
@@ -185,39 +212,55 @@ public class StateManagerImpl extends St
return null;
}
- if (log.isLoggable(Level.FINEST)) log.finest("Entering saveSerializedView");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Entering saveSerializedView");
+ }
checkForDuplicateIds(facesContext, facesContext.getViewRoot(), new HashSet<String>());
- if (log.isLoggable(Level.FINEST)) log.finest("Processing saveSerializedView - Checked for duplicate Ids");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Processing saveSerializedView - Checked for duplicate Ids");
+ }
ExternalContext externalContext = facesContext.getExternalContext();
// SerializedView already created before within this request?
- serializedView = externalContext.getRequestMap()
+ serializedView = facesContext.getAttributes()
.get(SERIALIZED_VIEW_REQUEST_ATTR);
if (serializedView == null)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Processing saveSerializedView - create new serialized view");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Processing saveSerializedView - create new serialized view");
+ }
// first call to saveSerializedView --> create SerializedView
Object treeStruct = getTreeStructureToSave(facesContext);
Object compStates = getComponentStateToSave(facesContext);
serializedView = new Object[] {treeStruct, compStates};
- externalContext.getRequestMap().put(SERIALIZED_VIEW_REQUEST_ATTR,
+ facesContext.getAttributes().put(SERIALIZED_VIEW_REQUEST_ATTR,
serializedView);
- if (log.isLoggable(Level.FINEST)) log.finest("Processing saveSerializedView - new serialized view created");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Processing saveSerializedView - new serialized view created");
+ }
}
// If MyfacesResponseStateManager is used, give the option to do
// additional operations for save the state if is necessary.
if (StateCacheUtils.isMyFacesResponseStateManager(responseStateManager))
{
- StateCacheUtils.getMyFacesResponseStateManager(responseStateManager).saveState(facesContext, serializedView);
+ StateCacheUtils.getMyFacesResponseStateManager(responseStateManager).
+ saveState(facesContext, serializedView);
}
- if (log.isLoggable(Level.FINEST)) log.finest("Exiting saveView");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Exiting saveView");
+ }
}
finally
{
@@ -282,7 +325,9 @@ public class StateManagerImpl extends St
private static void getPathToComponent(UIComponent component, StringBuffer buf)
{
if(component == null)
+ {
return;
+ }
StringBuffer intBuf = new StringBuffer();
@@ -309,7 +354,10 @@ public class StateManagerImpl extends St
public void writeState(FacesContext facesContext,
Object state) throws IOException
{
- if (log.isLoggable(Level.FINEST)) log.finest("Entering writeState");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Entering writeState");
+ }
//UIViewRoot uiViewRoot = facesContext.getViewRoot();
//save state in response (client)
@@ -318,7 +366,10 @@ public class StateManagerImpl extends St
responseStateManager.writeState(facesContext, state);
- if (log.isLoggable(Level.FINEST)) log.finest("Exiting writeState");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Exiting writeState");
+ }
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/ServerSideStateCacheImpl.java Sat Mar 3 16:27:42 2012
@@ -78,12 +78,16 @@ class ServerSideStateCacheImpl extends S
*
* <p>Only applicable if state saving method is "server" (= default). For example, if this param has value = 2 and
* in your custom webapp there is a form that is clicked 3 times, only 2 views
- * will be stored and the third one (the one stored the first time) will be removed from session, even if the view can
- * store more sessions org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION. This feature becomes useful for multi-window applications.
- * where without this feature a window can swallow all view slots so the other ones will throw ViewExpiredException.</p>
+ * will be stored and the third one (the one stored the first time) will be
+ * removed from session, even if the view can
+ * store more sessions org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION.
+ * This feature becomes useful for multi-window applications.
+ * where without this feature a window can swallow all view slots so
+ * the other ones will throw ViewExpiredException.</p>
*/
@JSFWebConfigParam(since="2.0.6", classType="java.lang.Integer", group="state", tags="performance")
- private static final String NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_PARAM = "org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION";
+ private static final String NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION_PARAM
+ = "org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION";
/**
* Default value for <code>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</code> context parameter.
@@ -104,7 +108,8 @@ class ServerSideStateCacheImpl extends S
/**
* Indicates that the serialized state will be compressed before it is written to the session. By default true.
*
- * Only applicable if state saving method is "server" (= default) and if <code>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</code> is <code>true</code> (= default).
+ * Only applicable if state saving method is "server" (= default) and if
+ * <code>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</code> is <code>true</code> (= default).
* If <code>true</code> (default) the serialized state will be compressed before it is written to the session.
* If <code>false</code> the state will not be compressed.
*/
@@ -144,7 +149,8 @@ class ServerSideStateCacheImpl extends S
* </ul>
*
*/
- @JSFWebConfigParam(defaultValue="off", expectedValues="off, no, hard-soft, soft, soft-weak, weak", since="1.2.5", group="state", tags="performance")
+ @JSFWebConfigParam(defaultValue="off", expectedValues="off, no, hard-soft, soft, soft-weak, weak",
+ since="1.2.5", group="state", tags="performance")
private static final String CACHE_OLD_VIEWS_IN_SESSION_MODE = "org.apache.myfaces.CACHE_OLD_VIEWS_IN_SESSION_MODE";
/**
@@ -171,7 +177,8 @@ class ServerSideStateCacheImpl extends S
* The default value is false.</p>
*/
@JSFWebConfigParam(since="2.0.6", defaultValue="false", expectedValues="true, false", group="state")
- private static final String USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION = "org.apache.myfaces.USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION";
+ private static final String USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION
+ = "org.apache.myfaces.USE_FLASH_SCOPE_PURGE_VIEWS_IN_SESSION";
private static final int UNCOMPRESSED_FLAG = 0;
private static final int COMPRESSED_FLAG = 1;
@@ -221,9 +228,11 @@ class ServerSideStateCacheImpl extends S
if (key == null )
{
if (isUseFlashScopePurgeViewsInSession(context.getExternalContext()) &&
- Boolean.TRUE.equals(context.getExternalContext().getRequestMap().get("oam.Flash.REDIRECT.PREVIOUSREQUEST")))
+ Boolean.TRUE.equals(context.getExternalContext().getRequestMap()
+ .get("oam.Flash.REDIRECT.PREVIOUSREQUEST")))
{
- key = (SerializedViewKey) context.getExternalContext().getFlash().get(RESTORED_VIEW_KEY_REQUEST_ATTR);
+ key = (SerializedViewKey)
+ context.getExternalContext().getFlash().get(RESTORED_VIEW_KEY_REQUEST_ATTR);
}
}
}
@@ -283,7 +292,8 @@ class ServerSideStateCacheImpl extends S
}
attributeMap.put(RESTORED_SERIALIZED_VIEW_REQUEST_ATTR, serializedView);
- if (getNumberOfSequentialViewsInSession(externalContext) != null && getNumberOfSequentialViewsInSession(externalContext) > 0)
+ if (getNumberOfSequentialViewsInSession(externalContext) != null &&
+ getNumberOfSequentialViewsInSession(externalContext) > 0)
{
SerializedViewKey key = new SerializedViewKey(viewId, sequence);
attributeMap.put(RESTORED_VIEW_KEY_REQUEST_ATTR, key);
@@ -302,14 +312,12 @@ class ServerSideStateCacheImpl extends S
public int getNextViewSequence(FacesContext context)
{
- ExternalContext externalContext = context.getExternalContext();
-
- if (!externalContext.getRequestMap().containsKey(RendererUtils.SEQUENCE_PARAM))
+ if (!context.getAttributes().containsKey(RendererUtils.SEQUENCE_PARAM))
{
nextViewSequence(context);
}
- Integer sequence = (Integer) externalContext.getRequestMap().get(RendererUtils.SEQUENCE_PARAM);
+ Integer sequence = (Integer) context.getAttributes().get(RendererUtils.SEQUENCE_PARAM);
return sequence.intValue();
}
@@ -317,11 +325,12 @@ class ServerSideStateCacheImpl extends S
{
ExternalContext externalContext = facescontext.getExternalContext();
Object sessionObj = externalContext.getSession(true);
+ Integer sequence = null;
synchronized(sessionObj) // synchronized to increase sequence if multiple requests
// are handled at the same time for the session
{
Map<String, Object> map = externalContext.getSessionMap();
- Integer sequence = (Integer) map.get(RendererUtils.SEQUENCE_PARAM);
+ sequence = (Integer) map.get(RendererUtils.SEQUENCE_PARAM);
if(sequence == null || sequence.intValue() == Integer.MAX_VALUE)
{
sequence = Integer.valueOf(1);
@@ -331,17 +340,23 @@ class ServerSideStateCacheImpl extends S
sequence = Integer.valueOf(sequence.intValue() + 1);
}
map.put(RendererUtils.SEQUENCE_PARAM, sequence);
- externalContext.getRequestMap().put(RendererUtils.SEQUENCE_PARAM, sequence);
}
+ facescontext.getAttributes().put(RendererUtils.SEQUENCE_PARAM, sequence);
}
protected Object serializeView(FacesContext context, Object serializedView)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Entering serializeView");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Entering serializeView");
+ }
if(isSerializeStateInSession(context))
{
- if (log.isLoggable(Level.FINEST)) log.finest("Processing serializeView - serialize state in session");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Processing serializeView - serialize state in session");
+ }
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
try
@@ -349,14 +364,20 @@ class ServerSideStateCacheImpl extends S
OutputStream os = baos;
if(isCompressStateInSession(context))
{
- if (log.isLoggable(Level.FINEST)) log.finest("Processing serializeView - serialize compressed");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Processing serializeView - serialize compressed");
+ }
os.write(COMPRESSED_FLAG);
os = new GZIPOutputStream(os, 1024);
}
else
{
- if (log.isLoggable(Level.FINEST)) log.finest("Processing serializeView - serialize uncompressed");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Processing serializeView - serialize uncompressed");
+ }
os.write(UNCOMPRESSED_FLAG);
}
@@ -371,7 +392,10 @@ class ServerSideStateCacheImpl extends S
out.close();
baos.close();
- if (log.isLoggable(Level.FINEST)) log.finest("Exiting serializeView - serialized. Bytes : "+baos.size());
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Exiting serializeView - serialized. Bytes : " + baos.size());
+ }
return baos.toByteArray();
}
catch (IOException e)
@@ -383,7 +407,9 @@ class ServerSideStateCacheImpl extends S
if (log.isLoggable(Level.FINEST))
+ {
log.finest("Exiting serializeView - do not serialize state in session.");
+ }
return serializedView;
@@ -391,7 +417,7 @@ class ServerSideStateCacheImpl extends S
/**
* Reads the value of the <code>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</code> context parameter.
- * @see SERIALIZE_STATE_IN_SESSION_PARAM
+ * @see #SERIALIZE_STATE_IN_SESSION_PARAM
* @param context <code>FacesContext</code> for the request we are processing.
* @return boolean true, if the server state should be serialized in the session
*/
@@ -409,7 +435,7 @@ class ServerSideStateCacheImpl extends S
/**
* Reads the value of the <code>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</code> context parameter.
- * @see COMPRESS_SERVER_STATE_PARAM
+ * @see #COMPRESS_SERVER_STATE_PARAM
* @param context <code>FacesContext</code> for the request we are processing.
* @return boolean true, if the server state steam should be compressed
*/
@@ -427,11 +453,18 @@ class ServerSideStateCacheImpl extends S
protected Object deserializeView(Object state)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Entering deserializeView");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Entering deserializeView");
+ }
if(state instanceof byte[])
{
- if (log.isLoggable(Level.FINEST)) log.finest("Processing deserializeView - deserializing serialized state. Bytes : "+((byte[]) state).length);
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Processing deserializeView - deserializing serialized state. Bytes : "
+ + ((byte[]) state).length);
+ }
try
{
@@ -492,7 +525,10 @@ class ServerSideStateCacheImpl extends S
}
else if (state instanceof Object[])
{
- if (log.isLoggable(Level.FINEST)) log.finest("Exiting deserializeView - state not serialized.");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Exiting deserializeView - state not serialized.");
+ }
return state;
}
@@ -503,7 +539,8 @@ class ServerSideStateCacheImpl extends S
}
else
{
- log.severe("Exiting deserializeView - this method should not be called with a state of type : "+state.getClass());
+ log.severe("Exiting deserializeView - this method should not be called with a state of type : "
+ + state.getClass());
return null;
}
}
@@ -530,7 +567,8 @@ class ServerSideStateCacheImpl extends S
{
private static final long serialVersionUID = -3734849062185115847L;
- private final List<SerializedViewKey> _keys = new ArrayList<SerializedViewKey>(DEFAULT_NUMBER_OF_VIEWS_IN_SESSION);
+ private final List<SerializedViewKey> _keys
+ = new ArrayList<SerializedViewKey>(DEFAULT_NUMBER_OF_VIEWS_IN_SESSION);
private final Map<SerializedViewKey, Object> _serializedViews = new HashMap<SerializedViewKey, Object>();
private final Map<SerializedViewKey, SerializedViewKey> _precedence =
@@ -540,7 +578,8 @@ class ServerSideStateCacheImpl extends S
// the garbage collector if free memory is low
private transient Map<Object, Object> _oldSerializedViews = null;
- public synchronized void add(FacesContext context, Object state, Integer nextSequence, SerializedViewKey previousRestoredKey)
+ public synchronized void add(FacesContext context, Object state, Integer nextSequence,
+ SerializedViewKey previousRestoredKey)
{
SerializedViewKey key = new SerializedViewKey(context.getViewRoot().getViewId(), nextSequence);
_serializedViews.put(key, state);
@@ -554,7 +593,10 @@ class ServerSideStateCacheImpl extends S
}
}
- while (_keys.remove(key));
+ while (_keys.remove(key))
+ {
+ // do nothing
+ }
_keys.add(key);
if (previousRestoredKey != null && maxCount != null && maxCount > 0)
@@ -575,7 +617,10 @@ class ServerSideStateCacheImpl extends S
// put on that map.
do
{
- while (_keys.remove(keyToRemove));
+ while (_keys.remove(keyToRemove))
+ {
+ // do nothing
+ }
Object oldView = _serializedViews.remove(keyToRemove);
if (oldView != null &&
@@ -623,7 +668,7 @@ class ServerSideStateCacheImpl extends S
/**
* Reads the amount (default = 20) of views to be stored in session.
- * @see NUMBER_OF_VIEWS_IN_SESSION_PARAM
+ * @see #NUMBER_OF_VIEWS_IN_SESSION_PARAM
* @param context FacesContext for the current request, we are processing
* @return Number vf views stored in the session
*/
@@ -692,7 +737,7 @@ class ServerSideStateCacheImpl extends S
* @since 1.2.5
* @param context
* @return constant indicating caching mode
- * @see CACHE_OLD_VIEWS_IN_SESSION_MODE
+ * @see #CACHE_OLD_VIEWS_IN_SESSION_MODE
*/
protected String getCacheOldViewsInSessionMode(FacesContext context)
{
@@ -763,10 +808,10 @@ class ServerSideStateCacheImpl extends S
@Override
public int hashCode()
{
- final int PRIME = 31;
+ final int prime = 31;
int result = 1;
- result = PRIME * result + ((_sequenceId == null) ? 0 : _sequenceId.hashCode());
- result = PRIME * result + ((_viewId == null) ? 0 : _viewId.hashCode());
+ result = prime * result + ((_sequenceId == null) ? 0 : _sequenceId.hashCode());
+ result = prime * result + ((_viewId == null) ? 0 : _viewId.hashCode());
return result;
}
@@ -774,26 +819,40 @@ class ServerSideStateCacheImpl extends S
public boolean equals(Object obj)
{
if (this == obj)
+ {
return true;
+ }
if (obj == null)
+ {
return false;
+ }
if (getClass() != obj.getClass())
+ {
return false;
+ }
final SerializedViewKey other = (SerializedViewKey) obj;
if (_sequenceId == null)
{
if (other._sequenceId != null)
+ {
return false;
+ }
}
else if (!_sequenceId.equals(other._sequenceId))
+ {
return false;
+ }
if (_viewId == null)
{
if (other._viewId != null)
+ {
return false;
+ }
}
else if (!_viewId.equals(other._viewId))
+ {
return false;
+ }
return true;
}
@@ -804,11 +863,17 @@ class ServerSideStateCacheImpl extends S
@Override
public Object saveSerializedView(FacesContext facesContext, Object serializedView)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Processing saveSerializedView - server-side state saving - save state");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Processing saveSerializedView - server-side state saving - save state");
+ }
//save state in server session
saveSerializedViewInServletSession(facesContext, serializedView);
- if (log.isLoggable(Level.FINEST)) log.finest("Exiting saveSerializedView - server-side state saving - saved state");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Exiting saveSerializedView - server-side state saving - saved state");
+ }
return encodeSerializedState(facesContext, serializedView);
}
@@ -816,11 +881,16 @@ class ServerSideStateCacheImpl extends S
@Override
public Object restoreSerializedView(FacesContext facesContext, String viewId, Object viewState)
{
- if (log.isLoggable(Level.FINEST)) log.finest("Restoring view from session");
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("Restoring view from session");
+ }
Integer serverStateId = getServerStateId((Object[]) viewState);
- return (serverStateId == null) ? null : getSerializedViewFromServletSession(facesContext, viewId, serverStateId);
+ return (serverStateId == null)
+ ? null
+ : getSerializedViewFromServletSession(facesContext, viewId, serverStateId);
}
public Object encodeSerializedState(FacesContext facesContext, Object serializedView)
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java Sat Mar 3 16:27:42 2012
@@ -471,7 +471,7 @@ public class DefaultFaceletsStateManagem
ExternalContext externalContext = context.getExternalContext();
- Object serializedView = externalContext.getRequestMap()
+ Object serializedView = context.getAttributes()
.get(SERIALIZED_VIEW_REQUEST_ATTR);
//Note on ajax case the method saveState could be called twice: once before start
@@ -552,7 +552,7 @@ public class DefaultFaceletsStateManagem
//externalContext.getRequestMap().put(SERIALIZED_VIEW_REQUEST_ATTR,
// getStateCache().encodeSerializedState(context, serializedView));
- externalContext.getRequestMap().put(SERIALIZED_VIEW_REQUEST_ATTR, serializedView);
+ context.getAttributes().put(SERIALIZED_VIEW_REQUEST_ATTR, serializedView);
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java Sat Mar 3 16:27:42 2012
@@ -291,9 +291,11 @@ public class FaceletViewDeclarationLangu
*/
public final static String MARK_INITIAL_STATE_KEY = "org.apache.myfaces.MARK_INITIAL_STATE";
- public final static String IS_BUILDING_INITIAL_STATE_KEY_ALIAS = "javax.faces.view.ViewDeclarationLanguage.IS_BUILDING_INITIAL_STATE";
+ public final static String IS_BUILDING_INITIAL_STATE_KEY_ALIAS
+ = "javax.faces.view.ViewDeclarationLanguage.IS_BUILDING_INITIAL_STATE";
- public final static String CLEAN_TRANSIENT_BUILD_ON_RESTORE = "org.apache.myfaces.CLEAN_TRANSIENT_BUILD_ON_RESTORE";
+ public final static String CLEAN_TRANSIENT_BUILD_ON_RESTORE
+ = "org.apache.myfaces.CLEAN_TRANSIENT_BUILD_ON_RESTORE";
private final static String STATE_KEY = "<!-...@-->";
@@ -511,7 +513,8 @@ public class FaceletViewDeclarationLangu
public static void _publishPostBuildComponentTreeOnRestoreViewEvent(FacesContext context, UIComponent component)
{
- context.getApplication().publishEvent(context, PostBuildComponentTreeOnRestoreViewEvent.class, component.getClass(), component);
+ context.getApplication().publishEvent(context, PostBuildComponentTreeOnRestoreViewEvent.class,
+ component.getClass(), component);
if (component.getChildCount() > 0)
{
@@ -585,7 +588,8 @@ public class FaceletViewDeclarationLangu
FaceletFactory.setInstance(_faceletFactory);
try
{
- compositeComponentFacelet = _faceletFactory.getCompositeComponentMetadataFacelet(componentResource.getURL());
+ compositeComponentFacelet
+ = _faceletFactory.getCompositeComponentMetadataFacelet(componentResource.getURL());
}
finally
{
@@ -595,7 +599,8 @@ public class FaceletViewDeclarationLangu
// Create a temporal tree where all components will be put, but we are only
// interested in metadata.
- UINamingContainer compositeComponentBase = (UINamingContainer) context.getApplication().createComponent(UINamingContainer.COMPONENT_TYPE);
+ UINamingContainer compositeComponentBase
+ = (UINamingContainer) context.getApplication().createComponent(UINamingContainer.COMPONENT_TYPE);
// Fill the component resource key, because this information should be available
// on metadata to recognize which is the component used as composite component base.
@@ -716,7 +721,8 @@ public class FaceletViewDeclarationLangu
public void retargetAttachedObjects(FacesContext context,
UIComponent topLevelComponent, List<AttachedObjectHandler> handlerList)
{
- BeanInfo compositeComponentMetadata = (BeanInfo) topLevelComponent.getAttributes().get(UIComponent.BEANINFO_KEY);
+ BeanInfo compositeComponentMetadata
+ = (BeanInfo) topLevelComponent.getAttributes().get(UIComponent.BEANINFO_KEY);
if (compositeComponentMetadata == null)
{
@@ -960,8 +966,9 @@ public class FaceletViewDeclarationLangu
{
if (log.isLoggable(Level.SEVERE))
{
- log.severe("attributeValueExpression not found under the key \"" + attributeName +
- "\". Looking for the next attribute");
+ log.severe("attributeValueExpression not found under the key \""
+ + attributeName
+ + "\". Looking for the next attribute");
}
}
}
@@ -1828,10 +1835,10 @@ public class FaceletViewDeclarationLangu
}
// get our content type
- String contentType = (String) extContext.getRequestMap().get("facelets.ContentType");
+ String contentType = (String) context.getAttributes().get("facelets.ContentType");
// get the encoding
- String encoding = (String) extContext.getRequestMap().get("facelets.Encoding");
+ String encoding = (String) context.getAttributes().get("facelets.Encoding");
// -= Leonardo Uribe =- Add */* to the contentType is a fix done from FaceletViewHandler
// to make old RI versions work, but since this is for JSF 2.0 it is not necessary that code.
@@ -1914,7 +1921,7 @@ public class FaceletViewDeclarationLangu
String contentType = orig;
// see if we need to override the contentType
- Map<String, Object> m = context.getExternalContext().getRequestMap();
+ Map<Object, Object> m = context.getAttributes();
if (m.containsKey("facelets.ContentType"))
{
contentType = (String) m.get("facelets.ContentType");
@@ -1946,7 +1953,7 @@ public class FaceletViewDeclarationLangu
String encoding = orig;
// see if we need to override the encoding
- Map<String, Object> m = context.getExternalContext().getRequestMap();
+ Map<Object, Object> m = context.getAttributes();
Map<String, Object> sm = context.getExternalContext().getSessionMap();
// 1. check the request attribute
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewHandler.java Sat Mar 3 16:27:42 2012
@@ -241,9 +241,13 @@ public class FaceletViewHandler extends
long refreshPeriod;
if(ctx.isProjectStage(ProjectStage.Production))
+ {
refreshPeriod = DEFAULT_REFRESH_PERIOD_PRODUCTION;
+ }
else
+ {
refreshPeriod = DEFAULT_REFRESH_PERIOD;
+ }
String userPeriod = ctx.getExternalContext().getInitParameter(PARAM_REFRESH_PERIOD);
if (userPeriod != null && userPeriod.length() > 0)
@@ -408,10 +412,10 @@ public class FaceletViewHandler extends
}
// get our content type
- String contentType = (String) extContext.getRequestMap().get("facelets.ContentType");
+ String contentType = (String) context.getAttributes().get("facelets.ContentType");
// get the encoding
- String encoding = (String) extContext.getRequestMap().get("facelets.Encoding");
+ String encoding = (String) context.getAttributes().get("facelets.Encoding");
ResponseWriter writer;
// append */* to the contentType so createResponseWriter will succeed no matter
@@ -463,7 +467,7 @@ public class FaceletViewHandler extends
String encoding = orig;
// see if we need to override the encoding
- Map<String, Object> m = context.getExternalContext().getRequestMap();
+ Map<Object, Object> m = context.getAttributes();
Map<String, Object> sm = context.getExternalContext().getSessionMap();
// 1. check the request attribute
@@ -519,7 +523,7 @@ public class FaceletViewHandler extends
String contentType = orig;
// see if we need to override the contentType
- Map<String, Object> m = context.getExternalContext().getRequestMap();
+ Map<Object, Object> m = context.getAttributes();
if (m.containsKey("facelets.ContentType"))
{
contentType = (String) m.get("facelets.ContentType");
@@ -712,7 +716,9 @@ public class FaceletViewHandler extends
finally
{
if (stateWriter != null)
+ {
stateWriter.release();
+ }
}
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/EncodingHandler.java Sat Mar 3 16:27:42 2012
@@ -45,15 +45,15 @@ public class EncodingHandler implements
this.next.apply(ctx, parent);
if (this.encoding == null)
{
- if (!ctx.getFacesContext().getExternalContext().getRequestMap().containsKey("facelets.Encoding"))
+ if (!ctx.getFacesContext().getAttributes().containsKey("facelets.Encoding"))
{
- ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", "UTF-8");
+ ctx.getFacesContext().getAttributes().put("facelets.Encoding", "UTF-8");
}
}
else
{
//Encoding of document takes precedence over f:view contentType
- ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", this.encoding);
+ ctx.getFacesContext().getAttributes().put("facelets.Encoding", this.encoding);
}
}
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewHandler.java Sat Mar 3 16:27:42 2012
@@ -131,16 +131,16 @@ public final class ViewHandler extends T
}
}
}
- ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.ContentType", v);
+ ctx.getFacesContext().getAttributes().put("facelets.ContentType", v);
}
if (this.encoding != null)
{
String v = this.encoding.getValue(ctx);
- ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", v);
+ ctx.getFacesContext().getAttributes().put("facelets.Encoding", v);
}
else if (encodingValue != null)
{
- ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", encodingValue);
+ ctx.getFacesContext().getAttributes().put("facelets.Encoding", encodingValue);
}
if (this.beforePhase != null)
{
Modified: myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategyTest.java Sat Mar 3 16:27:42 2012
@@ -420,7 +420,7 @@ public class DefaultFaceletsStateManagem
public UIViewRoot saveAndRestore(StateManagementStrategy stateManagement, UIViewRoot viewRoot)
{
- externalContext.getRequestMap()
+ facesContext.getAttributes()
.remove(StateManagerImpl.class.getName() + ".SERIALIZED_VIEW");
Object state1 = stateManagement.saveView(facesContext);
stateToRestore = state1;
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/application/DefaultViewHandlerSupport.java Sat Mar 3 16:27:42 2012
@@ -247,21 +247,19 @@ public class DefaultViewHandlerSupport i
*/
protected FacesServletMapping getFacesServletMapping(FacesContext context)
{
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ Map<Object, Object> attributes = context.getAttributes();
// Has the mapping already been determined during this request?
- if (!requestMap.containsKey(CACHED_SERVLET_MAPPING))
+ FacesServletMapping mapping = (FacesServletMapping) attributes.get(CACHED_SERVLET_MAPPING);
+ if (mapping == null)
{
ExternalContext externalContext = context.getExternalContext();
- FacesServletMapping mapping =
- calculateFacesServletMapping(
- externalContext.getRequestServletPath(),
+ mapping = calculateFacesServletMapping(externalContext.getRequestServletPath(),
externalContext.getRequestPathInfo());
- requestMap.put(CACHED_SERVLET_MAPPING, mapping);
+ attributes.put(CACHED_SERVLET_MAPPING, mapping);
}
-
- return (FacesServletMapping) requestMap.get(CACHED_SERVLET_MAPPING);
+ return mapping;
}
/**
Modified: myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java?rev=1296657&r1=1296656&r2=1296657&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java (original)
+++ myfaces/core/branches/2.0.x/shared/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java Sat Mar 3 16:27:42 2012
@@ -1212,6 +1212,10 @@ public final class RendererUtils
dest.setValidator(src.getValidator());
}
+ /**
+ * @deprecated Logic corrected and encapsulated better in org.apache.myfaces.renderkit.ServerSideStateCacheImpl
+ */
+ @Deprecated
public static Integer getViewSequence(FacesContext facescontext)
{
Map map = facescontext.getExternalContext().getRequestMap();