You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/02/22 16:57:12 UTC
svn commit: r630232 [1/2] - in
/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra:
filter/ frameworkAdapter/ frameworkAdapter/basic/ frameworkAdapter/jsf/
frameworkAdapter/local/ lib/ lib/jsf/
Author: skitching
Date: Fri Feb 22 07:57:09 2008
New Revision: 630232
URL: http://svn.apache.org/viewvc?rev=630232&view=rev
Log:
Tabs to spaces; a couple of other code formatting tweaks.
Modified:
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/filter/OrchestraServletFilter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/_FrameworkAdapterUtils.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapterFilter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/local/LocalFrameworkAdapter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/CompoundFilter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ClassUtils.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_NullFilter.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ReentrantLock.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConfigUtils.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConversationManagerRequestHandler.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/DataSourceLeakRequestHandler.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FacesContextWrapper.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FrameworkAdapterRequestHandler.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraFacesContextFactory.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/RequestHandler.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/SerializableConverter.java
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/filter/OrchestraServletFilter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/filter/OrchestraServletFilter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/filter/OrchestraServletFilter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/filter/OrchestraServletFilter.java Fri Feb 22 07:57:09 2008
@@ -52,30 +52,31 @@
public class OrchestraServletFilter implements Filter
{
- /**
- * This filter init property can be set to "true" or "false". Default: "true".
- */
- public final static String SERIALIZE_REQUESTS = "serializeRequests"; // NON-NLS
+ /**
+ * This filter init property can be set to "true" or "false". Default: "true".
+ */
+ public final static String SERIALIZE_REQUESTS = "serializeRequests"; // NON-NLS
- private boolean serializeRequests = true;
+ private boolean serializeRequests = true;
- public void init(FilterConfig filterConfig) throws ServletException
- {
- String value = filterConfig.getInitParameter(SERIALIZE_REQUESTS);
- if ("false".equals(value)) // NON-NLS
- {
- serializeRequests = false;
- }
- }
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ String value = filterConfig.getInitParameter(SERIALIZE_REQUESTS);
+ if ("false".equals(value)) // NON-NLS
+ {
+ serializeRequests = false;
+ }
+ }
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException
- {
- // Copy the setting over to where the ContextLockRequestHandler class can see it.
- servletRequest.setAttribute(CoreConfig.SERIALIZE_REQUESTS, Boolean.valueOf(serializeRequests));
- filterChain.doFilter(servletRequest, servletResponse);
- }
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
+ final FilterChain filterChain) throws IOException, ServletException
+ {
+ // Copy the setting over to where the ContextLockRequestHandler class can see it.
+ servletRequest.setAttribute(CoreConfig.SERIALIZE_REQUESTS, Boolean.valueOf(serializeRequests));
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
- public void destroy()
- {
- }
-}
\ No newline at end of file
+ public void destroy()
+ {
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/FrameworkAdapter.java Fri Feb 22 07:57:09 2008
@@ -36,182 +36,182 @@
*/
public abstract class FrameworkAdapter
{
- private final static ThreadLocal instance = new ThreadLocal();
+ private final static ThreadLocal instance = new ThreadLocal();
- private ConversationMessager conversationMessager;
- private boolean prepared = false;
+ private ConversationMessager conversationMessager;
+ private boolean prepared = false;
- /**
- * Expected to be called only by a servlet filter at the start and end of each request.
- * <p>
- * The prepare method of the provided frameworkAdapter is called if it has not already
- * been done. This ensures that the object is valid before the request begins. An
- * unchecked exception may therefore be thrown if the instance is misconfigured.
- */
- public static void setCurrentInstance(FrameworkAdapter frameworkAdapter)
- {
- if (frameworkAdapter == null)
- {
- instance.remove();
- return;
- }
-
- synchronized(frameworkAdapter)
- {
- if (!frameworkAdapter.prepared)
- {
- frameworkAdapter.prepare();
- }
- }
-
- instance.set(frameworkAdapter);
- }
-
- /**
- * Return an object that implements the non-static methods of this abstract
- * class in a manner appropriate for whatever UI framework is handling the
- * current request.
- */
- public static FrameworkAdapter getCurrentInstance()
- {
- return (FrameworkAdapter) instance.get();
- }
-
- /**
- * Constructor.
- * <p>
- * This constructor deliberately takes no parameters, as this class may be extended
- * in future releases, adding new framework-specific properties if more are needed.
- * Changing the constructor would not be elegant, so instead this class uses
- * "setter" methods to set the properties of this object, and the prepare() method
- * to ensure object integrity.
- */
- public FrameworkAdapter()
- {
- }
-
- /**
- * Ensure this object is valid, and perform any once-only initialisation required.
- * <p>
- * This method must be called before any call to any method on this class
- * other than setters. Multiple calls to this method are safe; all except the first
- * one will be ignored. The setCurrentInstance method calls this method
- * automatically.
- * <p>
- * This method may be overridden by subclasses to perform once-only initialisation.
- * If this is done, call super.prepare at the end of the subclass implementation.
- * <p>
- * This method can throw unchecked exceptions if there is a problem with the
- * configuration of this object.
- */
- public void prepare()
- {
- if (conversationMessager == null)
- {
- // Not set via an explicit call to the setter, and not set
- // from a child class implementation of this method, so
- // try to do it here.
- conversationMessager = createConversationMessager();
- }
-
- synchronized(this)
- {
- prepared = true;
- }
- }
-
- /**
- * If this method is not overridden by a subclass, then method setConversationMessager
- * must be used to explicitly provide an instance.
- */
- protected ConversationMessager createConversationMessager()
- {
- throw new IllegalStateException("conversation messager configuration missing"); // NON-NLS
- }
-
- /**
- * Return an object that can report internal application problems to the user associated
- * with the current request.
- * <p>
- * If setConversationManager was called explicitly when this object was set up, then the
- * provided instance is returned. Otherwise what is returned is determined by the
- * concrete subclass. See the appropriate subclass documentation for details.
- */
- public ConversationMessager getConversationMessager()
- {
- return conversationMessager;
- }
-
- /**
- * Set the object that can report internal application problems to the user associated
- * with a request. This method is only ever expected to be called once, during
- * configuration of a FrameworkAdapter instance.
- */
- public void setConversationMessager(ConversationMessager conversationMessager)
- {
- this.conversationMessager = conversationMessager;
- }
-
- /**
- * Return the global init parameter with the specified name.
- * In most cases this is expected to return data from the ServletContext.
- */
- public abstract String getInitParameter(String key);
-
- /**
- * Get a value from the set of input parameters sent by the user as part
- * of the request.
- */
- public abstract Object getRequestParameterAttribute(String key);
-
- public abstract boolean containsRequestParameterAttribute(String key);
-
- /**
- * Get a request-scope variable.
- */
- public abstract Object getRequestAttribute(String key);
-
- public abstract void setRequestAttribute(String key, Object value);
-
- public abstract boolean containsRequestAttribute(String key);
-
- /**
- * Get a variable from the session-scope of the current user.
- */
- public abstract Object getSessionAttribute(String key);
-
- public abstract void setSessionAttribute(String key, Object value);
-
- public abstract boolean containsSessionAttribute(String key);
-
- /**
- * Instruct the remote browser to fetch the specified URL.
- */
- public abstract void redirect(String url) throws IOException;
-
- /**
- * Return the variable with the specified name, or null if no such bean exists.
- * <p>
- * In frameworks that support "managed beans", ie creation of objects on demand then
- * this may trigger the creation of the specified object. In frameworks that do not
- * support this, then the lookup may just return null if no object with the specified
- * name currently exists.
- * <p>
- * Note that no "property traversal" is required or expected; a name of "a.b.c"
- * is NOT evaluated as "property c of property b of bean a", but as the bean
- * with name 'a.b.c'.
- */
- public abstract Object getBean(String name);
-
- /**
- * Navigate to the specified logical destination.
- * <p>
- * For frameworks that have a built-in navigation system, that system should be
- * invoked.
- * <p>
- * For frameworks with no logical navigation system, the navigationName is treated
- * as a plain URL. Whether a FORWARD or a REDIRECT to this URL is perfomed is
- * determined by the subclass.
- */
- public abstract void invokeNavigation(String navigationName) throws IOException;
+ /**
+ * Expected to be called only by a servlet filter at the start and end of each request.
+ * <p>
+ * The prepare method of the provided frameworkAdapter is called if it has not already
+ * been done. This ensures that the object is valid before the request begins. An
+ * unchecked exception may therefore be thrown if the instance is misconfigured.
+ */
+ public static void setCurrentInstance(FrameworkAdapter frameworkAdapter)
+ {
+ if (frameworkAdapter == null)
+ {
+ instance.remove();
+ return;
+ }
+
+ synchronized(frameworkAdapter)
+ {
+ if (!frameworkAdapter.prepared)
+ {
+ frameworkAdapter.prepare();
+ }
+ }
+
+ instance.set(frameworkAdapter);
+ }
+
+ /**
+ * Return an object that implements the non-static methods of this abstract
+ * class in a manner appropriate for whatever UI framework is handling the
+ * current request.
+ */
+ public static FrameworkAdapter getCurrentInstance()
+ {
+ return (FrameworkAdapter) instance.get();
+ }
+
+ /**
+ * Constructor.
+ * <p>
+ * This constructor deliberately takes no parameters, as this class may be extended
+ * in future releases, adding new framework-specific properties if more are needed.
+ * Changing the constructor would not be elegant, so instead this class uses
+ * "setter" methods to set the properties of this object, and the prepare() method
+ * to ensure object integrity.
+ */
+ public FrameworkAdapter()
+ {
+ }
+
+ /**
+ * Ensure this object is valid, and perform any once-only initialisation required.
+ * <p>
+ * This method must be called before any call to any method on this class
+ * other than setters. Multiple calls to this method are safe; all except the first
+ * one will be ignored. The setCurrentInstance method calls this method
+ * automatically.
+ * <p>
+ * This method may be overridden by subclasses to perform once-only initialisation.
+ * If this is done, call super.prepare at the end of the subclass implementation.
+ * <p>
+ * This method can throw unchecked exceptions if there is a problem with the
+ * configuration of this object.
+ */
+ public void prepare()
+ {
+ if (conversationMessager == null)
+ {
+ // Not set via an explicit call to the setter, and not set
+ // from a child class implementation of this method, so
+ // try to do it here.
+ conversationMessager = createConversationMessager();
+ }
+
+ synchronized(this)
+ {
+ prepared = true;
+ }
+ }
+
+ /**
+ * If this method is not overridden by a subclass, then method setConversationMessager
+ * must be used to explicitly provide an instance.
+ */
+ protected ConversationMessager createConversationMessager()
+ {
+ throw new IllegalStateException("conversation messager configuration missing"); // NON-NLS
+ }
+
+ /**
+ * Return an object that can report internal application problems to the user associated
+ * with the current request.
+ * <p>
+ * If setConversationManager was called explicitly when this object was set up, then the
+ * provided instance is returned. Otherwise what is returned is determined by the
+ * concrete subclass. See the appropriate subclass documentation for details.
+ */
+ public ConversationMessager getConversationMessager()
+ {
+ return conversationMessager;
+ }
+
+ /**
+ * Set the object that can report internal application problems to the user associated
+ * with a request. This method is only ever expected to be called once, during
+ * configuration of a FrameworkAdapter instance.
+ */
+ public void setConversationMessager(ConversationMessager conversationMessager)
+ {
+ this.conversationMessager = conversationMessager;
+ }
+
+ /**
+ * Return the global init parameter with the specified name.
+ * In most cases this is expected to return data from the ServletContext.
+ */
+ public abstract String getInitParameter(String key);
+
+ /**
+ * Get a value from the set of input parameters sent by the user as part
+ * of the request.
+ */
+ public abstract Object getRequestParameterAttribute(String key);
+
+ public abstract boolean containsRequestParameterAttribute(String key);
+
+ /**
+ * Get a request-scope variable.
+ */
+ public abstract Object getRequestAttribute(String key);
+
+ public abstract void setRequestAttribute(String key, Object value);
+
+ public abstract boolean containsRequestAttribute(String key);
+
+ /**
+ * Get a variable from the session-scope of the current user.
+ */
+ public abstract Object getSessionAttribute(String key);
+
+ public abstract void setSessionAttribute(String key, Object value);
+
+ public abstract boolean containsSessionAttribute(String key);
+
+ /**
+ * Instruct the remote browser to fetch the specified URL.
+ */
+ public abstract void redirect(String url) throws IOException;
+
+ /**
+ * Return the variable with the specified name, or null if no such bean exists.
+ * <p>
+ * In frameworks that support "managed beans", ie creation of objects on demand then
+ * this may trigger the creation of the specified object. In frameworks that do not
+ * support this, then the lookup may just return null if no object with the specified
+ * name currently exists.
+ * <p>
+ * Note that no "property traversal" is required or expected; a name of "a.b.c"
+ * is NOT evaluated as "property c of property b of bean a", but as the bean
+ * with name 'a.b.c'.
+ */
+ public abstract Object getBean(String name);
+
+ /**
+ * Navigate to the specified logical destination.
+ * <p>
+ * For frameworks that have a built-in navigation system, that system should be
+ * invoked.
+ * <p>
+ * For frameworks with no logical navigation system, the navigationName is treated
+ * as a plain URL. Whether a FORWARD or a REDIRECT to this URL is perfomed is
+ * determined by the subclass.
+ */
+ public abstract void invokeNavigation(String navigationName) throws IOException;
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/_FrameworkAdapterUtils.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/_FrameworkAdapterUtils.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/_FrameworkAdapterUtils.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/_FrameworkAdapterUtils.java Fri Feb 22 07:57:09 2008
@@ -29,25 +29,25 @@
*/
public abstract class _FrameworkAdapterUtils
{
- public static ConversationMessager createConversationMessager(String className, Class dfltClass)
- throws OrchestraException
- {
- if (className == null)
- {
- return (ConversationMessager) _ClassUtils.newInstance(dfltClass);
- }
+ public static ConversationMessager createConversationMessager(String className, Class dfltClass)
+ throws OrchestraException
+ {
+ if (className == null)
+ {
+ return (ConversationMessager) _ClassUtils.newInstance(dfltClass);
+ }
- // First try to find a bean of that name in the dependency-injection
- // framework.
- FrameworkAdapter fa = FrameworkAdapter.getCurrentInstance();
- Object instance = fa.getBean(className);
- if (instance instanceof ConversationMessager)
- {
- return (ConversationMessager) instance;
- }
+ // First try to find a bean of that name in the dependency-injection
+ // framework.
+ FrameworkAdapter fa = FrameworkAdapter.getCurrentInstance();
+ Object instance = fa.getBean(className);
+ if (instance instanceof ConversationMessager)
+ {
+ return (ConversationMessager) instance;
+ }
- // Now resort to trying the value as a classname.
- return (ConversationMessager) _ClassUtils.newInstance(className);
- }
+ // Now resort to trying the value as a classname.
+ return (ConversationMessager) _ClassUtils.newInstance(className);
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapter.java Fri Feb 22 07:57:09 2008
@@ -58,236 +58,236 @@
*/
public class BasicFrameworkAdapter extends FrameworkAdapter
{
- private final static String ISE_MESSAGE="No request/response data available"; // NON-NLS
+ private final static String ISE_MESSAGE="No request/response data available"; // NON-NLS
- private final static ThreadLocal httpServletRequest = new ThreadLocal();
- private final static ThreadLocal httpServletResponse = new ThreadLocal();
+ private final static ThreadLocal httpServletRequest = new ThreadLocal();
+ private final static ThreadLocal httpServletResponse = new ThreadLocal();
- private final Log log = LogFactory.getLog(BasicFrameworkAdapter.class);
+ private final Log log = LogFactory.getLog(BasicFrameworkAdapter.class);
- private final ServletContext servletContext;
- private final String conversationMessagerClass;
-
- public BasicFrameworkAdapter(ServletContext context, String conversationMessagerClass)
- {
- servletContext = context;
- this.conversationMessagerClass = conversationMessagerClass;
- }
-
- protected ConversationMessager createConversationMessager()
- {
- if (conversationMessagerClass == null)
- {
- return createDefaultConversationMessager();
- }
-
- // First try to find a bean of that name in the dependency-injection
- // framework.
- Object instance = getBean(conversationMessagerClass);
- if (instance instanceof ConversationMessager)
- {
- return (ConversationMessager) instance;
- }
-
- // Now resort to trying the value as a classname.
- return (ConversationMessager) _ClassUtils.newInstance(conversationMessagerClass);
- }
-
- protected ConversationMessager createDefaultConversationMessager()
- {
- return new LogConversationMessager();
- }
-
- private HttpServletRequest getRequest()
- {
- return (HttpServletRequest) httpServletRequest.get();
- }
-
- private HttpServletResponse getResponse()
- {
- return (HttpServletResponse) httpServletResponse.get();
- }
-
- public void beginRequest(ServletRequest req, ServletResponse rsp)
- {
- log.debug("Beginning request");
- if (req instanceof HttpServletRequest)
- {
- httpServletRequest.set(req);
- }
- if (rsp instanceof HttpServletResponse)
- {
- httpServletResponse.set(rsp);
- }
-
- FrameworkAdapter.setCurrentInstance(this);
- }
-
- public void endRequest()
- {
- log.debug("Ending request");
- FrameworkAdapter.setCurrentInstance(null);
- httpServletRequest.set(null);
- httpServletResponse.set(null);
- }
-
- public String getInitParameter(String key)
- {
- return servletContext.getInitParameter(key);
- }
-
- public Object getRequestParameterAttribute(String key)
- {
- HttpServletRequest request = getRequest();
- if (request != null)
- {
- return request.getParameter(key);
- }
-
- throw new IllegalStateException(ISE_MESSAGE);
- }
-
- public boolean containsRequestParameterAttribute(String key)
- {
- HttpServletRequest request = getRequest();
- if (request != null)
- {
- return request.getParameter(key) != null;
- }
-
- throw new IllegalStateException(ISE_MESSAGE);
- }
-
- public Object getRequestAttribute(String key)
- {
- HttpServletRequest request = getRequest();
- if (request != null)
- {
- return request.getAttribute(key);
- }
-
- throw new IllegalStateException(ISE_MESSAGE);
- }
-
- public void setRequestAttribute(String key, Object value)
- {
- HttpServletRequest request = getRequest();
- if (request != null)
- {
- request.setAttribute(key, value);
- return;
- }
-
- throw new IllegalStateException(ISE_MESSAGE);
- }
-
- public boolean containsRequestAttribute(String key)
- {
- HttpServletRequest request = getRequest();
- if (request != null)
- {
- return request.getAttribute(key) != null;
- }
-
- throw new IllegalStateException(ISE_MESSAGE);
- }
-
- public Object getSessionAttribute(String key)
- {
- HttpServletRequest request = getRequest();
- if (request != null && request.getSession(true) != null)
- {
- return request.getSession(true).getAttribute(key);
- }
-
- throw new IllegalStateException(ISE_MESSAGE);
- }
-
- public void setSessionAttribute(String key, Object value)
- {
- HttpServletRequest request = getRequest();
- if (request != null && request.getSession(true) != null)
- {
- request.getSession(true).setAttribute(key, value);
- return;
- }
-
- }
-
- public boolean containsSessionAttribute(String key)
- {
- HttpServletRequest request = getRequest();
- if (request != null && request.getSession(true) != null)
- {
- return request.getSession(true).getAttribute(key) != null;
- }
-
- throw new IllegalStateException(ISE_MESSAGE);
- }
-
- protected String getRequestContextPath()
- {
- HttpServletRequest request = getRequest();
- if (request != null)
- {
- return request.getContextPath();
- }
-
- throw new IllegalStateException(ISE_MESSAGE);
- }
-
- public void redirect(String url) throws IOException
- {
- StringBuffer redir = new StringBuffer();
- if (url.startsWith("/"))
- {
- redir.append(getRequestContextPath());
- }
- redir.append(url);
-
- HttpServletResponse rsp = getResponse();
- String dstUrl = rsp.encodeRedirectURL(redir.toString());
- rsp.sendRedirect(dstUrl);
- }
-
- /**
- * Look in the request and session scopes for an entry
- * with the specified name.
- * <p>
- * This basic adapter class does not support invoking the JSP expression
- * evaluator; no "variable resolver" will ever be used to look up the
- * specified name.
- * <p>
- * TODO: also look in the application scope.
- * <p>
- * TODO: investigate invoking the jsp.ExpressionFactory class to look up
- * the variable. Possibly that could be done in a different JspFrameworkAdapter
- * class.
- */
- public Object getBean(String name)
- {
- Object obj;
-
- obj = getRequestAttribute(name);
- if (obj != null) return obj;
-
- obj = getSessionAttribute(name);
- if (obj != null) return obj;
-
- // TODO: look up application-scoped objects.
-
- return null;
- }
-
- /**
- * Perform a redirect to the specified url.
- * <p>
- * A redirect is done rather than a forward so that the remote browser has its
- * current url updated appropriately. Note that a redirect does cause any
- * request-scoped variables to be discarded.
- */
- public void invokeNavigation(String navigationName) throws IOException
- {
- redirect(navigationName);
- }
-}
\ No newline at end of file
+ private final ServletContext servletContext;
+ private final String conversationMessagerClass;
+
+ public BasicFrameworkAdapter(ServletContext context, String conversationMessagerClass)
+ {
+ servletContext = context;
+ this.conversationMessagerClass = conversationMessagerClass;
+ }
+
+ protected ConversationMessager createConversationMessager()
+ {
+ if (conversationMessagerClass == null)
+ {
+ return createDefaultConversationMessager();
+ }
+
+ // First try to find a bean of that name in the dependency-injection
+ // framework.
+ Object instance = getBean(conversationMessagerClass);
+ if (instance instanceof ConversationMessager)
+ {
+ return (ConversationMessager) instance;
+ }
+
+ // Now resort to trying the value as a classname.
+ return (ConversationMessager) _ClassUtils.newInstance(conversationMessagerClass);
+ }
+
+ protected ConversationMessager createDefaultConversationMessager()
+ {
+ return new LogConversationMessager();
+ }
+
+ private HttpServletRequest getRequest()
+ {
+ return (HttpServletRequest) httpServletRequest.get();
+ }
+
+ private HttpServletResponse getResponse()
+ {
+ return (HttpServletResponse) httpServletResponse.get();
+ }
+
+ public void beginRequest(ServletRequest req, ServletResponse rsp)
+ {
+ log.debug("Beginning request");
+ if (req instanceof HttpServletRequest)
+ {
+ httpServletRequest.set(req);
+ }
+ if (rsp instanceof HttpServletResponse)
+ {
+ httpServletResponse.set(rsp);
+ }
+
+ FrameworkAdapter.setCurrentInstance(this);
+ }
+
+ public void endRequest()
+ {
+ log.debug("Ending request");
+ FrameworkAdapter.setCurrentInstance(null);
+ httpServletRequest.set(null);
+ httpServletResponse.set(null);
+ }
+
+ public String getInitParameter(String key)
+ {
+ return servletContext.getInitParameter(key);
+ }
+
+ public Object getRequestParameterAttribute(String key)
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null)
+ {
+ return request.getParameter(key);
+ }
+
+ throw new IllegalStateException(ISE_MESSAGE);
+ }
+
+ public boolean containsRequestParameterAttribute(String key)
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null)
+ {
+ return request.getParameter(key) != null;
+ }
+
+ throw new IllegalStateException(ISE_MESSAGE);
+ }
+
+ public Object getRequestAttribute(String key)
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null)
+ {
+ return request.getAttribute(key);
+ }
+
+ throw new IllegalStateException(ISE_MESSAGE);
+ }
+
+ public void setRequestAttribute(String key, Object value)
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null)
+ {
+ request.setAttribute(key, value);
+ return;
+ }
+
+ throw new IllegalStateException(ISE_MESSAGE);
+ }
+
+ public boolean containsRequestAttribute(String key)
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null)
+ {
+ return request.getAttribute(key) != null;
+ }
+
+ throw new IllegalStateException(ISE_MESSAGE);
+ }
+
+ public Object getSessionAttribute(String key)
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null && request.getSession(true) != null)
+ {
+ return request.getSession(true).getAttribute(key);
+ }
+
+ throw new IllegalStateException(ISE_MESSAGE);
+ }
+
+ public void setSessionAttribute(String key, Object value)
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null && request.getSession(true) != null)
+ {
+ request.getSession(true).setAttribute(key, value);
+ return;
+ }
+
+ }
+
+ public boolean containsSessionAttribute(String key)
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null && request.getSession(true) != null)
+ {
+ return request.getSession(true).getAttribute(key) != null;
+ }
+
+ throw new IllegalStateException(ISE_MESSAGE);
+ }
+
+ protected String getRequestContextPath()
+ {
+ HttpServletRequest request = getRequest();
+ if (request != null)
+ {
+ return request.getContextPath();
+ }
+
+ throw new IllegalStateException(ISE_MESSAGE);
+ }
+
+ public void redirect(String url) throws IOException
+ {
+ StringBuffer redir = new StringBuffer();
+ if (url.startsWith("/"))
+ {
+ redir.append(getRequestContextPath());
+ }
+ redir.append(url);
+
+ HttpServletResponse rsp = getResponse();
+ String dstUrl = rsp.encodeRedirectURL(redir.toString());
+ rsp.sendRedirect(dstUrl);
+ }
+
+ /**
+ * Look in the request and session scopes for an entry
+ * with the specified name.
+ * <p>
+ * This basic adapter class does not support invoking the JSP expression
+ * evaluator; no "variable resolver" will ever be used to look up the
+ * specified name.
+ * <p>
+ * TODO: also look in the application scope.
+ * <p>
+ * TODO: investigate invoking the jsp.ExpressionFactory class to look up
+ * the variable. Possibly that could be done in a different JspFrameworkAdapter
+ * class.
+ */
+ public Object getBean(String name)
+ {
+ Object obj;
+
+ obj = getRequestAttribute(name);
+ if (obj != null) return obj;
+
+ obj = getSessionAttribute(name);
+ if (obj != null) return obj;
+
+ // TODO: look up application-scoped objects.
+
+ return null;
+ }
+
+ /**
+ * Perform a redirect to the specified url.
+ * <p>
+ * A redirect is done rather than a forward so that the remote browser has its
+ * current url updated appropriately. Note that a redirect does cause any
+ * request-scoped variables to be discarded.
+ */
+ public void invokeNavigation(String navigationName) throws IOException
+ {
+ redirect(navigationName);
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/basic/BasicFrameworkAdapterFilter.java Fri Feb 22 07:57:09 2008
@@ -45,33 +45,33 @@
*/
public class BasicFrameworkAdapterFilter implements Filter
{
- private final static String INIT_CONVERSATION_MESSAGER = "conversationMessagerClass";
+ private final static String INIT_CONVERSATION_MESSAGER = "conversationMessagerClass";
- private final Log log = LogFactory.getLog(BasicFrameworkAdapterFilter.class);
- private BasicFrameworkAdapter adapter;
+ private final Log log = LogFactory.getLog(BasicFrameworkAdapterFilter.class);
+ private BasicFrameworkAdapter adapter;
- public void init(FilterConfig filterConfig) throws ServletException
- {
- String conversationMessager = filterConfig.getInitParameter(INIT_CONVERSATION_MESSAGER);
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ String conversationMessager = filterConfig.getInitParameter(INIT_CONVERSATION_MESSAGER);
- adapter = new BasicFrameworkAdapter(filterConfig.getServletContext(), conversationMessager);
- }
+ adapter = new BasicFrameworkAdapter(filterConfig.getServletContext(), conversationMessager);
+ }
- public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain filterChain) throws IOException, ServletException
- {
- log.debug("doFilter");
- try
- {
- adapter.beginRequest(req, rsp);
- filterChain.doFilter(req, rsp);
- }
- finally
- {
- adapter.endRequest();
- }
- }
+ public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain filterChain) throws IOException, ServletException
+ {
+ log.debug("doFilter");
+ try
+ {
+ adapter.beginRequest(req, rsp);
+ filterChain.doFilter(req, rsp);
+ }
+ finally
+ {
+ adapter.endRequest();
+ }
+ }
- public void destroy()
- {
- }
-}
\ No newline at end of file
+ public void destroy()
+ {
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapter.java Fri Feb 22 07:57:09 2008
@@ -37,148 +37,148 @@
*/
public class JsfFrameworkAdapter extends FrameworkAdapter
{
- private final Log log = LogFactory.getLog(JsfFrameworkAdapter.class);
+ private final Log log = LogFactory.getLog(JsfFrameworkAdapter.class);
- public JsfFrameworkAdapter(String conversationMessagerClass)
- {
- ConversationMessager cm = _FrameworkAdapterUtils.createConversationMessager(conversationMessagerClass,
- JsfConversationMessager.class);
- setConversationMessager(cm);
- }
-
- /**
- * This method should be invoked at the start of each JSF request cycle, before any Orchestra
- * functionality is invoked.
- *
- * @since 1.1
- */
- public void beginRequest()
- {
- log.debug("Beginning request");
- FrameworkAdapter.setCurrentInstance(this);
- }
-
- /**
- * This method should be invoked at the end of each JSF request cycle, after the last
- * Orchestra functionality is invoked.
- *
- * @since 1.1
- */
- public void endRequest()
- {
- log.debug("Ending request");
- FrameworkAdapter.setCurrentInstance(null);
- }
-
- protected ConversationMessager createDefaultConversationMessager()
- {
- return new JsfConversationMessager();
- }
-
- protected FacesContext getFacesContext()
- {
- FacesContext fc = FacesContext.getCurrentInstance();
- if (fc == null)
- {
- throw new OrchestraException("Missing FacesContext");
- }
- return fc;
- }
-
- public String getInitParameter(String key)
- {
- FacesContext context = getFacesContext();
-
- return context.getExternalContext().getInitParameter(key);
- }
-
- public Object getRequestParameterAttribute(String key)
- {
- FacesContext context = getFacesContext();
- return context.getExternalContext().getRequestParameterMap().get(key);
- }
-
- public boolean containsRequestParameterAttribute(String key)
- {
- FacesContext context = getFacesContext();
- return context.getExternalContext().getRequestParameterMap().containsKey(key);
- }
-
- public Object getRequestAttribute(String key)
- {
- FacesContext context = getFacesContext();
- return context.getExternalContext().getRequestMap().get(key);
- }
-
- public void setRequestAttribute(String key, Object value)
- {
- FacesContext context = getFacesContext();
- context.getExternalContext().getRequestMap().put(key, value);
- }
-
- public boolean containsRequestAttribute(String key)
- {
- FacesContext context = getFacesContext();
- return context.getExternalContext().getRequestMap().containsKey(key);
- }
-
- public Object getSessionAttribute(String key)
- {
- FacesContext context = getFacesContext();
- return context.getExternalContext().getSessionMap().get(key);
- }
-
- public void setSessionAttribute(String key, Object value)
- {
- FacesContext context = getFacesContext();
- context.getExternalContext().getSessionMap().put(key, value);
- }
-
- public boolean containsSessionAttribute(String key)
- {
- FacesContext context = getFacesContext();
- return context.getExternalContext().getSessionMap().containsKey(key);
- }
-
- protected String getRequestContextPath()
- {
- FacesContext context = getFacesContext();
- return context.getExternalContext().getRequestContextPath();
- }
-
- public void redirect(String url) throws IOException
- {
- StringBuffer redir = new StringBuffer();
- if (url.startsWith("/"))
- {
- redir.append(getRequestContextPath());
- }
- redir.append(url);
-
-
- FacesContext context = getFacesContext();
-
- String actionUrl = context.getExternalContext().encodeActionURL(redir.toString());
- context.getExternalContext().redirect(actionUrl);
- context.responseComplete();
- }
-
- public Object getBean(String name)
- {
- FacesContext context = getFacesContext();
- if (context == null)
- {
- throw new IllegalStateException("getBean invoked before FacesServlet");
- }
-
- return context.getApplication()
- .getVariableResolver().resolveVariable(context, name);
- }
-
- public void invokeNavigation(String navigationName)
- {
- FacesContext context = getFacesContext();
-
- context.getApplication().getNavigationHandler().handleNavigation(context, null, navigationName);
- }
-}
\ No newline at end of file
+ public JsfFrameworkAdapter(String conversationMessagerClass)
+ {
+ ConversationMessager cm = _FrameworkAdapterUtils.createConversationMessager(conversationMessagerClass,
+ JsfConversationMessager.class);
+ setConversationMessager(cm);
+ }
+
+ /**
+ * This method should be invoked at the start of each JSF request cycle, before any Orchestra
+ * functionality is invoked.
+ *
+ * @since 1.1
+ */
+ public void beginRequest()
+ {
+ log.debug("Beginning request");
+ FrameworkAdapter.setCurrentInstance(this);
+ }
+
+ /**
+ * This method should be invoked at the end of each JSF request cycle, after the last
+ * Orchestra functionality is invoked.
+ *
+ * @since 1.1
+ */
+ public void endRequest()
+ {
+ log.debug("Ending request");
+ FrameworkAdapter.setCurrentInstance(null);
+ }
+
+ protected ConversationMessager createDefaultConversationMessager()
+ {
+ return new JsfConversationMessager();
+ }
+
+ protected FacesContext getFacesContext()
+ {
+ FacesContext fc = FacesContext.getCurrentInstance();
+ if (fc == null)
+ {
+ throw new OrchestraException("Missing FacesContext");
+ }
+ return fc;
+ }
+
+ public String getInitParameter(String key)
+ {
+ FacesContext context = getFacesContext();
+
+ return context.getExternalContext().getInitParameter(key);
+ }
+
+ public Object getRequestParameterAttribute(String key)
+ {
+ FacesContext context = getFacesContext();
+ return context.getExternalContext().getRequestParameterMap().get(key);
+ }
+
+ public boolean containsRequestParameterAttribute(String key)
+ {
+ FacesContext context = getFacesContext();
+ return context.getExternalContext().getRequestParameterMap().containsKey(key);
+ }
+
+ public Object getRequestAttribute(String key)
+ {
+ FacesContext context = getFacesContext();
+ return context.getExternalContext().getRequestMap().get(key);
+ }
+
+ public void setRequestAttribute(String key, Object value)
+ {
+ FacesContext context = getFacesContext();
+ context.getExternalContext().getRequestMap().put(key, value);
+ }
+
+ public boolean containsRequestAttribute(String key)
+ {
+ FacesContext context = getFacesContext();
+ return context.getExternalContext().getRequestMap().containsKey(key);
+ }
+
+ public Object getSessionAttribute(String key)
+ {
+ FacesContext context = getFacesContext();
+ return context.getExternalContext().getSessionMap().get(key);
+ }
+
+ public void setSessionAttribute(String key, Object value)
+ {
+ FacesContext context = getFacesContext();
+ context.getExternalContext().getSessionMap().put(key, value);
+ }
+
+ public boolean containsSessionAttribute(String key)
+ {
+ FacesContext context = getFacesContext();
+ return context.getExternalContext().getSessionMap().containsKey(key);
+ }
+
+ protected String getRequestContextPath()
+ {
+ FacesContext context = getFacesContext();
+ return context.getExternalContext().getRequestContextPath();
+ }
+
+ public void redirect(String url) throws IOException
+ {
+ StringBuffer redir = new StringBuffer();
+ if (url.startsWith("/"))
+ {
+ redir.append(getRequestContextPath());
+ }
+ redir.append(url);
+
+
+ FacesContext context = getFacesContext();
+
+ String actionUrl = context.getExternalContext().encodeActionURL(redir.toString());
+ context.getExternalContext().redirect(actionUrl);
+ context.responseComplete();
+ }
+
+ public Object getBean(String name)
+ {
+ FacesContext context = getFacesContext();
+ if (context == null)
+ {
+ throw new IllegalStateException("getBean invoked before FacesServlet");
+ }
+
+ return context.getApplication()
+ .getVariableResolver().resolveVariable(context, name);
+ }
+
+ public void invokeNavigation(String navigationName)
+ {
+ FacesContext context = getFacesContext();
+
+ context.getApplication().getNavigationHandler().handleNavigation(context, null, navigationName);
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapterFilter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapterFilter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapterFilter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/jsf/JsfFrameworkAdapterFilter.java Fri Feb 22 07:57:09 2008
@@ -53,33 +53,33 @@
*/
public class JsfFrameworkAdapterFilter implements Filter
{
- private final static String INIT_CONVERSATION_MESSAGER = "conversationMessagerClass";
+ private final static String INIT_CONVERSATION_MESSAGER = "conversationMessagerClass";
- private final Log log = LogFactory.getLog(JsfFrameworkAdapterFilter.class);
- private JsfFrameworkAdapter adapter;
+ private final Log log = LogFactory.getLog(JsfFrameworkAdapterFilter.class);
+ private JsfFrameworkAdapter adapter;
- public void init(FilterConfig filterConfig) throws ServletException
- {
- String conversationMessager = filterConfig.getInitParameter(INIT_CONVERSATION_MESSAGER);
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ String conversationMessager = filterConfig.getInitParameter(INIT_CONVERSATION_MESSAGER);
- adapter = new JsfFrameworkAdapter(conversationMessager);
- }
+ adapter = new JsfFrameworkAdapter(conversationMessager);
+ }
- public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain filterChain) throws IOException, ServletException
- {
- log.debug("doFilter");
- try
- {
- adapter.beginRequest();
- filterChain.doFilter(req, rsp);
- }
- finally
- {
- adapter.endRequest();
- }
- }
+ public void doFilter(ServletRequest req, ServletResponse rsp, FilterChain filterChain) throws IOException, ServletException
+ {
+ log.debug("doFilter");
+ try
+ {
+ adapter.beginRequest();
+ filterChain.doFilter(req, rsp);
+ }
+ finally
+ {
+ adapter.endRequest();
+ }
+ }
- public void destroy()
- {
- }
-}
\ No newline at end of file
+ public void destroy()
+ {
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/local/LocalFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/local/LocalFrameworkAdapter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/local/LocalFrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/local/LocalFrameworkAdapter.java Fri Feb 22 07:57:09 2008
@@ -60,72 +60,72 @@
*/
public class LocalFrameworkAdapter extends FrameworkAdapter implements ApplicationContextAware
{
- private ConfigurableApplicationContext configurableApplicationContext;
+ private ConfigurableApplicationContext configurableApplicationContext;
- private final Map sessionMap = new HashMap();
- private final Map requestMap = new HashMap();
- private final Map requestParameterMap = new HashMap();
- private final Map initMap = new HashMap();
-
- public String getInitParameter(String key)
- {
- return (String) initMap.get(key);
- }
-
- public Object getRequestParameterAttribute(String key)
- {
- return requestParameterMap.get(key);
- }
-
- public boolean containsRequestParameterAttribute(String key)
- {
- return requestParameterMap.containsKey(key);
- }
-
- public void setRequestParameterAttribute(String key , Object value)
- {
- requestParameterMap.put(key, value);
- }
-
- public Object getRequestAttribute(String key)
- {
- return requestMap.get(key);
- }
-
- public void setRequestAttribute(String key, Object value)
- {
- requestMap.put(key, value);
- }
-
- public void clearRequestMap()
- {
- requestMap.clear();
- }
-
- public boolean containsRequestAttribute(String key)
- {
- return requestMap.containsKey(key);
- }
-
- public Object getSessionAttribute(String key)
- {
- return sessionMap.get(key);
- }
-
- public void setSessionAttribute(String key, Object value)
- {
- sessionMap.put(key, value);
- }
-
- public boolean containsSessionAttribute(String key)
- {
- return sessionMap.containsKey(key);
- }
-
- protected ConfigurableApplicationContext getApplicationContext()
- {
- return configurableApplicationContext;
- }
+ private final Map sessionMap = new HashMap();
+ private final Map requestMap = new HashMap();
+ private final Map requestParameterMap = new HashMap();
+ private final Map initMap = new HashMap();
+
+ public String getInitParameter(String key)
+ {
+ return (String) initMap.get(key);
+ }
+
+ public Object getRequestParameterAttribute(String key)
+ {
+ return requestParameterMap.get(key);
+ }
+
+ public boolean containsRequestParameterAttribute(String key)
+ {
+ return requestParameterMap.containsKey(key);
+ }
+
+ public void setRequestParameterAttribute(String key , Object value)
+ {
+ requestParameterMap.put(key, value);
+ }
+
+ public Object getRequestAttribute(String key)
+ {
+ return requestMap.get(key);
+ }
+
+ public void setRequestAttribute(String key, Object value)
+ {
+ requestMap.put(key, value);
+ }
+
+ public void clearRequestMap()
+ {
+ requestMap.clear();
+ }
+
+ public boolean containsRequestAttribute(String key)
+ {
+ return requestMap.containsKey(key);
+ }
+
+ public Object getSessionAttribute(String key)
+ {
+ return sessionMap.get(key);
+ }
+
+ public void setSessionAttribute(String key, Object value)
+ {
+ sessionMap.put(key, value);
+ }
+
+ public boolean containsSessionAttribute(String key)
+ {
+ return sessionMap.containsKey(key);
+ }
+
+ protected ConfigurableApplicationContext getApplicationContext()
+ {
+ return configurableApplicationContext;
+ }
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
@@ -133,24 +133,24 @@
}
public void setApplicationContext(ConfigurableApplicationContext configurableApplicationContext)
- {
- this.configurableApplicationContext = configurableApplicationContext;
- }
-
- public void redirect(String url) throws IOException
- {
- }
-
- public Object getBean(String name)
- {
- if (!getApplicationContext().containsBean(name))
- {
- return null;
- }
- return getApplicationContext().getBean(name);
- }
-
- public void invokeNavigation(String navigationName)
- {
- }
-}
\ No newline at end of file
+ {
+ this.configurableApplicationContext = configurableApplicationContext;
+ }
+
+ public void redirect(String url) throws IOException
+ {
+ }
+
+ public Object getBean(String name)
+ {
+ if (!getApplicationContext().containsBean(name))
+ {
+ return null;
+ }
+ return getApplicationContext().getBean(name);
+ }
+
+ public void invokeNavigation(String navigationName)
+ {
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/CompoundFilter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/CompoundFilter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/CompoundFilter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/CompoundFilter.java Fri Feb 22 07:57:09 2008
@@ -33,38 +33,39 @@
*/
public abstract class CompoundFilter implements Filter
{
- private final Filter filter1;
- private final Filter filter2;
+ private final Filter filter1;
+ private final Filter filter2;
- public CompoundFilter(Filter filter1, Filter filter2)
- {
- this.filter1 = filter1;
- this.filter2 = filter2;
- }
+ public CompoundFilter(Filter filter1, Filter filter2)
+ {
+ this.filter1 = filter1;
+ this.filter2 = filter2;
+ }
- public void init(FilterConfig filterConfig) throws ServletException
- {
- filter1.init(filterConfig);
- filter2.init(filterConfig);
- }
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ filter1.init(filterConfig);
+ filter2.init(filterConfig);
+ }
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException
- {
- FilterChain chain = new FilterChain()
- {
- public void doFilter(ServletRequest req, ServletResponse rsp) throws IOException, ServletException
- {
- filter2.doFilter(req, rsp, filterChain);
- }
-
- };
-
- filter1.doFilter(servletRequest, servletResponse, chain);
- }
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
+ final FilterChain filterChain) throws IOException, ServletException
+ {
+ FilterChain chain = new FilterChain()
+ {
+ public void doFilter(ServletRequest req, ServletResponse rsp) throws IOException, ServletException
+ {
+ filter2.doFilter(req, rsp, filterChain);
+ }
+
+ };
+
+ filter1.doFilter(servletRequest, servletResponse, chain);
+ }
- public void destroy()
- {
- filter2.destroy();
- filter1.destroy();
- }
-}
\ No newline at end of file
+ public void destroy()
+ {
+ filter2.destroy();
+ filter1.destroy();
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/OrchestraException.java Fri Feb 22 07:57:09 2008
@@ -23,24 +23,24 @@
*/
public class OrchestraException extends RuntimeException
{
- private static final long serialVersionUID = -282458546217595126L;
+ private static final long serialVersionUID = -282458546217595126L;
- public OrchestraException()
- {
- }
+ public OrchestraException()
+ {
+ }
- public OrchestraException(String message)
- {
- super(message);
- }
+ public OrchestraException(String message)
+ {
+ super(message);
+ }
- public OrchestraException(String message, Throwable cause)
- {
- super(message, cause);
- }
+ public OrchestraException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
- public OrchestraException(Throwable cause)
- {
- super(cause);
- }
+ public OrchestraException(Throwable cause)
+ {
+ super(cause);
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ClassUtils.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ClassUtils.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ClassUtils.java Fri Feb 22 07:57:09 2008
@@ -28,87 +28,87 @@
*/
public final class _ClassUtils
{
- private _ClassUtils()
- {
- }
+ private _ClassUtils()
+ {
+ }
- /**
- * Create a new instance for a class by its name
- *
- * @since 1.1
- */
- public static Object newInstance(Class clazz)
- {
- try
- {
- return clazz.newInstance();
- }
- catch(NoClassDefFoundError e)
- {
- throw new OrchestraException(e);
- }
- catch (InstantiationException e)
- {
- throw new OrchestraException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new OrchestraException(e);
- }
- }
+ /**
+ * Create a new instance for a class by its name
+ *
+ * @since 1.1
+ */
+ public static Object newInstance(Class clazz)
+ {
+ try
+ {
+ return clazz.newInstance();
+ }
+ catch(NoClassDefFoundError e)
+ {
+ throw new OrchestraException(e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new OrchestraException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new OrchestraException(e);
+ }
+ }
- /**
- * create a new instance for a class by its name
- */
- public static Object newInstance(String className)
- {
- try
- {
- Class clazz = classForName(className);
- return clazz.newInstance();
- }
- catch(NoClassDefFoundError e)
- {
- throw new OrchestraException(e);
- }
- catch (InstantiationException e)
- {
- throw new OrchestraException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new OrchestraException(e);
- }
- catch (ClassNotFoundException e)
- {
- throw new OrchestraException(e);
- }
- }
+ /**
+ * create a new instance for a class by its name
+ */
+ public static Object newInstance(String className)
+ {
+ try
+ {
+ Class clazz = classForName(className);
+ return clazz.newInstance();
+ }
+ catch(NoClassDefFoundError e)
+ {
+ throw new OrchestraException(e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new OrchestraException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new OrchestraException(e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new OrchestraException(e);
+ }
+ }
- /**
- * Lookup class using the webapp classloader first and the the classloader which loaded
- * this class.
- */
- public static Class classForName(String className) throws ClassNotFoundException
- {
- if (className == null)
- {
- throw new NullPointerException("className");
- }
+ /**
+ * Lookup class using the webapp classloader first and the the classloader which loaded
+ * this class.
+ */
+ public static Class classForName(String className) throws ClassNotFoundException
+ {
+ if (className == null)
+ {
+ throw new NullPointerException("className");
+ }
- try
- {
- // Try WebApp ClassLoader first
- return Class.forName(className,
- false, // do not initialize for faster startup
- Thread.currentThread().getContextClassLoader());
- }
- catch (ClassNotFoundException ignore)
- {
- // fallback: Try ClassLoader for this class (i.e. the myfaces.jar lib)
- return Class.forName(className,
- false, // do not initialize for faster startup
- _ClassUtils.class.getClassLoader());
- }
- }
+ try
+ {
+ // Try WebApp ClassLoader first
+ return Class.forName(className,
+ false, // do not initialize for faster startup
+ Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException ignore)
+ {
+ // fallback: Try ClassLoader for this class (i.e. the myfaces.jar lib)
+ return Class.forName(className,
+ false, // do not initialize for faster startup
+ _ClassUtils.class.getClassLoader());
+ }
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_NullFilter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_NullFilter.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_NullFilter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_NullFilter.java Fri Feb 22 07:57:09 2008
@@ -35,16 +35,17 @@
*/
public final class _NullFilter implements Filter
{
- public void init(FilterConfig filterConfig) throws ServletException
- {
- }
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ }
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException
- {
- filterChain.doFilter(servletRequest, servletResponse);
- }
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
+ final FilterChain filterChain) throws IOException, ServletException
+ {
+ filterChain.doFilter(servletRequest, servletResponse);
+ }
- public void destroy()
- {
- }
-}
\ No newline at end of file
+ public void destroy()
+ {
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ReentrantLock.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ReentrantLock.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ReentrantLock.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/_ReentrantLock.java Fri Feb 22 07:57:09 2008
@@ -43,61 +43,61 @@
public void lockInterruptibly() throws InterruptedException
{
- Thread caller = Thread.currentThread();
- for(;;)
- {
- synchronized(this)
- {
- if (lockedBy == null)
- {
- lockedBy = caller;
- lockCount = 1;
- return;
- }
-
- if (lockedBy == caller)
- {
- ++lockCount;
- return;
- }
-
- try
- {
- this.wait();
- }
- catch(InterruptedException e)
- {
- throw e;
- }
- }
- }
+ Thread caller = Thread.currentThread();
+ for(;;)
+ {
+ synchronized(this)
+ {
+ if (lockedBy == null)
+ {
+ lockedBy = caller;
+ lockCount = 1;
+ return;
+ }
+
+ if (lockedBy == caller)
+ {
+ ++lockCount;
+ return;
+ }
+
+ try
+ {
+ this.wait();
+ }
+ catch(InterruptedException e)
+ {
+ throw e;
+ }
+ }
+ }
}
public void unlock()
{
- Thread caller = Thread.currentThread();
- synchronized(this)
- {
- if (lockedBy != caller)
- {
- throw new IllegalStateException("Unlock on lock not owned by caller");
- }
-
- --lockCount;
- if (lockCount == 0)
- {
- lockedBy = null;
- this.notifyAll();
- }
- }
+ Thread caller = Thread.currentThread();
+ synchronized(this)
+ {
+ if (lockedBy != caller)
+ {
+ throw new IllegalStateException("Unlock on lock not owned by caller");
+ }
+
+ --lockCount;
+ if (lockCount == 0)
+ {
+ lockedBy = null;
+ this.notifyAll();
+ }
+ }
}
public boolean isHeldByCurrentThread()
{
- Thread caller = Thread.currentThread();
- synchronized(this)
- {
- return lockedBy == caller;
- }
+ Thread caller = Thread.currentThread();
+ synchronized(this)
+ {
+ return lockedBy == caller;
+ }
}
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConfigUtils.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConfigUtils.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConfigUtils.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConfigUtils.java Fri Feb 22 07:57:09 2008
@@ -30,29 +30,31 @@
*/
public abstract class ConfigUtils
{
- private static final String RH_KEY = ConfigUtils.class.getName() + ".RH";
+ private static final String RH_KEY = ConfigUtils.class.getName() + ".RH";
- static List getRequestHandlers(Map reqScope) {
- List rhl = (List) reqScope.get(RH_KEY);
- if (rhl != null)
- return rhl;
- else
- return Collections.EMPTY_LIST;
- }
+ static List getRequestHandlers(Map reqScope)
+ {
+ List rhl = (List) reqScope.get(RH_KEY);
+ if (rhl != null)
+ return rhl;
+ else
+ return Collections.EMPTY_LIST;
+ }
- /**
- * Can be called from a Filter or similar class in order to registed a
- * handler that should be run at the start of each request just
- * <i>after</i> the FacesContext object has been created, and at the end
- * of each request just <i>before</i> the FacesContext is released.
- */
- public static void registerRequestHandler(Map reqScope, RequestHandler rh) {
- List rhl = (List) reqScope.get(RH_KEY);
- if (rhl == null)
- {
- rhl = new ArrayList(1);
- reqScope.put(RH_KEY, rhl);
- }
- rhl.add(rh);
- }
+ /**
+ * Can be called from a Filter or similar class in order to registed a
+ * handler that should be run at the start of each request just
+ * <i>after</i> the FacesContext object has been created, and at the end
+ * of each request just <i>before</i> the FacesContext is released.
+ */
+ public static void registerRequestHandler(Map reqScope, RequestHandler rh)
+ {
+ List rhl = (List) reqScope.get(RH_KEY);
+ if (rhl == null)
+ {
+ rhl = new ArrayList(1);
+ reqScope.put(RH_KEY, rhl);
+ }
+ rhl.add(rh);
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ContextLockRequestHandler.java Fri Feb 22 07:57:09 2008
@@ -36,58 +36,58 @@
*/
class ContextLockRequestHandler implements RequestHandler
{
- ConversationContext context;
+ ConversationContext context;
- public void init(FacesContext facesContext) throws FacesException
- {
- if (getSerializeRequests(facesContext))
- {
- // Note that ConversationManager.getInstance requires the FrameworkAdapter
- // to be initialised...
- //
- // ?? Why is false passed here ??
- ConversationManager manager = ConversationManager.getInstance(false);
- if (manager != null)
- {
- context = manager.getCurrentConversationContext();
- if (context != null)
- {
- try
- {
- context.lockInterruptablyForCurrentThread();
- }
- catch(InterruptedException e)
- {
- throw new FacesException(e);
- }
- }
- }
- }
- }
+ public void init(FacesContext facesContext) throws FacesException
+ {
+ if (getSerializeRequests(facesContext))
+ {
+ // Note that ConversationManager.getInstance requires the FrameworkAdapter
+ // to be initialised...
+ //
+ // ?? Why is false passed here ??
+ ConversationManager manager = ConversationManager.getInstance(false);
+ if (manager != null)
+ {
+ context = manager.getCurrentConversationContext();
+ if (context != null)
+ {
+ try
+ {
+ context.lockInterruptablyForCurrentThread();
+ }
+ catch(InterruptedException e)
+ {
+ throw new FacesException(e);
+ }
+ }
+ }
+ }
+ }
- public void deinit() throws FacesException
- {
- if (context != null)
- {
- context.unlockForCurrentThread();
- }
- }
-
- private boolean getSerializeRequests(FacesContext facesContext)
- {
- ExternalContext ec = facesContext.getExternalContext();
+ public void deinit() throws FacesException
+ {
+ if (context != null)
+ {
+ context.unlockForCurrentThread();
+ }
+ }
+
+ private boolean getSerializeRequests(FacesContext facesContext)
+ {
+ ExternalContext ec = facesContext.getExternalContext();
- // Check for deprecated setting via the OrchestraServletFilter.
- Map reqScope = ec.getRequestMap();
- Boolean serializeRequests = (Boolean) reqScope.get(CoreConfig.SERIALIZE_REQUESTS);
- if (serializeRequests != null)
- {
- return serializeRequests.booleanValue();
- }
+ // Check for deprecated setting via the OrchestraServletFilter.
+ Map reqScope = ec.getRequestMap();
+ Boolean serializeRequests = (Boolean) reqScope.get(CoreConfig.SERIALIZE_REQUESTS);
+ if (serializeRequests != null)
+ {
+ return serializeRequests.booleanValue();
+ }
- // Check for the normal global init param; true unless "false" is specified
- String value = ec.getInitParameter(CoreConfig.SERIALIZE_REQUESTS);
- return !"false".equals(value); // NON-NLS
- }
+ // Check for the normal global init param; true unless "false" is specified
+ String value = ec.getInitParameter(CoreConfig.SERIALIZE_REQUESTS);
+ return !"false".equals(value); // NON-NLS
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConversationManagerRequestHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConversationManagerRequestHandler.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConversationManagerRequestHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConversationManagerRequestHandler.java Fri Feb 22 07:57:09 2008
@@ -31,13 +31,13 @@
*/
class ConversationManagerRequestHandler implements RequestHandler
{
- public void init(FacesContext facesContext) throws FacesException
- {
- ConversationManager.getInstance();
- }
+ public void init(FacesContext facesContext) throws FacesException
+ {
+ ConversationManager.getInstance();
+ }
- public void deinit() throws FacesException
- {
- }
+ public void deinit() throws FacesException
+ {
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/DataSourceLeakRequestHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/DataSourceLeakRequestHandler.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/DataSourceLeakRequestHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/DataSourceLeakRequestHandler.java Fri Feb 22 07:57:09 2008
@@ -32,21 +32,21 @@
*/
class DataSourceLeakRequestHandler implements RequestHandler
{
- boolean enabled;
+ boolean enabled;
- public void init(FacesContext facesContext) throws FacesException
- {
- // Check for the normal global init param; true unless "false" is specified
- String value = facesContext.getExternalContext().getInitParameter(CoreConfig.SERIALIZE_REQUESTS);
- enabled = !"false".equals(value);
- }
+ public void init(FacesContext facesContext) throws FacesException
+ {
+ // Check for the normal global init param; true unless "false" is specified
+ String value = facesContext.getExternalContext().getInitParameter(CoreConfig.SERIALIZE_REQUESTS);
+ enabled = !"false".equals(value);
+ }
- public void deinit() throws FacesException
- {
- if (enabled)
- {
- ConnectionManagerDataSource.releaseAllBorrowedConnections();
- }
- }
+ public void deinit() throws FacesException
+ {
+ if (enabled)
+ {
+ ConnectionManagerDataSource.releaseAllBorrowedConnections();
+ }
+ }
}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FacesContextWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FacesContextWrapper.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FacesContextWrapper.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FacesContextWrapper.java Fri Feb 22 07:57:09 2008
@@ -73,12 +73,12 @@
*/
public FacesContextWrapper(FacesContext facesContext, boolean install)
{
- _facesContext = facesContext;
-
- if (install)
- {
- FacesContext.setCurrentInstance(this);
- }
+ _facesContext = facesContext;
+
+ if (install)
+ {
+ FacesContext.setCurrentInstance(this);
+ }
}
//~ Non-Final Methods -----------------------------------------------------
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FrameworkAdapterRequestHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FrameworkAdapterRequestHandler.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FrameworkAdapterRequestHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/FrameworkAdapterRequestHandler.java Fri Feb 22 07:57:09 2008
@@ -35,45 +35,45 @@
*/
class FrameworkAdapterRequestHandler implements RequestHandler
{
- private final static String CONVERSATION_MESSAGER_CLASS = "org.apache.myfaces.orchestra.CONVERSATION_MESSAGER"; // NON-NLS
+ private final static String CONVERSATION_MESSAGER_CLASS = "org.apache.myfaces.orchestra.CONVERSATION_MESSAGER"; // NON-NLS
- private final Log log = LogFactory.getLog(FrameworkAdapterRequestHandler.class);
+ private final Log log = LogFactory.getLog(FrameworkAdapterRequestHandler.class);
- private JsfFrameworkAdapter adapter;
+ private JsfFrameworkAdapter adapter;
- public void init(FacesContext facesContext) throws FacesException
- {
- log.debug("init");
-
- if (FrameworkAdapter.getCurrentInstance() == null)
- {
- log.debug("creating jsfFrameworkAdapter");
- // No filter has yet initialised the adapter, so do it here.
- String conversationMessagerClass = getConversationMessagerClass(facesContext);
- adapter = new JsfFrameworkAdapter(conversationMessagerClass);
- adapter.beginRequest();
- }
- }
-
- public void deinit() throws FacesException
- {
- if (adapter != null)
- {
- adapter.endRequest();
- }
- }
-
- private static String getConversationMessagerClass(FacesContext facesContext)
- {
- ExternalContext ec = facesContext.getExternalContext();
-
- String cn = ec.getInitParameter(CONVERSATION_MESSAGER_CLASS);
- if (cn != null)
- {
- return cn;
- }
-
- cn = ec.getInitParameter(CoreConfig.CONVERSATION_MESSAGER);
- return cn;
- }
-}
\ No newline at end of file
+ public void init(FacesContext facesContext) throws FacesException
+ {
+ log.debug("init");
+
+ if (FrameworkAdapter.getCurrentInstance() == null)
+ {
+ log.debug("creating jsfFrameworkAdapter");
+ // No filter has yet initialised the adapter, so do it here.
+ String conversationMessagerClass = getConversationMessagerClass(facesContext);
+ adapter = new JsfFrameworkAdapter(conversationMessagerClass);
+ adapter.beginRequest();
+ }
+ }
+
+ public void deinit() throws FacesException
+ {
+ if (adapter != null)
+ {
+ adapter.endRequest();
+ }
+ }
+
+ private static String getConversationMessagerClass(FacesContext facesContext)
+ {
+ ExternalContext ec = facesContext.getExternalContext();
+
+ String cn = ec.getInitParameter(CONVERSATION_MESSAGER_CLASS);
+ if (cn != null)
+ {
+ return cn;
+ }
+
+ cn = ec.getInitParameter(CoreConfig.CONVERSATION_MESSAGER);
+ return cn;
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraFacesContextFactory.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraFacesContextFactory.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraFacesContextFactory.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraFacesContextFactory.java Fri Feb 22 07:57:09 2008
@@ -51,106 +51,106 @@
*/
public class OrchestraFacesContextFactory extends FacesContextFactory
{
- private final Log log = LogFactory.getLog(OrchestraFacesContextFactory.class);
- private final FacesContextFactory original;
+ private final Log log = LogFactory.getLog(OrchestraFacesContextFactory.class);
+ private final FacesContextFactory original;
- public OrchestraFacesContextFactory(FacesContextFactory original)
- {
- this.original = original;
- }
-
- public FacesContext getFacesContext(
- final Object context,
- final Object request,
- final Object response,
- final Lifecycle lifecycle) throws FacesException
- {
- log.debug("getFacesContext: entry");
- final FacesContext facesContext = original.getFacesContext(context, request, response, lifecycle);
- if (facesContext == null)
- {
- // should not happen
- return null;
- }
-
- // The handlers need to be reset on every request, as each request has a different
- // url which could potentially affect the list of handlers for that request.
- final LinkedList handlers = new LinkedList();
- handlers.add(new ContextLockRequestHandler());
- handlers.add(new FrameworkAdapterRequestHandler());
- handlers.add(new ConversationManagerRequestHandler());
- handlers.add(new DataSourceLeakRequestHandler());
-
- // Add any other handlers registered by filters or similar
- Map reqScope = facesContext.getExternalContext().getRequestMap();
- handlers.addAll(ConfigUtils.getRequestHandlers(reqScope));
-
- // Create and return the custom instance. Note that install=false
- // is specified for the FacesContextWrapper constructor, meaning
- // that the wrapper does not bind itself to the current thread:
- // the original object will still be the one that is returned
- // by FacesContext.getCurrentInstance(), not this wrapper. What
- // is important here is that the FacesServlet calls the release
- // method on this particular object, and that will happen because
- // FacesServlet uses the return value from this method as the object
- // to call release on, even though it is not the "current instance".
- // Not making the wrapper the current instance saves a little bit
- // of performance..
- log.debug("getFacesContext: creating custom instance");
- return new FacesContextWrapper(facesContext, false)
- {
- // Constructor...
- {
- log.debug("getFacesContext: running inner constructor");
- ListIterator i = handlers.listIterator();
- try
- {
- while(i.hasNext())
- {
- RequestHandler h = (RequestHandler) i.next();
-
- if (log.isDebugEnabled())
- {
- log.debug("Running inithandler of type " + i.getClass().getName());
- }
-
- h.init(facesContext);
- }
- }
- catch(RuntimeException e)
- {
- _release(i);
- throw e;
- }
- }
-
- public void release()
- {
- log.debug("Running release");
- super.release();
- ListIterator i = handlers.listIterator();
- // ecch, wind forward to end of list.
- while (i.hasNext()) i.next();
- _release(i);
- }
-
- private void _release(ListIterator i)
- {
- while (i.hasPrevious())
- {
- try
- {
- RequestHandler h = (RequestHandler) i.previous();
- h.deinit();
- }
- catch(Exception e)
- {
- // ignore errors, so we always deinitialise anything
- // that we initialised.
- log.error("Problem deinitialising RequestHandler", e);
- }
- }
- }
- };
- }
-}
\ No newline at end of file
+ public OrchestraFacesContextFactory(FacesContextFactory original)
+ {
+ this.original = original;
+ }
+
+ public FacesContext getFacesContext(
+ final Object context,
+ final Object request,
+ final Object response,
+ final Lifecycle lifecycle) throws FacesException
+ {
+ log.debug("getFacesContext: entry");
+ final FacesContext facesContext = original.getFacesContext(context, request, response, lifecycle);
+ if (facesContext == null)
+ {
+ // should not happen
+ return null;
+ }
+
+ // The handlers need to be reset on every request, as each request has a different
+ // url which could potentially affect the list of handlers for that request.
+ final LinkedList handlers = new LinkedList();
+ handlers.add(new ContextLockRequestHandler());
+ handlers.add(new FrameworkAdapterRequestHandler());
+ handlers.add(new ConversationManagerRequestHandler());
+ handlers.add(new DataSourceLeakRequestHandler());
+
+ // Add any other handlers registered by filters or similar
+ Map reqScope = facesContext.getExternalContext().getRequestMap();
+ handlers.addAll(ConfigUtils.getRequestHandlers(reqScope));
+
+ // Create and return the custom instance. Note that install=false
+ // is specified for the FacesContextWrapper constructor, meaning
+ // that the wrapper does not bind itself to the current thread:
+ // the original object will still be the one that is returned
+ // by FacesContext.getCurrentInstance(), not this wrapper. What
+ // is important here is that the FacesServlet calls the release
+ // method on this particular object, and that will happen because
+ // FacesServlet uses the return value from this method as the object
+ // to call release on, even though it is not the "current instance".
+ // Not making the wrapper the current instance saves a little bit
+ // of performance..
+ log.debug("getFacesContext: creating custom instance");
+ return new FacesContextWrapper(facesContext, false)
+ {
+ // Constructor...
+ {
+ log.debug("getFacesContext: running inner constructor");
+ ListIterator i = handlers.listIterator();
+ try
+ {
+ while(i.hasNext())
+ {
+ RequestHandler h = (RequestHandler) i.next();
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Running inithandler of type " + i.getClass().getName());
+ }
+
+ h.init(facesContext);
+ }
+ }
+ catch(RuntimeException e)
+ {
+ _release(i);
+ throw e;
+ }
+ }
+
+ public void release()
+ {
+ log.debug("Running release");
+ super.release();
+ ListIterator i = handlers.listIterator();
+ // ecch, wind forward to end of list.
+ while (i.hasNext()) i.next();
+ _release(i);
+ }
+
+ private void _release(ListIterator i)
+ {
+ while (i.hasPrevious())
+ {
+ try
+ {
+ RequestHandler h = (RequestHandler) i.previous();
+ h.deinit();
+ }
+ catch(Exception e)
+ {
+ // ignore errors, so we always deinitialise anything
+ // that we initialised.
+ log.error("Problem deinitialising RequestHandler", e);
+ }
+ }
+ }
+ };
+ }
+}
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/RequestHandler.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/RequestHandler.java?rev=630232&r1=630231&r2=630232&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/RequestHandler.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/RequestHandler.java Fri Feb 22 07:57:09 2008
@@ -29,6 +29,6 @@
*/
public interface RequestHandler
{
- void init(FacesContext facesContext) throws FacesException;
- void deinit() throws FacesException;
+ void init(FacesContext facesContext) throws FacesException;
+ void deinit() throws FacesException;
}