incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r489424 - in /incubator/adffaces/branches/jwaldman-portal/trinidad: ./ trinidad-api/ trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/ trinidad-impl/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/ trini...
Date Thu, 21 Dec 2006 18:10:02 GMT
Author: awiner
Date: Thu Dec 21 10:09:54 2006
New Revision: 489424

URL: http://svn.apache.org/viewvc?view=rev&rev=489424
Log:
Cleanup GlobalConfiguratorImpl and Configurator classes

Removed:
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/GenericConfigurator.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/GlobalConfigurator.java
Modified:
    incubator/adffaces/branches/jwaldman-portal/trinidad/pom.xml
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/pom.xml
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/Configurator.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/pom.xml
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java
    incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/pom.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/pom.xml?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/pom.xml (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/pom.xml Thu Dec 21 10:09:54 2006
@@ -338,6 +338,13 @@
       </dependency>
 
       <dependency>
+        <groupId>portlet-api</groupId>
+        <artifactId>portlet-api</artifactId>
+        <version>1.0</version>
+        <scope>provided</scope>
+      </dependency>
+
+      <dependency>
         <groupId>org.apache.myfaces.core</groupId>
         <artifactId>myfaces-api</artifactId>
         <version>1.1.4</version>

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/pom.xml?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/pom.xml (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/pom.xml Thu Dec 21 10:09:54
2006
@@ -132,13 +132,6 @@
     </dependency>
 
     <dependency>
-      <groupId>portlet-api</groupId>
-      <artifactId>portlet-api</artifactId>
-      <version>1.0</version>
-      <scope>provided</scope>
-    </dependency>
-
-    <dependency>
       <groupId>org.apache.myfaces.core</groupId>
       <artifactId>myfaces-api</artifactId>
     </dependency>

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/Configurator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/Configurator.java?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/Configurator.java
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/config/Configurator.java
Thu Dec 21 10:09:54 2006
@@ -18,10 +18,15 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import javax.faces.context.ExternalContext;
 import javax.servlet.ServletRequest;
 
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
+import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
 
 /**
  * This defines an abstract class for the Configurator. Classes implementing
@@ -50,9 +55,66 @@
  * @author Scott O'Bryan (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class Configurator
+abstract public class Configurator
 {
   /**
+   * Returns the proper instance of the Configurator.
+   * An ExternalContext is generally passed to ensure that
+   * a Configurator can properly be created, if necessary.
+   * However, a null ExternalContext may be passed if
+   * there is no requirement that a Configurator be created
+   * if not already loaded - calls to destroy() are the
+   * most obvious scenario.
+   */
+  static public Configurator getInstance(ExternalContext ec)
+  {
+    ClassLoader loader = Thread.currentThread().getContextClassLoader();
+    
+    if (loader == null)
+      _LOG.severe("Could not find context class loader.");
+    else
+    {
+      // FIXME: would probably be better to just use ConcurrentHashMap
+      synchronized(_CONFIGURATORS)
+      {
+        Configurator config = _CONFIGURATORS.get(loader);
+        if ((config == null) && (ec != null))
+        {
+          try
+          {
+            List<Configurator> configs = ClassLoaderUtils.getServices(
+               _GLOBAL_CONFIGURATOR);
+            if (configs.isEmpty())
+            {
+              _LOG.severe("Could not load a global configurator");
+              // Create a null configurator (which is an empty subclass),
+              // just so we don't have to re-warn the user every time
+              config = new Configurator() {};
+            }
+            else
+            {
+              config = configs.get(0);
+            }
+
+            config.init(ec);
+            _CONFIGURATORS.put(loader, config);
+            _LOG.fine("GlobalConfigurator has been created.");
+          }
+          catch (RuntimeException e)
+          {
+            // OC4J was not reporting these errors properly:
+            _LOG.severe(e);
+            throw e;
+          }
+        }
+        return config;
+      }
+    } 
+
+    return null;
+  }
+
+  /**
    * Initializes the Configurator.  This method is guaranteed to run before
    * any other method within this Configurator and will be called by the
    * GlobalConfigurator only once per webapp context.  This init is
@@ -144,62 +206,39 @@
    * Disables Configurator services for the current request.  When this method
    * has been called on a request, then calls to beginRequest, endRequest, and
    * getExternalContext will not execute any of the associated services or
-   * initialize the RequestContext.  After the physical request is complete
-   * then this flag will automatically be cleared.
+   * initialize the RequestContext.
    * 
-   * <p><string>Note:</strong> that this command should be execured before
+   * <p><string>Note:</strong> that this command should be executed before
    * {@link Configurator#beginRequest(ExternalContext)}.</p>
    * 
-   * @param request the HttpServletRequest for which to disable this configurator
-   * @throws InvocationTargetException 
-   * @throws IllegalAccessException 
-   * @throws IllegalArgumentException 
-   * 
-   * @throws IllegalStateException when this is run after a beginRequest on
-   *         the current request.
+   * @param ec the ExternalContext
    */
-  public static final void disableConfiguratorServices(final ServletRequest request)
+  public static final void disableConfiguratorServices(ExternalContext ec)
   {
-    ClassLoader loader = Thread.currentThread().getContextClassLoader();
-    if (loader == null)
-      _LOG.severe("Could not find context class loader.");
-    else
-    {
-      try
-      {
-        //We have to use the IMPL method because this is final so people don't override it
-        Method disable = loader.loadClass("org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl")
-                               .getMethod("disableConfiguratorServicesImpl", _SERVLET_REQUEST_ARRAY);
-        Object[] paramArray = {request};
-        disable.invoke(null, paramArray);
-      }
-      catch (ClassNotFoundException e)
-      {
-        _LOG.severe(e);
-      }
-      catch (SecurityException e)
-      {
-        _LOG.severe(e);
-      }
-      catch (NoSuchMethodException e)
-      {
-        _LOG.severe(e);
-      }
-      catch (IllegalArgumentException e)
-      {
-        _LOG.severe(e);      
-      }
-      catch (IllegalAccessException e)
-      {
-        _LOG.severe(e);      
-      }
-      catch (InvocationTargetException e)
-      {
-        _LOG.severe(e);
-      }
-    }
+    ec.getRequestMap().put(_DISABLE_SERVICES, Boolean.TRUE);
+  }
+
+  /**
+   * Utility to disable configurator services without access to
+   * an ExternalContext.
+   */
+  public static final void disableConfiguratorServices(ServletRequest srq)
+  {
+    srq.setAttribute(_DISABLE_SERVICES, Boolean.TRUE);
+  }
+
+  public static final boolean isConfiguratorServiceDisabled(ExternalContext ec)
+  {
+    return Boolean.TRUE.equals(ec.getRequestMap().get(_DISABLE_SERVICES));
   }
   
   private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(Configurator.class);
   private static final Class[] _SERVLET_REQUEST_ARRAY = {ServletRequest.class};
+
+  static private final String _GLOBAL_CONFIGURATOR =
+    "org.apache.myfaces.trinidad.config.GlobalConfigurator";
+  static private final String _DISABLE_SERVICES =
+    "org.apache.myfaces.trinidad.config.DISABLE_SERVICES";
+  static private final Map<ClassLoader, Configurator> _CONFIGURATORS
+   = new HashMap<ClassLoader, Configurator>();
 }

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/pom.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/pom.xml?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/pom.xml (original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/pom.xml Thu Dec 21
10:09:54 2006
@@ -171,8 +171,6 @@
     <dependency>
       <groupId>portlet-api</groupId>
       <artifactId>portlet-api</artifactId>
-      <version>1.0</version>
-      <scope>provided</scope>
     </dependency>
 
     <dependency>

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/GlobalConfiguratorImpl.java
Thu Dec 21 10:09:54 2006
@@ -40,6 +40,8 @@
  * @author Scott O'Bryan (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
+//FIXME: destroy() and endRequest() should go in inverse order
+// from init() and startRequest()
 public class GlobalConfiguratorImpl extends Configurator
 {
   /**
@@ -56,64 +58,12 @@
     return Boolean.TRUE.equals(ec.getRequestMap().get(_IN_REQUEST));
   }
   
-  /**
-   * 
-   */
-  public static boolean isRequestDisabled(final ExternalContext ec)
-  {
-    return _DISABLED.equals(ec.getRequestMap().get(_IN_REQUEST));
-  }
-  
-  /**
-   * Returns a GlobalConfigurator instance for the current context's class loader.  The
-   * GlobalConfigurator is responsible for enforcing the contract on the other methods
-   * of this class.  This means that if {@link #init(ExternalContext)} is called multiple
-   * times, the global configurator will call all subordinate configurators only once.
-   * 
-   * <p>Likewise, the GlobalConfigurator will return exceptions when the contract is
-   * expressly violated (like if {@link #getExternalContext(ExternalContext)} is called
-   * before a {{@link #beginRequest(ExternalContext)}.
-   * 
-   * @return a GlobalConfigurator or <code>null</code> is one was unable to be
obtained.
-   */
-  public static final GlobalConfiguratorImpl getInstance()
-  {
-    ClassLoader loader = Thread.currentThread().getContextClassLoader();
-    
-    if (loader == null)
-      _LOG.severe("Could not find context class loader.");
-    else
-    {
-      synchronized(_CONFIGURATORS)
-      {
-        GlobalConfiguratorImpl config = _CONFIGURATORS.get(loader);
-        if(config == null)
-        {
-          try
-          {
-            config = new GlobalConfiguratorImpl();
-            _CONFIGURATORS.put(loader, config);
-          }
-          catch (RuntimeException e)
-          {
-            // OC4J was not reporting these errors properly:
-            _LOG.severe(e);
-            throw e;
-          }
-          _LOG.fine("GlobalConfigurator has been created.");
-        }
-        return config;
-      }
-    } 
-    return null;
-  }
 
   /**
    * Default constructor
    */
-  private GlobalConfiguratorImpl()
+  public GlobalConfiguratorImpl()
   {
-    _services = ClassLoaderUtils.getServices(Configurator.class.getName());
   }
 
   /*
@@ -122,11 +72,11 @@
    * @see org.apache.myfaces.trinidad.config.Configurator#beginRequest(javax.faces.context.ExternalContext)
    */
   @SuppressWarnings("unchecked")
-  public void beginRequest(final ExternalContext externalContext)
+  public void beginRequest(ExternalContext externalContext)
   {
     _checkInitialized();
     
-    if(!isRequestDisabled(externalContext))
+    if(!isConfiguratorServiceDisabled(externalContext))
     {
       _attachRequestContext(externalContext);
   
@@ -170,10 +120,6 @@
         // we always want to continue to destroy things, so log errors and continue
         _LOG.severe(t);
       }
-      finally
-      {
-        _initialized = false;
-      }
     }
   }
 
@@ -186,7 +132,7 @@
   {
     _checkInitialized();
     
-    if (!isRequestDisabled(externalContext))
+    if (!isConfiguratorServiceDisabled(externalContext))
     {
       if (isRequestBegun(externalContext))
       {
@@ -216,7 +162,7 @@
   {
     _checkInitialized();
     
-    if(!isRequestDisabled(externalContext))
+    if(!isConfiguratorServiceDisabled(externalContext))
     {
       // Wrap ExternalContexts
       for (final Configurator config : _services)
@@ -228,19 +174,13 @@
     return externalContext;
   }
 
-  /**
-   * Gets the maximum number of bytes that MultipartFormItem.writeFile() will be allowed
to write.
-   */
-  public long getMaximumAllowedBytes()
-  {
-    return _maxAllowedBytes;
-  }
-
   /*
    * @see org.apache.myfaces.trinidad.config.Configurator#init(javax.faces.context.ExternalContext)
    */
-  public void init(final ExternalContext externalContext)
+  public void init(ExternalContext externalContext)
   {
+    _services = ClassLoaderUtils.getServices(Configurator.class.getName());
+
     // Create a new RequestContextFactory is needed
     if (RequestContextFactory.getFactory() == null)
     {
@@ -253,58 +193,21 @@
       SkinFactory.setFactory(new SkinFactoryImpl());
     }
 
-    if (!_initialized)
-    {
-      // register the base skins
-      SkinUtils.registerBaseSkins();
-
-      for (final Configurator config : _services)
-      {
-        config.init(externalContext);
-      }
-
-      // after the 'services' filters are initialized, then register
-      // the skin extensions found in trinidad-skins.xml. This
-      // gives a chance to the 'services' filters to create more base
-      // skins that the skins in trinidad-skins.xml can extend.
-      SkinUtils.registerSkinExtensions(externalContext);
-      _initialized = true;
-    }
-  }
-
-  public boolean isInitialized()
-  {
-    return _initialized;
-  }
-
-  /* Do not refactor this as it's called using reflection from the API package
-   * 
-   * @see org.apache.myfaces.trinidad.config.Configurator#disableConfiguratorServices(javax.servlet.http.HttpServletRequest)
-   */
-  public static void disableConfiguratorServicesImpl(final ServletRequest request)
-  {
-    if(Boolean.TRUE.equals(request.getAttribute(_IN_REQUEST)))
+    // register the base skins
+    SkinUtils.registerBaseSkins();
+    
+    for (final Configurator config : _services)
     {
-        throw new IllegalStateException("Request is already begun.");
+      config.init(externalContext);
     }
     
-    request.setAttribute(_IN_REQUEST, _DISABLED);
-  }
+    // after the 'services' filters are initialized, then register
+    // the skin extensions found in trinidad-skins.xml. This
+    // gives a chance to the 'services' filters to create more base
+    // skins that the skins in trinidad-skins.xml can extend.
+    SkinUtils.registerSkinExtensions(externalContext);
 
-  /**
-   * Sets the maximum number of bytes that MultipartFormItem.writeFile() will be allowed
to write.
-   * This value may be set immediately before or between calls to MultipartFormItem.writeFile().
If
-   * any call to writeFile() exceeds this value, an EOFException will be thrown.
-   * <p>
-   * 
-   * @param maxAllowedBytes
-   *          the maximum number of bytes that MultipartFormItem.writeFile() will be allowed
to
-   *          write. Defaults to 128MB.
-   * @see org.apache.myfaces.trinidadinternal.share.util.MultipartFormItem#writeFile
-   */
-  public void setMaximumAllowedBytes(final long maxAllowedBytes)
-  {
-    _maxAllowedBytes = Math.max(0L, maxAllowedBytes);
+    _inited = true;
   }
 
   /**
@@ -353,7 +256,7 @@
 
   private void _checkInitialized()
   {
-    if (!isInitialized())
+    if (!_inited)
     {
       throw new IllegalStateException("Configurator not initialized!");
     }
@@ -365,12 +268,9 @@
    * @see org.apache.myfaces.trinidad.config.GlobalConfigurator#getPersistantRequestMap(javax.faces.context.ExternalContext)
    */
 
-  private boolean                     _initialized           = false;
-  private long                        _maxAllowedBytes;
-  private List<Configurator>          _services              = null;
+  private boolean                     _inited;
+  private List<Configurator>          _services;
   
   static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(GlobalConfiguratorImpl.class);
-  static private final Map<ClassLoader, GlobalConfiguratorImpl> _CONFIGURATORS = new
HashMap<ClassLoader, GlobalConfiguratorImpl>();
   static private final String _IN_REQUEST = GlobalConfiguratorImpl.class.getName()+".IN_REQUEST";
-  static private final String _DISABLED = "disabled";
  }

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/dispatch/DispatchResponseConfiguratorImpl.java
Thu Dec 21 10:09:54 2006
@@ -200,6 +200,10 @@
    * @param context
    * @return
    */
+  // FIXME: AdamWiner: I don't get how this could be applied
+  // twice - that would be a bug in the configurator system,
+  // and should be handled at that layer, not in individual
+  // configurators
   static public boolean isApplied(ExternalContext context)
   {
     return (context.getRequestMap().get(_APPLIED)!=null);

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/upload/FileUploadConfiguratorImpl.java
Thu Dec 21 10:09:54 2006
@@ -75,7 +75,7 @@
   }
 
   /* (non-Javadoc)
-   * @see org.apache.myfaces.trinidad.config.GenericConfigurator#beginRequest(javax.faces.context.ExternalContext)
+   * @see org.apache.myfaces.trinidad.config.Configurator#beginRequest(javax.faces.context.ExternalContext)
    */
   @Override
   @SuppressWarnings("unchecked")
@@ -89,6 +89,9 @@
      * generated the next request.  If we need to clean up sooner then we should
      * clean up on the end-request.
      */
+    // FIXME AdamWiner We should clean up ASAP - these are potentially very
+    // large allocations of memory and file, so cleaning up as soon
+    // as possible is a good thing
     //Process MultipartForm if need be
     if (MultipartFormHandler.isMultipartRequest(externalContext) && 
        (externalContext.getRequest() instanceof HttpServletRequest || 
@@ -99,6 +102,8 @@
         final MultipartFormHandler mfh = new MultipartFormHandler(externalContext);
 
         // TODO: How is this set?
+        // AdamWiner: looks like the previous Trinidad incarnation
+        // of this code didn't have any allowed configuration...
         mfh.setMaximumAllowedBytes(_maxAllowedBytes);
         mfh.setCharacterEncoding(ExternalContextUtils.getCharacterEncoding(externalContext));
 
@@ -146,7 +151,7 @@
   }
 
   /* (non-Javadoc)
-   * @see org.apache.myfaces.trinidad.config.GenericConfigurator#getExternalContext(javax.faces.context.ExternalContext)
+   * @see org.apache.myfaces.trinidad.config.Configurator#getExternalContext(javax.faces.context.ExternalContext)
    */
   @Override
   public ExternalContext getExternalContext(ExternalContext externalContext)
@@ -167,7 +172,7 @@
   }
 
   /* (non-Javadoc)
-   * @see org.apache.myfaces.trinidad.config.GenericConfigurator#init(javax.faces.context.ExternalContext)
+   * @see org.apache.myfaces.trinidad.config.Configurator#init(javax.faces.context.ExternalContext)
    */
   @Override
   public void init(ExternalContext externalContext)

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/FacesContextFactoryImpl.java
Thu Dec 21 10:09:54 2006
@@ -58,14 +58,9 @@
       Lifecycle lifecycle)
   {
     FacesContext fc = _factory.getFacesContext(context, request, response, lifecycle);
-    GlobalConfiguratorImpl config = GlobalConfiguratorImpl.getInstance();
     ExternalContext ec = fc.getExternalContext();
-    
-    if(!config.isInitialized())
-    {
-      config.init(ec);
-    }
-    
+
+    Configurator config = Configurator.getInstance(ec);    
     //The global configurator will make sure other configurators are run only once
     if(!GlobalConfiguratorImpl.isRequestBegun(ec))
     {
@@ -97,7 +92,9 @@
       _base = base;
       
       //SMO: TODO: is this still needed?
-      ExternalContext external = GlobalConfiguratorImpl.getInstance().getExternalContext(base.getExternalContext());
+      ExternalContext baseExternal = base.getExternalContext();
+      ExternalContext external = 
+        Configurator.getInstance(baseExternal).getExternalContext(baseExternal);
       _external = new OverrideDispatch(external);
       setCurrentInstance(this);
     }
@@ -246,7 +243,7 @@
       ExternalContext ec = getExternalContext();
       if(Boolean.TRUE.equals(ec.getApplicationMap().remove(_READY_FOR_CLEANUP)))
       {
-        GlobalConfiguratorImpl.getInstance().endRequest(ec);      
+        Configurator.getInstance(ec).endRequest(ec);
       }
       
       _base.release();

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/external/ServletSessionMap.java
Thu Dec 21 10:09:54 2006
@@ -48,7 +48,7 @@
 
   @Override
   @SuppressWarnings("unchecked")
-  protected Enumeration getAttributeNames()
+  protected Enumeration<String> getAttributeNames()
   {
     final HttpSession httpSession = _getSession();
     return httpSession == null ? NullEnumeration.instance() : httpSession.getAttributeNames();

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadFilterImpl.java
Thu Dec 21 10:09:54 2006
@@ -36,7 +36,6 @@
 import org.apache.myfaces.trinidad.config.Configurator;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.util.ClassLoaderUtils;
-import org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl;
 import org.apache.myfaces.trinidadinternal.config.dispatch.DispatchResponseConfiguratorImpl;
 import org.apache.myfaces.trinidadinternal.config.dispatch.DispatchServletResponse;
 import org.apache.myfaces.trinidadinternal.config.upload.FileUploadConfiguratorImpl;
@@ -85,12 +84,7 @@
     FilterConfig filterConfig) throws ServletException
   {
       _servletContext = filterConfig.getServletContext();
-      
-      //This is the container agnostic initialization filters.  These will work in the portal
-      //as well, but they will be tied to the creation of the Lifecycle.
-      ExternalContext externalContext = new ServletExternalContext(_servletContext, null,
null);
-      GlobalConfiguratorImpl.getInstance().init(externalContext);
-      
+            
       //There is some functionality that still might require servlet-only filter services.
       _filters = ClassLoaderUtils.getServices(TrinidadFilterImpl.class.getName());
       for(Filter f:_filters)
@@ -109,7 +103,9 @@
       _filters = null;
       
       //Destroy container agnostic services
-      GlobalConfiguratorImpl.getInstance().destroy();
+      Configurator config = Configurator.getInstance(null);
+      if (config != null)
+        config.destroy();
   }
 
   @SuppressWarnings("unchecked")
@@ -127,7 +123,8 @@
     request.setAttribute(_FILTER_EXECUTED_KEY, Boolean.TRUE);
 
     ExternalContext externalContext = new ServletExternalContext(_servletContext, request,
response);    
-    GlobalConfiguratorImpl.getInstance().beginRequest(externalContext);
+    Configurator config = Configurator.getInstance(externalContext);
+    config.beginRequest(externalContext);
     
     //To maintain backward compatibilty, wrap the request at the filter level
     Map<String, String[]> addedParams = (Map<String, String[]>) externalContext.getRequestMap().get(FileUploadConfiguratorImpl._PARAMS);
@@ -145,7 +142,7 @@
     }
     finally
     {
-      GlobalConfiguratorImpl.getInstance().endRequest(externalContext);
+      config.endRequest(externalContext);
     }
   }
 

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/TrinidadListenerImpl.java
Thu Dec 21 10:09:54 2006
@@ -18,7 +18,7 @@
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
-import org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl;
+import org.apache.myfaces.trinidad.config.Configurator;
 
 /**
  * Implementation of the Trinidad Context Listener
@@ -34,13 +34,12 @@
    */
   public void contextDestroyed(ServletContextEvent arg0)
   {
-    GlobalConfiguratorImpl config = GlobalConfiguratorImpl.getInstance();
-    
-    if(config.isInitialized())
-    {
-      //clean up the global configurator if it is initialized
-      config.destroy();
-    }
+    // FIXME: why is this here?  The filter has to be installed (in
+    // a servlet environment, as for this class), and
+    // it performs cleanup, so why do we worry about cleaning up here?
+    // Configurator config = Configurator.getInstance(null);
+    // if (config != null)
+    //   config.destroy();
   }
 
   /* (non-Javadoc)

Modified: incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator?view=diff&rev=489424&r1=489423&r2=489424
==============================================================================
--- incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator
(original)
+++ incubator/adffaces/branches/jwaldman-portal/trinidad/trinidad-impl/src/main/resources/META-INF/services/org.apache.myfaces.trinidad.config.GlobalConfigurator
Thu Dec 21 10:09:54 2006
@@ -0,0 +1,2 @@
+org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl
+



Mime
View raw message