You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/08/12 19:41:24 UTC

svn commit: r984873 - in /myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config: CustomImplementationParser.java DefaultWindowContextConfig.java

Author: gpetracek
Date: Thu Aug 12 17:41:24 2010
New Revision: 984873

URL: http://svn.apache.org/viewvc?rev=984873&view=rev
Log:
EXTCDI-1, EXTCDI-2 and EXTCDI-3 config refactoring (intermediate result)

Added:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/CustomImplementationParser.java
Modified:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultWindowContextConfig.java

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/CustomImplementationParser.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/CustomImplementationParser.java?rev=984873&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/CustomImplementationParser.java (added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/CustomImplementationParser.java Thu Aug 12 17:41:24 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.extensions.cdi.javaee.jsf.impl.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
+
+/**
+ * @author Gerhard Petracek
+ */
+class CustomImplementationParser<T> implements ConfigValueParser<T>
+{
+    public T parse(String value)
+    {
+        return (T)ClassUtils.tryToInstantiateClassForName(value);
+    }
+}
\ No newline at end of file

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultWindowContextConfig.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultWindowContextConfig.java?rev=984873&r1=984872&r2=984873&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultWindowContextConfig.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultWindowContextConfig.java Thu Aug 12 17:41:24 2010
@@ -136,28 +136,26 @@ public class DefaultWindowContextConfig 
 
     public ConversationFactory getConversationFactory()
     {
-        //TODO add config parameter
-        return new JsfAwareConversationFactory();
+        lazyInit();
+        return getAttribute(ConversationFactory.class.getName(), ConversationFactory.class);
     }
 
     public WindowContextFactory getWindowContextFactory()
     {
-        //TODO add config parameter
-        //we don't need a default implementation
-        return null;
+        lazyInit();
+        return getAttribute(WindowContextFactory.class.getName(), WindowContextFactory.class);
     }
 
     public WindowContextManagerFactory getWindowContextManagerFactory()
     {
-        //TODO add config parameter
-        //we don't need a default implementation
-        return null;
+        lazyInit();
+        return getAttribute(WindowContextManagerFactory.class.getName(), WindowContextManagerFactory.class);
     }
 
     public WindowContextQuotaHandler getWindowContextQuotaHandler()
     {
-        //TODO add config parameter
-        return new DefaultWindowContextQuotaHandler(getMaxWindowContextCount());
+        lazyInit();
+        return getAttribute(WindowContextQuotaHandler.class.getName(), WindowContextQuotaHandler.class);
     }
 
     public boolean isInitialRedirectDisable()
@@ -190,6 +188,12 @@ public class DefaultWindowContextConfig 
         initConversationTimeout(facesContext);
         initDisableInitialRedirect(facesContext);
         initConversatonEvents(facesContext);
+
+        //init custom implementations
+        initWindowContextManagerFactory(facesContext);
+        initWindowContextFactory(facesContext);
+        initConversationFactory(facesContext);
+        initWindowContextQuotaHandler(facesContext);
     }
 
     private void initUrlParameterEnabled(FacesContext facesContext)
@@ -257,6 +261,38 @@ public class DefaultWindowContextConfig 
                 ENABLE_UNSCOPE_BEAN_EVENT, new BooleanConfigValueParser(), ENABLE_UNSCOPE_BEAN_EVENT_DEFAULT);
     }
 
+    private void initWindowContextManagerFactory(FacesContext facesContext)
+    {
+        initConfig(facesContext,
+                   WindowContextManagerFactory.class.getName(),
+                   new CustomImplementationParser<WindowContextManagerFactory>(),
+                   null);
+    }
+
+    private void initWindowContextFactory(FacesContext facesContext)
+    {
+        initConfig(facesContext,
+                   WindowContextFactory.class.getName(),
+                   new CustomImplementationParser<WindowContextFactory>(),
+                   null);
+    }
+
+    private void initConversationFactory(FacesContext facesContext)
+    {
+        initConfig(facesContext,
+                   ConversationFactory.class.getName(),
+                   new CustomImplementationParser<ConversationFactory>(),
+                   new JsfAwareConversationFactory());
+    }
+
+    private void initWindowContextQuotaHandler(FacesContext facesContext)
+    {
+        initConfig(facesContext,
+                   WindowContextQuotaHandler.class.getName(),
+                   new CustomImplementationParser<WindowContextQuotaHandler>(),
+                   new DefaultWindowContextQuotaHandler(getMaxWindowContextCount()));
+    }
+
     protected <T> void initConfig(FacesContext facesContext,
                                   String configKey,
                                   ConfigValueParser<T> configValueParser,