myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1226314 - in /myfaces/extensions/cdi/trunk: core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/projectstage/ jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/ jee-modules/jsf-modu...
Date Sun, 01 Jan 2012 23:32:43 GMT
Author: gpetracek
Date: Sun Jan  1 23:32:42 2012
New Revision: 1226314

URL: http://svn.apache.org/viewvc?rev=1226314&view=rev
Log:
EXTCDI-255 decouple ProjectStageProducer from JsfProjectStageProducer

Added:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/JsfProjectStageProducerConfiguredValueResolver.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver
Modified:
    myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/projectstage/ProjectStageProducer.java

Modified: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/projectstage/ProjectStageProducer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/projectstage/ProjectStageProducer.java?rev=1226314&r1=1226313&r2=1226314&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/projectstage/ProjectStageProducer.java
(original)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/projectstage/ProjectStageProducer.java
Sun Jan  1 23:32:42 2012
@@ -19,8 +19,8 @@
 package org.apache.myfaces.extensions.cdi.core.impl.projectstage;
 
 
+import org.apache.myfaces.extensions.cdi.core.api.Aggregatable;
 import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
-import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
 import org.apache.myfaces.extensions.cdi.core.impl.util.CodiUtils;
 
 import javax.enterprise.context.Dependent;
@@ -133,15 +133,44 @@ public class ProjectStageProducer implem
         }
 
         ProjectStageProducer defaultProjectStageProducer = new ProjectStageProducer();
-        projectStageProducer = CodiUtils.lookupFromEnvironment(ProjectStageProducer.class,
defaultProjectStageProducer);
+        projectStageProducer = CodiUtils.lookupFromEnvironment(ProjectStageProducer.class,
+                new Aggregatable<ProjectStageProducer>()
+                {
+                    private ProjectStageProducer specializedCodiProjectStageProducer;
+                    private ProjectStageProducer customConfiguredProjectStageProducer;
 
-        if(projectStageProducer == null)
-        {
-            //workaround to avoid the usage of a service loader
-            projectStageProducer = ClassUtils.tryToInstantiateClassForName(
-                    "org.apache.myfaces.extensions.cdi.jsf.impl.projectstage.JsfProjectStageProducer",
-                    ProjectStageProducer.class);
-        }
+                    /**
+                     * {@inheritDoc}
+                     */
+                    public void add(ProjectStageProducer projectStageProducer)
+                    {
+                        if(projectStageProducer.getClass().getName().startsWith("org.apache.myfaces."))
+                        {
+                            specializedCodiProjectStageProducer = projectStageProducer;
+                        }
+                        else
+                        {
+                            customConfiguredProjectStageProducer = projectStageProducer;
+                        }
+                    }
+
+                    /**
+                     * {@inheritDoc}
+                     */
+                    public ProjectStageProducer create()
+                    {
+                        if(customConfiguredProjectStageProducer != null)
+                        {
+                            return this.customConfiguredProjectStageProducer;
+                        }
+
+                        if(specializedCodiProjectStageProducer != null)
+                        {
+                            return this.specializedCodiProjectStageProducer;
+                        }
+                        return null;
+                    }
+                }, defaultProjectStageProducer);
 
         if (projectStageProducer == null)
         {

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/JsfProjectStageProducerConfiguredValueResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/JsfProjectStageProducerConfiguredValueResolver.java?rev=1226314&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/JsfProjectStageProducerConfiguredValueResolver.java
(added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/JsfProjectStageProducerConfiguredValueResolver.java
Sun Jan  1 23:32:42 2012
@@ -0,0 +1,54 @@
+/*
+ * 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.jsf.impl.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.InvocationOrder;
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueDescriptor;
+import org.apache.myfaces.extensions.cdi.core.impl.config.AbstractConfiguredValueResolver;
+import org.apache.myfaces.extensions.cdi.core.impl.projectstage.ProjectStageProducer;
+import org.apache.myfaces.extensions.cdi.jsf.impl.projectstage.JsfProjectStageProducer;
+
+import javax.enterprise.inject.Typed;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * {@link org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver}
+ * which allows to overrule the default {@link ProjectStageProducer}.
+ * (If a custom {@link ProjectStageProducer} gets returned by a custom
+ * {@link org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver},
+ * it will be ignored.)
+ */
+@Typed()
+@InvocationOrder(500)
+public class JsfProjectStageProducerConfiguredValueResolver extends AbstractConfiguredValueResolver
+{
+    public <K, T> List<T> resolveInstances(ConfiguredValueDescriptor<K, T>
descriptor)
+    {
+        if(ProjectStageProducer.class.isAssignableFrom(descriptor.getTargetType()))
+        {
+            add(JsfProjectStageProducer.class);
+            return getConfiguredValues(descriptor.getTargetType());
+        }
+        else
+        {
+            return Collections.emptyList();
+        }
+    }
+}

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver?rev=1226314&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver
(added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver
Sun Jan  1 23:32:42 2012
@@ -0,0 +1,20 @@
+#####################################################################################
+# 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.
+#####################################################################################
+
+org.apache.myfaces.extensions.cdi.jsf.impl.config.JsfProjectStageProducerConfiguredValueResolver
\ No newline at end of file



Mime
View raw message