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 2011/02/13 19:45:04 UTC
svn commit: r1070277 - in /myfaces/extensions/cdi/trunk:
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/
core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/
core/api/src/main/java/org/apache/myfaces/extensions/c...
Author: gpetracek
Date: Sun Feb 13 18:45:03 2011
New Revision: 1070277
URL: http://svn.apache.org/viewvc?rev=1070277&view=rev
Log:
EXTCDI-134 initial draft and tests
Added:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Aggregatable.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueDescriptor.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueResolver.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/AbstractConfiguredValueResolver.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/LocalJndiResolver.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/ServiceLoaderResolver.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/SystemPropertyResolver.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ArtifactCacheKey.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivatorAggregator.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ConfiguredArtifactUtils.java
myfaces/extensions/cdi/trunk/core/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/RefreshAttribute.java
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/ConfigTest.java
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestArtifact.java
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestClassDeactivator.java
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestConfiguredValueResolver.java
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestImpl.java
myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestInterface.java
myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver
myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.test.impl.config.TestInterface
Modified:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/ClassDeactivator.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/projectstage/ProjectStage.java
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/projectstage/ProjectStageProducer.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivation.java
myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/CodiUtils.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigExtension.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigExtractor.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/projectstage/JsfProjectStageProducer.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/CodiRenderKitFactory.java
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/spi/RenderKitWrapperFactory.java
myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/CodiRenderKitFactory.java
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Aggregatable.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Aggregatable.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Aggregatable.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Aggregatable.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.core.api;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface Aggregatable<T>
+{
+ void add(T t);
+
+ T create();
+}
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/ClassDeactivator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/ClassDeactivator.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/ClassDeactivator.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/ClassDeactivator.java Sun Feb 13 18:45:03 2011
@@ -19,13 +19,14 @@
package org.apache.myfaces.extensions.cdi.core.api;
import java.util.Set;
+import java.io.Serializable;
/**
* Interface for an implementation which provides classes of default implementations which should be deactivated.
*
* @author Gerhard Petracek
*/
-public interface ClassDeactivator
+public interface ClassDeactivator extends Serializable
{
/**
* Provides classes which should be deactivated.
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueDescriptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueDescriptor.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueDescriptor.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueDescriptor.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.core.api.config;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface ConfiguredValueDescriptor<K, T>
+{
+ K getKey();
+
+ Class<T> getTargetType();
+}
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueResolver.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueResolver.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/config/ConfiguredValueResolver.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,34 @@
+/*
+ * 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.core.api.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.Deactivatable;
+
+import java.util.List;
+
+/**
+ * Allows to customize CODI in case of extension points which aren't supported by CDI.
+ * E.g. for artifacts which are needed before the bootstrapping process is finished.
+ *
+ * @author Gerhard Petracek
+ */
+public interface ConfiguredValueResolver extends Deactivatable
+{
+ <K, T> List<T> resolveInstances(ConfiguredValueDescriptor<K, T> descriptor);
+}
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/projectstage/ProjectStage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/projectstage/ProjectStage.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/projectstage/ProjectStage.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/projectstage/ProjectStage.java Sun Feb 13 18:45:03 2011
@@ -21,7 +21,6 @@ package org.apache.myfaces.extensions.cd
import javax.enterprise.inject.Typed;
import java.io.Serializable;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.logging.Logger;
@@ -126,11 +125,9 @@ public abstract class ProjectStage imple
static
{
ServiceLoader<ProjectStageHolder> psSl = ServiceLoader.load(ProjectStageHolder.class);
- Iterator<ProjectStageHolder> psIt = psSl.iterator();
- while (psIt.hasNext())
+ for (ProjectStageHolder aPsSl : psSl)
{
- ProjectStageHolder psH = psIt.next();
- log.fine("registering ProjectStages from ProjectStageHolder " + psH.getClass().getName());
+ log.fine("registering ProjectStages from ProjectStageHolder " + aPsSl.getClass().getName());
}
}
Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java (original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/util/ClassUtils.java Sun Feb 13 18:45:03 2011
@@ -72,6 +72,11 @@ public class ClassUtils
return loader;
}
+ public static <T> Class<T> tryToLoadClassForName(String name, Class<T> targetType)
+ {
+ return (Class<T>)tryToLoadClassForName(name);
+ }
+
public static Class tryToLoadClassForName(String name)
{
try
Added: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/AbstractConfiguredValueResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/AbstractConfiguredValueResolver.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/AbstractConfiguredValueResolver.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/AbstractConfiguredValueResolver.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,95 @@
+/*
+ * 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.core.impl.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver;
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
+import org.apache.myfaces.extensions.cdi.core.api.ClassDeactivator;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.ServiceLoader;
+
+/**
+ * @author Gerhard Petracek
+ */
+public abstract class AbstractConfiguredValueResolver implements ConfiguredValueResolver
+{
+ private boolean deactivated = false;
+
+ private List instances = new ArrayList();
+ private List<String> configuredValues = new ArrayList<String>();
+
+ protected AbstractConfiguredValueResolver()
+ {
+ ServiceLoader<ClassDeactivator> serviceLoader =
+ ServiceLoader.load(ClassDeactivator.class, ClassUtils.getClassLoader(null));
+
+ for(ClassDeactivator currentInstance : serviceLoader)
+ {
+ if(currentInstance.getDeactivatedClasses().contains(getClass()))
+ {
+ this.deactivated = true;
+ break;
+ }
+ }
+ }
+
+ protected <T> void add(Class<T> targetType)
+ {
+ T instance = ClassUtils.tryToInstantiateClass(targetType);
+
+ if(instance != null)
+ {
+ instances.add(instance);
+ }
+ }
+
+ protected <T> void add(T value)
+ {
+ if(!String.class.isAssignableFrom(value.getClass()))
+ {
+ instances.add(value);
+ }
+ else
+ {
+ configuredValues.add((String)value);
+ }
+ }
+
+ protected <T> List<T> getConfiguredValues(Class<T> targetType)
+ {
+ if(this.instances.size() > 0 && this.configuredValues.size() > 0)
+ {
+ //TODO
+ throw new IllegalStateException("Mixed config found.");
+ }
+
+ if(!String.class.isAssignableFrom(targetType))
+ {
+ return this.instances;
+ }
+ return (List<T>)this.configuredValues;
+ }
+
+ public boolean isActivated()
+ {
+ return !deactivated;
+ }
+}
Added: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/LocalJndiResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/LocalJndiResolver.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/LocalJndiResolver.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/LocalJndiResolver.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,70 @@
+/*
+ * 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.core.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.util.JndiUtils;
+
+import javax.enterprise.inject.Typed;
+import java.util.List;
+import java.util.Collections;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Typed()
+@InvocationOrder(300)
+public class LocalJndiResolver extends AbstractConfiguredValueResolver
+{
+ private static final String BASE_NAME = "java:comp/env/myfaces/codi/";
+
+ public <K, T> List<T> resolveInstances(ConfiguredValueDescriptor<K, T> descriptor)
+ {
+ String key;
+ if(descriptor.getKey() instanceof String && ((String)descriptor.getKey()).startsWith("java:comp/env"))
+ {
+ key = (String)descriptor.getKey();
+ }
+ else
+ {
+ key = BASE_NAME + descriptor.getKey();
+ }
+
+ T resolvedValue = null;
+
+ try
+ {
+ resolvedValue = JndiUtils.lookup(key, descriptor.getTargetType());
+ }
+ catch (Exception e)
+ {
+ //do nothing it was just a try
+ }
+
+ if(resolvedValue == null)
+ {
+ return Collections.emptyList();
+ }
+
+ add(resolvedValue);
+
+ return getConfiguredValues(descriptor.getTargetType());
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/ServiceLoaderResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/ServiceLoaderResolver.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/ServiceLoaderResolver.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/ServiceLoaderResolver.java Sun Feb 13 18:45:03 2011
@@ -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.core.impl.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.InvocationOrder;
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueDescriptor;
+
+import javax.enterprise.inject.Typed;
+import java.util.List;
+import java.util.ServiceLoader;
+import java.util.ArrayList;
+import java.lang.reflect.Modifier;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Typed()
+@InvocationOrder(200)
+public class ServiceLoaderResolver extends AbstractConfiguredValueResolver
+{
+ public <K, T> List<T> resolveInstances(ConfiguredValueDescriptor<K, T> descriptor)
+ {
+ List<T> result = new ArrayList<T>();
+ Class targetType = descriptor.getTargetType();
+ if(Modifier.isAbstract(targetType.getModifiers()) || Modifier.isInterface(targetType.getModifiers()))
+ {
+ @SuppressWarnings({"unchecked"})
+ ServiceLoader<T> serviceLoader = ServiceLoader.load(targetType, ClassUtils.getClassLoader(null));
+
+ for(T currentInstance : serviceLoader)
+ {
+ result.add(currentInstance);
+ }
+ }
+ return result;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/SystemPropertyResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/SystemPropertyResolver.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/SystemPropertyResolver.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/config/SystemPropertyResolver.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,70 @@
+/*
+ * 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.core.impl.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.InvocationOrder;
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueDescriptor;
+
+import javax.enterprise.inject.Typed;
+import java.util.List;
+import java.util.Collections;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Typed()
+@InvocationOrder(100)
+public class SystemPropertyResolver extends AbstractConfiguredValueResolver
+{
+ private static final String BASE_NAME = "org.apache.myfaces.extensions.cdi.";
+
+ public <K, T> List<T> resolveInstances(ConfiguredValueDescriptor<K, T> descriptor)
+ {
+ String key = "" + descriptor.getKey();
+
+ if(!key.contains("."))
+ {
+ key = BASE_NAME + key;
+ }
+
+ String configuredValue = System.getProperty(key);
+
+ if(configuredValue == null)
+ {
+ return Collections.emptyList();
+ }
+
+ if(!String.class.isAssignableFrom(descriptor.getTargetType()))
+ {
+ Class<T> targetClass = ClassUtils.tryToLoadClassForName(configuredValue, descriptor.getTargetType());
+
+ if(targetClass != null)
+ {
+ add(targetClass);
+ }
+ }
+ else
+ {
+ add(configuredValue);
+ }
+
+ return getConfiguredValues(descriptor.getTargetType());
+ }
+}
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=1070277&r1=1070276&r2=1070277&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 Feb 13 18:45:03 2011
@@ -27,6 +27,7 @@ import javax.enterprise.context.Dependen
import javax.enterprise.inject.Default;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.Typed;
+import java.io.Serializable;
/**
* <p>Produces {@link ProjectStage} configurations.</p>
@@ -53,17 +54,9 @@ import javax.enterprise.inject.Typed;
* TODO move jsf specific parts
*/
@Typed()
-public class ProjectStageProducer
+public class ProjectStageProducer implements Serializable
{
- private final static String PROJECTSTAGE_PRODUCER_PROPERTY_KEY
- = "org.apache.myfaces.extensions.cdi.ProjectStageProducer";
-
- private static final String PROJECTSTAGE_PRODUCER_JNDI_NAME = "java:comp/env/myfaces-codi/ProjectStageProducer";
-
- private final static String PROJECTSTAGE_PROPERTY_KEY
- = "org.apache.myfaces.extensions.cdi.ProjectStage";
-
- private static final String PROJECTSTAGE_JNDI_NAME = "java:comp/env/myfaces-codi/ProjectStage";
+ private static final long serialVersionUID = -2987762608635612074L;
/**
* ProjectStageProducers must only be created by subclassing producers
@@ -106,6 +99,13 @@ public class ProjectStageProducer
return projectStage;
}
+ //just for testing
+ protected void reset()
+ {
+ projectStage = null;
+ projectStageProducer = null;
+ }
+
/**
* <p>This factory method should only get used if there is absolutly no way
* to get the current {@link ProjectStage} via @Inject.</p>
@@ -118,8 +118,7 @@ public class ProjectStageProducer
{
if (projectStageProducer == null)
{
- projectStageProducer = CodiUtils.lookupFromEnvironment(
- PROJECTSTAGE_PRODUCER_PROPERTY_KEY, PROJECTSTAGE_PRODUCER_JNDI_NAME, ProjectStageProducer.class);
+ projectStageProducer = CodiUtils.lookupFromEnvironment(ProjectStageProducer.class);
if(projectStageProducer == null)
{
@@ -169,7 +168,7 @@ public class ProjectStageProducer
protected ProjectStage resolveProjectStage()
{
String stageName = CodiUtils
- .lookupFromEnvironment(PROJECTSTAGE_PROPERTY_KEY, PROJECTSTAGE_JNDI_NAME, String.class);
+ .lookupFromEnvironment(ProjectStage.class.getSimpleName(), String.class); //we have to use a string here
if (stageName != null)
{
Added: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ArtifactCacheKey.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ArtifactCacheKey.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ArtifactCacheKey.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ArtifactCacheKey.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,84 @@
+/*
+ * 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.core.impl.util;
+
+import java.io.Serializable;
+
+/**
+ * @author Gerhard Petracek
+ */
+class ArtifactCacheKey<K extends Serializable>
+{
+ private final K key;
+ private final Class targetType;
+
+ ArtifactCacheKey(K key, Class targetType)
+ {
+ if(key == null)
+ {
+ //TODO
+ throw new IllegalStateException("Please provide a key for " + targetType);
+ }
+ if(targetType == null)
+ {
+ //TODO
+ throw new IllegalStateException("Please provide a targetType");
+ }
+
+ this.key = key;
+ this.targetType = targetType;
+ }
+
+ /*
+ * generated
+ */
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (!(o instanceof ArtifactCacheKey))
+ {
+ return false;
+ }
+
+ ArtifactCacheKey that = (ArtifactCacheKey) o;
+
+ if (!key.equals(that.key))
+ {
+ return false;
+ }
+ if (!targetType.equals(that.targetType))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = key.hashCode();
+ result = 31 * result + targetType.hashCode();
+ return result;
+ }
+}
Modified: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivation.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivation.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivation.java (original)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivation.java Sun Feb 13 18:45:03 2011
@@ -30,10 +30,6 @@ public class ClassDeactivation
{
private static Logger logger = Logger.getLogger(ClassDeactivation.class.getName());
- private static final String CLASS_DEACTIVATOR_PROPERTY_NAME = "org.apache.myfaces.extensions.cdi.ClassDeactivator";
-
- private static final String CLASS_DEACTIVATOR_JNDI_NAME = "java:comp/env/myfaces-codi/ClassDeactivator";
-
public static boolean isClassActivated(Class targetClass)
{
ClassDeactivator classDeactivator = ClassDeactivatorStorage.getClassDeactivator();
@@ -55,10 +51,8 @@ public class ClassDeactivation
private static ClassDeactivator getClassDeactivator()
{
- ClassDeactivator classDeactivator = CodiUtils
- .lookupFromEnvironment(CLASS_DEACTIVATOR_PROPERTY_NAME,
- CLASS_DEACTIVATOR_JNDI_NAME,
- ClassDeactivator.class);
+ ClassDeactivator classDeactivator =
+ CodiUtils.lookupFromEnvironment(ClassDeactivator.class, new ClassDeactivatorAggregator());
// use default deactivator
if (classDeactivator == null)
@@ -67,7 +61,7 @@ public class ClassDeactivation
}
else
{
- logger.info("used class deactivator: " + classDeactivator.getClass().getName());
+ logger.info("used class deactivator: " + classDeactivator.toString());
// display deactivated classes here once
// NOTE that isClassActivated() will be called many times for the same class
@@ -85,6 +79,8 @@ public class ClassDeactivation
{
return new AbstractClassDeactivator()
{
+ private static final long serialVersionUID = 3365575383802245760L;
+
protected void deactivateClasses()
{
//do nothing
Added: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivatorAggregator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivatorAggregator.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivatorAggregator.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ClassDeactivatorAggregator.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.core.impl.util;
+
+import org.apache.myfaces.extensions.cdi.core.api.Aggregatable;
+import org.apache.myfaces.extensions.cdi.core.api.ClassDeactivator;
+
+import javax.enterprise.inject.Typed;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Typed()
+class ClassDeactivatorAggregator implements Aggregatable<ClassDeactivator>, ClassDeactivator
+{
+ private static final long serialVersionUID = 5996031456559606240L;
+
+ private Set<Class> deactivatedClasses = new HashSet<Class>();
+
+ private String deactivators = "";
+
+ public void add(ClassDeactivator classDeactivator)
+ {
+ this.deactivatedClasses.addAll(classDeactivator.getDeactivatedClasses());
+
+ if(this.deactivators.length() > 0)
+ {
+ this.deactivators = this.deactivators + "\n" + classDeactivator.getClass().getName();
+ }
+ else
+ {
+ this.deactivators = classDeactivator.getClass().getName();
+ }
+ }
+
+ public ClassDeactivator create()
+ {
+ return this;
+ }
+
+ public Set<Class> getDeactivatedClasses()
+ {
+ return this.deactivatedClasses;
+ }
+
+ @Override
+ public String toString()
+ {
+ return this.deactivators;
+ }
+}
Modified: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/CodiUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/CodiUtils.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/CodiUtils.java (original)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/CodiUtils.java Sun Feb 13 18:45:03 2011
@@ -19,11 +19,11 @@
package org.apache.myfaces.extensions.cdi.core.impl.util;
import org.apache.myfaces.extensions.cdi.core.api.Advanced;
+import org.apache.myfaces.extensions.cdi.core.api.Aggregatable;
import org.apache.myfaces.extensions.cdi.core.api.config.CodiCoreConfig;
import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
import org.apache.myfaces.extensions.cdi.core.api.provider.BeanManagerProvider;
import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
-import static org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils.tryToInstantiateClassForName;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.AnnotatedType;
@@ -33,15 +33,16 @@ import javax.enterprise.inject.spi.Injec
import javax.enterprise.util.Nonbinding;
import java.io.IOException;
import java.io.InputStream;
+import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
+import java.util.List;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Set;
import java.util.Collections;
-import java.util.List;
import java.util.Properties;
-import java.util.Set;
+import java.util.Arrays;
/**
* This is a collection of a few useful static helper functions.
@@ -428,37 +429,49 @@ public class CodiUtils
return Collections.emptyList();
}
- public static <T> T lookupFromEnvironment(String systemPropertyName, String jndiName , Class<T> targetType)
+ public static <T extends Serializable> T lookupFromEnvironment(Class<T> targetType, Aggregatable<T>... aggregatable)
{
- String configuredValue = System.getProperty(systemPropertyName);
- if (configuredValue != null)
+ return lookupFromEnvironment(targetType.getSimpleName(), targetType, aggregatable);
+ }
+
+ public static <T extends Serializable> T lookupFromEnvironment(String key,
+ Class<T> targetType,
+ Aggregatable<T>... aggregatable)
+ {
+ List<T> results = ConfiguredArtifactUtils.getCachedArtifact(key, targetType);
+
+ if(results == null)
{
+ results = ConfiguredArtifactUtils.resolveFromEnvironment(key, targetType, aggregatable != null);
+
if(String.class.isAssignableFrom(targetType))
{
- return (T)configuredValue;
+ ConfiguredArtifactUtils.processConfiguredArtifact(key, (List<String>)results);
+ }
+ else
+ {
+ ConfiguredArtifactUtils.processFoundArtifact(key, targetType, results);
}
- return tryToInstantiateClassForName(configuredValue, targetType);
}
- try
+ if(results.isEmpty())
{
- configuredValue = JndiUtils.lookup(jndiName, String.class);
- }
- catch (RuntimeException jndiException)
- {
- // noop - lookup did not work
+ return null;
}
- if (configuredValue != null)
+ if(aggregatable != null && aggregatable.length > 0)
{
- if(String.class.isAssignableFrom(targetType))
+ Aggregatable<T> firstAggregatable = aggregatable[0]; //TODO
+ for(T currentEntry : results)
{
- return (T)configuredValue;
+ firstAggregatable.add(currentEntry);
}
- return tryToInstantiateClassForName(configuredValue, targetType);
+ return firstAggregatable.create();
+ }
+ else
+ {
+ return results.iterator().next();
}
-
- return null;
}
public static boolean isCdiInitialized()
Added: myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ConfiguredArtifactUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ConfiguredArtifactUtils.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ConfiguredArtifactUtils.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/util/ConfiguredArtifactUtils.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,232 @@
+/*
+ * 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.core.impl.util;
+
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver;
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueDescriptor;
+import org.apache.myfaces.extensions.cdi.core.impl.InvocationOrderComparator;
+
+import javax.enterprise.inject.Typed;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.ServiceLoader;
+import java.util.Comparator;
+import java.util.concurrent.ConcurrentHashMap;
+import java.io.Serializable;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Typed()
+public class ConfiguredArtifactUtils
+{
+ private static Map<ClassLoader, Map<ArtifactCacheKey<String>, Set<Serializable>>> apiToImplCache
+ = new ConcurrentHashMap<ClassLoader, Map<ArtifactCacheKey<String>, Set<Serializable>>>();
+
+ private static Map<ClassLoader, Map<String, Set<String>>> configuredValueCache
+ = new ConcurrentHashMap<ClassLoader, Map<String, Set<String>>>();
+
+ protected ConfiguredArtifactUtils()
+ {
+ }
+
+ protected void reset()
+ {
+ apiToImplCache.clear();
+ configuredValueCache.clear();
+ }
+
+ static <T extends Serializable> List<T> getCachedArtifact(String key, Class<T> targetClass)
+ {
+ ClassLoader classLoader = ClassUtils.getClassLoader(null);
+ if(String.class.isAssignableFrom(targetClass))
+ {
+ Map<String, Set<String>> cachedValueMap = configuredValueCache.get(classLoader);
+
+ if(cachedValueMap != null)
+ {
+ List<String> result = new ArrayList<String>();
+ result.addAll(cachedValueMap.get(key));
+ return (List<T>)result;
+ }
+ return null;
+ }
+
+ Map<ArtifactCacheKey<String>, Set<Serializable>> artifactCache = apiToImplCache.get(classLoader);
+
+ if(artifactCache == null)
+ {
+ return null;
+ }
+
+ List<T> result = new ArrayList<T>();
+
+ Set<T> cachedInstances = (Set<T>)artifactCache.get(new ArtifactCacheKey<String>(key, targetClass));
+
+ if(cachedInstances == null)
+ {
+ return null;
+ }
+ for(T currentClass : cachedInstances)
+ {
+ result.add(currentClass);
+ }
+ Collections.sort(result, new InvocationOrderComparator<T>());
+ return result;
+ }
+
+ static <T> List<T> resolveFromEnvironment(final String key,
+ final Class<T> targetType,
+ boolean supportOfMultipleArtifacts)
+ {
+ List<T> results = new ArrayList<T>();
+ List<T> resolverResult = null;
+
+ List<ConfiguredValueResolver> resolvers = getConfiguredValueResolvers();
+
+ for(ConfiguredValueResolver configuredValueResolver : resolvers)
+ {
+ if(configuredValueResolver.isActivated())
+ {
+ resolverResult = configuredValueResolver.resolveInstances(new ConfiguredValueDescriptor<String, T>()
+ {
+ public String getKey()
+ {
+ return key;
+ }
+
+ public Class<T> getTargetType()
+ {
+ return targetType;
+ }
+ });
+ }
+
+ if(resolverResult != null && !resolverResult.isEmpty())
+ {
+ results.addAll(resolverResult);
+ }
+ }
+
+ checkArtifacts(targetType, results, supportOfMultipleArtifacts);
+
+ return results;
+ }
+
+ private static List<ConfiguredValueResolver> getConfiguredValueResolvers()
+ {
+ ServiceLoader<ConfiguredValueResolver> configuredValueResolvers =
+ ServiceLoader.load(ConfiguredValueResolver.class, ClassUtils.getClassLoader(null));
+
+ List<ConfiguredValueResolver> resolvers = new ArrayList<ConfiguredValueResolver>();
+ Comparator<ConfiguredValueResolver> comparator = new InvocationOrderComparator<ConfiguredValueResolver>();
+
+ //TODO cache the resolvers
+ for(ConfiguredValueResolver currentResolver : configuredValueResolvers)
+ {
+ resolvers.add(currentResolver);
+ }
+
+ Collections.sort(resolvers, comparator);
+ return resolvers;
+ }
+
+ static void processConfiguredArtifact(String key, List<String> results)
+ {
+ processFoundArtifact(key, String.class, results);
+ }
+
+ static <T extends Serializable> void processFoundArtifact(String key, Class<T> targetType, List<T> artifacts)
+ {
+ for(T currentArtifact : artifacts)
+ {
+ cacheArtifact(key, currentArtifact);
+ }
+ }
+
+ private static <T extends Serializable> void cacheArtifact(String key, T artifact)
+ {
+ ClassLoader classLoader = ClassUtils.getClassLoader(null);
+
+ if(String.class.isAssignableFrom(artifact.getClass()))
+ {
+ Map<String, Set<String>> configuredValueMapping = configuredValueCache.get(classLoader);
+
+ if(configuredValueMapping == null)
+ {
+ configuredValueMapping = new HashMap<String, Set<String>>();
+ configuredValueCache.put(classLoader, configuredValueMapping);
+ }
+
+ Set<String> configuredValues = configuredValueMapping.get(key);
+
+ if(configuredValues == null)
+ {
+ configuredValues = new HashSet<String>();
+ configuredValueMapping.put(key, configuredValues);
+ }
+ configuredValues.add((String)artifact);
+ }
+ else
+ {
+ Map<ArtifactCacheKey<String>, Set<Serializable>> configuredValueMapping = apiToImplCache.get(classLoader);
+
+ if(configuredValueMapping == null)
+ {
+ configuredValueMapping = new HashMap<ArtifactCacheKey<String>, Set<Serializable>>();
+ apiToImplCache.put(classLoader, configuredValueMapping);
+ }
+
+ ArtifactCacheKey<String> cacheKey = new ArtifactCacheKey<String>(key, artifact.getClass());
+ Set<Serializable> configuredValues = configuredValueMapping.get(cacheKey);
+
+ if(configuredValues == null)
+ {
+ configuredValues = new HashSet<Serializable>();
+ configuredValueMapping.put(cacheKey, configuredValues);
+ }
+ configuredValues.add(artifact);
+ }
+ }
+
+ private static <T> void checkArtifacts(Class<T> targetType, List<T> results, boolean supportOfMultipleArtifacts)
+ {
+ if(!supportOfMultipleArtifacts && results.size() > 1)
+ {
+ //TODO move to exception utils
+ StringBuilder message = new StringBuilder("Multiple implementations for ");
+ message.append(targetType.getName());
+ message.append(" aren't allowed. Found implementations: \n");
+
+ for(T artifacts : results)
+ {
+ message.append(artifacts.getClass().getName());
+ message.append("\n");
+ }
+
+ throw new IllegalStateException(message.toString());
+ }
+ }
+}
Added: myfaces/extensions/cdi/trunk/core/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/core/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/main/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver Sun Feb 13 18:45:03 2011
@@ -0,0 +1,3 @@
+org.apache.myfaces.extensions.cdi.core.impl.config.SystemPropertyResolver
+org.apache.myfaces.extensions.cdi.core.impl.config.ServiceLoaderResolver
+org.apache.myfaces.extensions.cdi.core.impl.config.LocalJndiResolver
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/RefreshAttribute.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/RefreshAttribute.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/RefreshAttribute.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/RefreshAttribute.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,36 @@
+/*
+ * 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.core.test;
+
+public class RefreshAttribute implements Cloneable
+{
+
+ public RefreshAttribute getClone()
+ {
+ try
+ {
+ return (RefreshAttribute) clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ //do nothing
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/ConfigTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/ConfigTest.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/ConfigTest.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/ConfigTest.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,154 @@
+/*
+ * 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.core.test.impl.config;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.AfterMethod;
+import static org.testng.Assert.*;
+import org.apache.myfaces.extensions.cdi.core.impl.projectstage.ProjectStageProducer;
+import org.apache.myfaces.extensions.cdi.core.impl.util.CodiUtils;
+import org.apache.myfaces.extensions.cdi.core.impl.util.ConfiguredArtifactUtils;
+import org.apache.myfaces.extensions.cdi.core.api.projectstage.ProjectStage;
+import org.apache.myfaces.extensions.cdi.core.api.ClassDeactivator;
+
+import java.util.Date;
+
+public class ConfigTest
+{
+ @BeforeMethod
+ private void beforeTest()
+ {
+ reset();
+ }
+
+ @AfterMethod
+ private void afterTest()
+ {
+ reset();
+ }
+
+ protected void reset()
+ {
+ new ConfiguredArtifactUtils() {
+ @Override
+ public void reset()
+ {
+ super.reset();
+ }
+ }.reset();
+
+ new ProjectStageProducer() {
+ private static final long serialVersionUID = -2656209286979856460L;
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ }
+ }.reset();
+ System.setProperty("org.apache.myfaces.extensions.cdi.ProjectStage", "Production");
+ System.setProperty("org.apache.myfaces.extensions.cdi.CustomValue", "");
+ System.setProperty("ext.test.CustomValue", "");
+ }
+
+ @Test
+ public void testConfiguredValueViaSystemPropertyConfig()
+ {
+ assertEquals(ProjectStageProducer.getInstance().getProjectStage(), ProjectStage.Production);
+
+ reset();
+
+ System.setProperty("org.apache.myfaces.extensions.cdi.ProjectStage", "Development");
+
+ assertEquals(ProjectStageProducer.getInstance().getProjectStage(), ProjectStage.Development);
+ }
+
+ @Test
+ public void testConfiguredClassViaSystemPropertyConfig()
+ {
+ assertNull(CodiUtils.lookupFromEnvironment(ClassDeactivator.class));
+
+ System.setProperty("org.apache.myfaces.extensions.cdi.ClassDeactivator", TestClassDeactivator.class.getName());
+
+ assertEquals(CodiUtils.lookupFromEnvironment(ClassDeactivator.class).getDeactivatedClasses().iterator().next(), TestClassDeactivator.class);
+ }
+
+ @Test
+ public void testCustomConfiguredValueResolver()
+ {
+ assertEquals(ProjectStageProducer.getInstance().getProjectStage(), ProjectStage.Production);
+ assertEquals(TestConfiguredValueResolver.isCalled(), false);
+
+ TestConfiguredValueResolver.setActivated(true);
+
+ reset();
+
+ assertEquals(ProjectStageProducer.getInstance().getProjectStage(), ProjectStage.Production);
+ assertEquals(TestConfiguredValueResolver.isCalled(), true);
+
+ TestConfiguredValueResolver.setActivated(false);
+ }
+
+ @Test
+ public void testCustomConfiguredValue()
+ {
+ assertEquals(CodiUtils.lookupFromEnvironment("CustomValue", String.class), "");
+
+ reset();
+
+ System.setProperty("org.apache.myfaces.extensions.cdi.CustomValue", "test");
+
+ assertEquals(CodiUtils.lookupFromEnvironment("CustomValue", String.class), "test");
+ }
+
+ @Test
+ public void testCustomConfiguredFormat()
+ {
+ assertEquals(CodiUtils.lookupFromEnvironment("ext.test.CustomValue", String.class), "");
+
+ reset();
+
+ System.setProperty("ext.test.CustomValue", "test");
+
+ assertEquals(CodiUtils.lookupFromEnvironment("ext.test.CustomValue", String.class), "test");
+ }
+
+ @Test
+ public void testCustomArtifact()
+ {
+ assertEquals(CodiUtils.lookupFromEnvironment(TestArtifact.class), null);
+
+ reset();
+
+ System.setProperty("org.apache.myfaces.extensions.cdi.TestArtifact", TestArtifact.class.getName());
+
+ assertEquals(CodiUtils.lookupFromEnvironment(TestArtifact.class).getClass().getName(), TestArtifact.class.getName());
+
+ //test cache
+ Date created = CodiUtils.lookupFromEnvironment(TestArtifact.class).getCreated();
+ assertEquals(CodiUtils.lookupFromEnvironment(TestArtifact.class).getCreated(), created);
+ }
+
+ @Test
+ public void testServiceLoaderConfig()
+ {
+ assertEquals(CodiUtils.lookupFromEnvironment(TestInterface.class).getValue(), "TestImpl");
+ }
+}
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestArtifact.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestArtifact.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestArtifact.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestArtifact.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,49 @@
+/*
+ * 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.core.test.impl.config;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class TestArtifact implements Serializable
+{
+ private static final long serialVersionUID = -8150942173999559913L;
+
+ private Date created = new Date();
+
+ Date getCreated()
+ {
+ return created;
+ }
+
+ @SuppressWarnings({"EqualsWhichDoesntCheckParameterClass"})
+ @Override
+ public boolean equals(Object o)
+ {
+ //just for testing the cache
+ return this == o;
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return created.hashCode();
+ }
+}
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestClassDeactivator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestClassDeactivator.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestClassDeactivator.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestClassDeactivator.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.core.test.impl.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.AbstractClassDeactivator;
+
+public class TestClassDeactivator extends AbstractClassDeactivator
+{
+ private static final long serialVersionUID = 7799046096147501268L;
+
+ protected void deactivateClasses()
+ {
+ addDeactivatedClass(TestClassDeactivator.class);
+ }
+}
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestConfiguredValueResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestConfiguredValueResolver.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestConfiguredValueResolver.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestConfiguredValueResolver.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.core.test.impl.config;
+
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueDescriptor;
+import org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver;
+
+import java.util.List;
+import java.util.Collections;
+
+public class TestConfiguredValueResolver implements ConfiguredValueResolver
+{
+ private static boolean called = false;
+ private static boolean activated = false;
+
+ public <K, T> List<T> resolveInstances(ConfiguredValueDescriptor<K, T> descriptor)
+ {
+ if(activated)
+ {
+ called = true;
+ }
+ return Collections.emptyList();
+ }
+
+ static boolean isCalled()
+ {
+ return called;
+ }
+
+ static void setActivated(boolean newValue)
+ {
+ activated = newValue;
+ }
+
+ public boolean isActivated()
+ {
+ return activated;
+ }
+}
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestImpl.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestImpl.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestImpl.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestImpl.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.core.test.impl.config;
+
+public class TestImpl implements TestInterface
+{
+ private static final long serialVersionUID = -9190258825414992052L;
+
+ public String getValue()
+ {
+ return getClass().getSimpleName();
+ }
+}
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestInterface.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestInterface.java?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestInterface.java (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/java/org/apache/myfaces/extensions/cdi/core/test/impl/config/TestInterface.java Sun Feb 13 18:45:03 2011
@@ -0,0 +1,26 @@
+/*
+ * 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.core.test.impl.config;
+
+import java.io.Serializable;
+
+public interface TestInterface extends Serializable
+{
+ String getValue();
+}
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.api.config.ConfiguredValueResolver Sun Feb 13 18:45:03 2011
@@ -0,0 +1 @@
+org.apache.myfaces.extensions.cdi.core.test.impl.config.TestConfiguredValueResolver
\ No newline at end of file
Added: myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.test.impl.config.TestInterface
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.test.impl.config.TestInterface?rev=1070277&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.test.impl.config.TestInterface (added)
+++ myfaces/extensions/cdi/trunk/core/impl/src/test/resources/META-INF/services/org.apache.myfaces.extensions.cdi.core.test.impl.config.TestInterface Sun Feb 13 18:45:03 2011
@@ -0,0 +1 @@
+org.apache.myfaces.extensions.cdi.core.test.impl.config.TestImpl
\ No newline at end of file
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigExtension.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/view/ViewConfigExtension.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigExtension.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ViewConfigExtension.java Sun Feb 13 18:45:03 2011
@@ -43,12 +43,6 @@ import java.lang.reflect.Modifier;
@SuppressWarnings({"UnusedDeclaration"})
public class ViewConfigExtension implements Extension, Deactivatable
{
- private static final String VIEW_CONFIG_EXTRACTOR_PROPERTY_NAME =
- "org.apache.myfaces.extensions.cdi.ViewConfigExtractor";
-
- private static final String VIEW_CONFIG_EXTRACTOR_JNDI_NAME =
- "java:comp/env/myfaces-codi/ViewConfigExtractor";
-
public void processPageDefinitions(@Observes ProcessAnnotatedType processAnnotatedType)
{
if(!isActivated())
@@ -235,9 +229,7 @@ public class ViewConfigExtension impleme
private ViewConfigExtractor getViewConfigExtractor()
{
- ViewConfigExtractor viewConfigExtractor = CodiUtils.lookupFromEnvironment(VIEW_CONFIG_EXTRACTOR_PROPERTY_NAME,
- VIEW_CONFIG_EXTRACTOR_JNDI_NAME,
- ViewConfigExtractor.class);
+ ViewConfigExtractor viewConfigExtractor = CodiUtils.lookupFromEnvironment(ViewConfigExtractor.class);
if(viewConfigExtractor == null)
{
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigExtractor.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/view/spi/ViewConfigExtractor.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigExtractor.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/spi/ViewConfigExtractor.java Sun Feb 13 18:45:03 2011
@@ -20,10 +20,12 @@ package org.apache.myfaces.extensions.cd
import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import java.io.Serializable;
+
/**
* @author Gerhard Petracek
*/
-public interface ViewConfigExtractor
+public interface ViewConfigExtractor extends Serializable
{
ViewConfigEntry extractViewConfig(Class<? extends ViewConfig> viewDefinitionClass);
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/projectstage/JsfProjectStageProducer.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/projectstage/JsfProjectStageProducer.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/projectstage/JsfProjectStageProducer.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/projectstage/JsfProjectStageProducer.java Sun Feb 13 18:45:03 2011
@@ -30,6 +30,8 @@ import javax.enterprise.inject.Typed;
@Typed()
public class JsfProjectStageProducer extends ProjectStageProducer
{
+ private static final long serialVersionUID = 2378537865206165557L;
+
/** JNDI path for the ProjectStage */
private final static String PROJECT_STAGE_JNDI_NAME = "java:comp/env/jsf/ProjectStage";
@@ -46,8 +48,14 @@ public class JsfProjectStageProducer ext
return projectStage;
}
- String stageName = CodiUtils
- .lookupFromEnvironment(JSF_PROJECT_STAGE_SYSTEM_PROPERTY_NAME, PROJECT_STAGE_JNDI_NAME, String.class);
+ String stageName;
+
+ stageName = CodiUtils.lookupFromEnvironment(JSF_PROJECT_STAGE_SYSTEM_PROPERTY_NAME, String.class);
+
+ if(stageName == null)
+ {
+ CodiUtils.lookupFromEnvironment(PROJECT_STAGE_JNDI_NAME, String.class);
+ }
if (stageName != null)
{
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/CodiRenderKitFactory.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/scope/conversation/CodiRenderKitFactory.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/CodiRenderKitFactory.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/CodiRenderKitFactory.java Sun Feb 13 18:45:03 2011
@@ -36,11 +36,6 @@ import java.util.Iterator;
*/
public class CodiRenderKitFactory extends RenderKitFactory implements Deactivatable
{
- public static final String RENDER_KIT_WRAPPER_FACTORY_PROPERTY_NAME =
- "org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.RenderKitWrapperFactory";
- public static final String RENDER_KIT_WRAPPER_FACTORY_JNDI_NAME =
- "java:comp/env/myfaces-codi/RenderKitWrapperFactory";
-
private RenderKitFactory wrapped;
private RenderKitWrapperFactory renderKitWrapperFactory;
@@ -54,9 +49,7 @@ public class CodiRenderKitFactory extend
if(!this.deactivated)
{
- this.renderKitWrapperFactory = CodiUtils.lookupFromEnvironment(RENDER_KIT_WRAPPER_FACTORY_PROPERTY_NAME,
- RENDER_KIT_WRAPPER_FACTORY_JNDI_NAME,
- RenderKitWrapperFactory.class);
+ this.renderKitWrapperFactory = CodiUtils.lookupFromEnvironment(RenderKitWrapperFactory.class);
}
}
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/spi/RenderKitWrapperFactory.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/scope/conversation/spi/RenderKitWrapperFactory.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/spi/RenderKitWrapperFactory.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/spi/RenderKitWrapperFactory.java Sun Feb 13 18:45:03 2011
@@ -19,6 +19,7 @@
package org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi;
import javax.faces.render.RenderKit;
+import java.io.Serializable;
/**
* Component libs like Trinidad use very special renderkits.
@@ -26,7 +27,7 @@ import javax.faces.render.RenderKit;
*
* @author Gerhard Petracek
*/
-public interface RenderKitWrapperFactory
+public interface RenderKitWrapperFactory extends Serializable
{
/**
* Creates a {@link RenderKit} based on the currently active {@link RenderKit}
Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/CodiRenderKitFactory.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/CodiRenderKitFactory.java?rev=1070277&r1=1070276&r2=1070277&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/CodiRenderKitFactory.java (original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf20-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf2/impl/scope/conversation/CodiRenderKitFactory.java Sun Feb 13 18:45:03 2011
@@ -52,12 +52,7 @@ public class CodiRenderKitFactory extend
if(!this.deactivated)
{
- this.renderKitWrapperFactory = CodiUtils.lookupFromEnvironment(
- org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.CodiRenderKitFactory
- .RENDER_KIT_WRAPPER_FACTORY_PROPERTY_NAME,
- org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.CodiRenderKitFactory
- .RENDER_KIT_WRAPPER_FACTORY_JNDI_NAME,
- RenderKitWrapperFactory.class);
+ this.renderKitWrapperFactory = CodiUtils.lookupFromEnvironment(RenderKitWrapperFactory.class);
}
}