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/08 11:53:48 UTC
svn commit: r619830 - in
/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra:
./ filter/ lib/jsf/
Author: skitching
Date: Fri Feb 8 02:53:45 2008
New Revision: 619830
URL: http://svn.apache.org/viewvc?rev=619830&view=rev
Log:
Allow new FacesContextFactory-based request handling to be configurable again.
All this should now be backwards-compatible with the old code.
Added:
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConfigUtils.java
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/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
Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java?rev=619830&view=auto
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/CoreConfig.java Fri Feb 8 02:53:45 2008
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.orchestra;
+
+/**
+ * A place to define all the configuration constants that can be used to
+ * configure parts of Orchestra core.
+ */
+public final class CoreConfig
+{
+ private static final String BASE = CoreConfig.class.getName();
+
+ /**
+ * Controls whether two threads are prevented from accessing the same
+ * ConversationContext concurrently, or not. This is generally a bad idea as it
+ * can lead to ugly race conditions, so it is TRUE by default.
+ * <p>
+ * It is possible for multiple requests associated with the same http session to be
+ * received concurrently. By default, a servlet engine simply processes all requests
+ * concurrently in different threads. However that can cause all sorts of unexpected
+ * problems with objects in scopes that are visible to both threads (session-scoped
+ * and conversation-scoped objects).
+ * <p>
+ * When enabled, this option will block the thread for any request which will
+ * access the same Orchestra ConversationContext as a thread that is already
+ * running, and release it only when the earlier request has completed. This protects
+ * all orchestra conversation-scoped objects from concurrent access, but
+ * <i>does not</i> protect any session-scoped objects.
+ * <p>
+ * When using Orchestra, it is recommended that session-scoped objects are avoided
+ * conversation-scoped beans used instead. If there is no session-scoped data in
+ * use by an application then it is safe to allow concurrent requests to the
+ * same http session. If you do wish to protect normal session-scoped objects as
+ * well, then the standard solution is to write a filter that uses standard java
+ * synchronisation on a session-scoped object, taking the lock on request entry
+ * and releasing it on request exit.
+ * <p>
+ * Note that the expression "serialize requests" as used here means requests are
+ * processed serially, ie one after the other rather than concurrently. This has
+ * nothing to do with java.io.Serializable.
+ */
+ public static final String SERIALIZE_REQUESTS = BASE + ":SERIALIZE_REQUESTS";
+
+ /**
+ * Controls whether Orchestra should monitor the set of JDBC connections borrowed
+ * during a request, and clean up any that are still open at the end of the request.
+ * <p>
+ * Orchestra provides a special DataSource wrapper that can be configured for any
+ * datasource used by the application. The datasource simply wraps all real Connection
+ * objects it returns in a proxy, and keeps track of them. At the end of each request,
+ * any connections borrowed by this thread but not returned can be returned
+ * automatically. See ConnectionManagerDataSource for more details.
+ * <p>
+ * If this special DataSource is not configured, then checking for unreleased
+ * connections is harmless, and always finds nothing. Therefore this option is
+ * enabled by default.
+ */
+ public static final String CLEANUP_CONNECTIONS = BASE + ":CLEANUP_CONNECTIONS";
+
+ /**
+ * Controls what class is used to present Orchestra-related error messages to
+ * the user. When not specified, the default implementation for the current
+ * FrameworkAdapter (eg JsfFrameworkAdapter) is used.
+ * <p>
+ * See class ConversationMessager for further details.
+ */
+ public static final String CONVERSATION_MESSAGER = BASE + ":CONVERSATION_MESSAGER";
+}
\ No newline at end of file
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=619830&r1=619829&r2=619830&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 8 02:53:45 2008
@@ -28,57 +28,28 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import org.apache.myfaces.orchestra.CoreConfig;
+
/**
* Perform a number of useful per-request tasks.
* <p>
- * This filter is entirely optional; it can be omitted if you do not need any of the
- * functionality provided here.
- * <p>
- * Note that it is necessary to define a filter that initialises the Orchestra
- * framework; this can be done either via a standalone filter such as
- * JsfFrameworkAdapterFilter, or via a filter that combines framework initialisation
- * with the functionality of this class, such as
- * {@link org.apache.myfaces.orchestra.conversation.jsf.filter.OrchestraServletFilter}.
+ * This filter has been deprecated. The configuration settings it supports are
+ * still implemented; however web.xml files defining this filter should instead
+ * simply define context params using the corresponding constants from class
+ * org.apache.myfaces.orchestra.CoreConfig instead.
* <p>
* <h2>Request Serialization</h2>
- * It is possible for multiple requests associated with the same http session to be
- * received concurrently.
- * <p>
- * By default, the servlet engine simply processes all requests concurrently
- * in different threads. However that can cause all sorts of unexpected problems with
- * session-scoped objects.
- * <p>
- * The usual solution is to apply a filter to all requests which uses standard java
- * synchronisation on a session-scoped object, taking the lock on request entry and
- * releasing it on request exit. This ensures that only one request for that session
- * runs at a time, with the others waiting until they can obtain a lock on the
- * appropriate object. This is referred to as "request serialization" because it causes
- * requests to be processed serially, ie one after the other, rather than concurrently.
- * This has nothing to do with java.io.Serializable.
- * <p>
- * When using an Orchestra conversationContext, session-scoped data should be avoided and
- * conversation-scoped beans used instead. If there is no session-scoped data in use by
- * an application then it is possible to allow concurrent requests to the same http session,
- * but NOT concurrent access to the same orchestra conversationContext. This filter
- * implements that, by holding a lock on a mutex object held by the appropriate
- * conversationContext.
- * <p>
- * The request serialization functionality can be enabled or disabled via a filter init
+ * Request serialization functionality can be enabled or disabled via a filter init
* parameter; setting "serializeRequests" to "false" disables this feature. Default
* value: true (enabled).
* <p>
+ * See {@See CoreConfig.SERIALIZE_REQUESTS} for further details.
+ * <p>
* <h2>JDBC Connection Management</h2>
- * Orchestra provides a special DataSource wrapper that can be configured for any
- * datasource used by the application. The datasource simply wraps all real Connection
- * objects it returns in a proxy, and keeps track of them. Here in this servlet it
- * checks whether all connections borrowed by this thread have been returned, and if
- * not returns the real connection nulls out the connection held by the proxy. See
- * ConnectionManagerDataSource for more details.
+ * This servlet always enables connection management; see
+ * {@See CoreConfig.CLEANUP_CONNECTIONS} for further details.
*/
-// THIS CLASS HAS BEEN TEMPORARILY MODIFIED. The code formerly in here has been moved
-// to the OrchestraFacesContextFactory. That code needs to be made configurable again
-// (everything is currently hard-wired to on, unlike this filter).
public class OrchestraServletFilter implements Filter
{
/**
@@ -99,6 +70,8 @@
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);
}
Added: 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=619830&view=auto
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConfigUtils.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ConfigUtils.java Fri Feb 8 02:53:45 2008
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.orchestra.lib.jsf;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility methods for configuring the behaviour of a JSF-based Orchestra installation.
+ */
+public abstract class ConfigUtils
+{
+ 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;
+ }
+
+ /**
+ * 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=619830&r1=619829&r2=619830&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 8 02:53:45 2008
@@ -18,8 +18,13 @@
*/
package org.apache.myfaces.orchestra.lib.jsf;
+import java.util.Map;
+
import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import org.apache.myfaces.orchestra.CoreConfig;
import org.apache.myfaces.orchestra.conversation.ConversationContext;
import org.apache.myfaces.orchestra.conversation.ConversationManager;
@@ -29,17 +34,11 @@
*/
class ContextLockRequestHandler implements RequestHandler
{
- boolean serializeRequests;
ConversationContext context;
- public ContextLockRequestHandler(boolean serializeRequests)
+ public void init(FacesContext facesContext) throws FacesException
{
- this.serializeRequests = serializeRequests;
- }
-
- public void init() throws FacesException
- {
- if (serializeRequests)
+ if (getSerializeRequests(facesContext))
{
// Note that ConversationManager.getInstance requires the FrameworkAdapter
// to be initialised...
@@ -67,6 +66,23 @@
{
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 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=619830&r1=619829&r2=619830&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 8 02:53:45 2008
@@ -19,6 +19,7 @@
package org.apache.myfaces.orchestra.lib.jsf;
import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
import org.apache.myfaces.orchestra.conversation.ConversationManager;
@@ -28,7 +29,7 @@
*/
class ConversationManagerRequestHandler implements RequestHandler
{
- public void init() throws FacesException
+ public void init(FacesContext facesContext) throws FacesException
{
ConversationManager.getInstance();
}
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=619830&r1=619829&r2=619830&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 8 02:53:45 2008
@@ -19,7 +19,9 @@
package org.apache.myfaces.orchestra.lib.jsf;
import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import org.apache.myfaces.orchestra.CoreConfig;
import org.apache.myfaces.orchestra.connectionManager.ConnectionManagerDataSource;
/**
@@ -28,13 +30,21 @@
*/
class DataSourceLeakRequestHandler implements RequestHandler
{
- public void init() throws FacesException
+ 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 deinit() throws FacesException
{
- ConnectionManagerDataSource.releaseAllBorrowedConnections();
+ 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=619830&r1=619829&r2=619830&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 8 02:53:45 2008
@@ -35,6 +35,8 @@
* <p>
* Any methods that do not actually need to be overridden are declared final
* in order to improve performance (helps the JVM to optimise away the call).
+ * <p>
+ * Note that this class does NOT call
*
* @since 1.1
*
@@ -50,9 +52,16 @@
//~ Constructors ----------------------------------------------------------
- public FacesContextWrapper(FacesContext facesContext)
+ /**
+ * The install parameter controls whether this object will be configured as
+ * the object returned from calls to FacesContext.getCurrentInstance() or not.
+ */
+ public FacesContextWrapper(FacesContext facesContext, boolean install)
{
- _facesContext = facesContext;
+ _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=619830&r1=619829&r2=619830&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 8 02:53:45 2008
@@ -19,10 +19,12 @@
package org.apache.myfaces.orchestra.lib.jsf;
import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.orchestra.CoreConfig;
import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
import org.apache.myfaces.orchestra.frameworkAdapter.jsf.JsfFrameworkAdapter;
@@ -35,23 +37,17 @@
private final Log log = LogFactory.getLog(FrameworkAdapterRequestHandler.class);
- private FacesContext facesContext;
private JsfFrameworkAdapter adapter;
- public FrameworkAdapterRequestHandler(FacesContext facesContext)
- {
- this.facesContext = facesContext;
- }
-
- public void init() throws FacesException
+ 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 = facesContext.getExternalContext().getInitParameter(
- CONVERSATION_MESSAGER_CLASS);
+ String conversationMessagerClass = getConversationMessagerClass(facesContext);
adapter = new JsfFrameworkAdapter(conversationMessagerClass);
adapter.beginRequest();
}
@@ -63,5 +59,19 @@
{
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=619830&r1=619829&r2=619830&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 8 02:53:45 2008
@@ -20,6 +20,7 @@
import java.util.LinkedList;
import java.util.ListIterator;
+import java.util.Map;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
@@ -72,15 +73,27 @@
return null;
}
- // TODO: make this handlers list configurable
+ // 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(true));
- handlers.add(new FrameworkAdapterRequestHandler(facesContext));
+ 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. All that
+ // 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. By not installing this as the object used
+ // elsewhere, we save a little bit of performance.
log.debug("getFacesContext: creating custom instance");
- return new FacesContextWrapper(facesContext)
+ return new FacesContextWrapper(facesContext, false)
{
// Constructor...
{
@@ -97,7 +110,7 @@
log.debug("Running inithandler of type " + i.getClass().getName());
}
- h.init();
+ h.init(facesContext);
}
}
catch(RuntimeException 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=619830&r1=619829&r2=619830&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 8 02:53:45 2008
@@ -19,13 +19,14 @@
package org.apache.myfaces.orchestra.lib.jsf;
import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
/**
* An interface for classes that want to be run at the start and end
* of each jsf request.
*/
-interface RequestHandler
+public interface RequestHandler
{
- void init() throws FacesException;
+ void init(FacesContext facesContext) throws FacesException;
void deinit() throws FacesException;
}