aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rotty3...@apache.org
Subject svn commit: r1793847 [1/3] - in /aries/trunk/cdi: cdi-extender/ cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/ cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ cdi-extender/src/main/java/org/apache/aries/cdi...
Date Thu, 04 May 2017 18:42:00 GMT
Author: rotty3000
Date: Thu May  4 18:41:59 2017
New Revision: 1793847

URL: http://svn.apache.org/viewvc?rev=1793847&view=rev
Log:
[CDI] major refactor

Signed-off-by: Raymond Augé <rotty3000@apache.org>

Added:
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ConfigurationBean.java
      - copied, changed from r1792762, aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BootstrapContainer.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationManagedService.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationResolveAction.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Entry.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/literal/ConfigurationLiteral.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/ConfigurationInjectionPoint.java
      - copied, changed from r1792762, aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/ReferenceInjectionPoint.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/util/Conversions.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/util/PropertyType.java
    aries/trunk/cdi/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/model/MapsTest.java
    aries/trunk/cdi/cdi-itests/bnd/tb5-beans.xml
    aries/trunk/cdi/cdi-itests/bnd/tb5.bnd
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_Optional.java
      - copied, changed from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceCardinality0Bean.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceProperties.java
      - copied, changed from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstancePropertiesBean.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceReference.java
      - copied, changed from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceServiceReferenceBean.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/Config.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanB.java
      - copied, changed from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/Config.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/ConfigurationBeanC.java
      - copied, changed from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java
Removed:
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/literal/ServicePropertyLiteral.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/PropertyModel.java
    aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiObjectFactory.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceBean.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceCardinality0Bean.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceOrderBean.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstancePropertiesBean.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceServiceReferenceBean.java
Modified:
    aries/trunk/cdi/cdi-extender/bnd.bnd
    aries/trunk/cdi/cdi-extender/pom.xml
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/Activator.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/BundleContextBean.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/command/CdiCommand.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BindType.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerService.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerState.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationDependency.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationExtension.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ExtensionDependency.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Configuration.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Extension.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Init.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Publish.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Reference.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ReferenceDependency.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ServiceDeclaration.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/literal/AnyLiteral.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/literal/ReferenceLiteral.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/literal/ServiceLiteral.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/AbstractModel.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/AbstractModelBuilder.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/BeansModelBuilder.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/ConfigurationModel.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/Constants.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/OSGiBeansHandler.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/ReferenceInjectionPoint.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/ReferenceModel.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/ServiceModel.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/model/XmlSchema.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/util/Maps.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/util/Reflection.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/util/Sets.java
    aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/util/Strings.java
    aries/trunk/cdi/cdi-extender/src/main/resources/META-INF/cdi.xsd
    aries/trunk/cdi/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/model/ModelTest.java
    aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-configuration.xml
    aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-only.xml
    aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-references.xml
    aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-services.xml
    aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/Activator.java
    aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtension.java
    aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtensionFactory.java
    aries/trunk/cdi/cdi-itests/bnd.bnd
    aries/trunk/cdi/cdi-itests/bnd/basic-beans.xml
    aries/trunk/cdi/cdi-itests/bnd/tb1-beans.xml
    aries/trunk/cdi/cdi-itests/bnd/tb2-beans.xml
    aries/trunk/cdi/cdi-itests/bnd/tb3-beans.xml
    aries/trunk/cdi/cdi-itests/bnd/tb4-beans.xml
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/BeanWithReference.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/ServiceWithProperties.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/CdiBeanTests.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/ConfigurationTests.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/JndiExtensionTests.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/components/ServiceBundleScope.java
    aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java

Modified: aries/trunk/cdi/cdi-extender/bnd.bnd
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/bnd.bnd?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/bnd.bnd (original)
+++ aries/trunk/cdi/cdi-extender/bnd.bnd Thu May  4 18:41:59 2017
@@ -1,12 +1,12 @@
 Bundle-Activator: org.apache.aries.cdi.container.internal.Activator
 Conditional-Package: \
+	org.apache.felix.converter.dto,\
 	org.apache.felix.converter.impl,\
 	org.apache.felix.utils.extender,\
 	org.osgi.util.converter,\
 	org.osgi.util.function
 Export-Package: \
 	org.apache.aries.cdi.provider
-#Import-Package: javax.el, javax.interceptor, *
 Provide-Capability: \
 	osgi.extender; \
 		osgi.extender='osgi.cdi'; \

Modified: aries/trunk/cdi/cdi-extender/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/pom.xml?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/pom.xml (original)
+++ aries/trunk/cdi/cdi-extender/pom.xml Thu May  4 18:41:59 2017
@@ -62,6 +62,11 @@
 			</exclusions>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-annotation_1.2_spec</artifactId>
+			<version>1.0</version>
+		</dependency>
+		<dependency>
 			<groupId>org.jboss.weld</groupId>
 			<artifactId>weld-osgi-bundle</artifactId>
 			<version>2.4.2.Final</version>
@@ -114,6 +119,12 @@
 			<artifactId>slf4j-api</artifactId>
 			<version>1.7.0</version>
 		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.12</version>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 
 </project>

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/Activator.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/Activator.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/Activator.java Thu May  4 18:41:59 2017
@@ -15,7 +15,7 @@
 package org.apache.aries.cdi.container.internal;
 
 import static org.osgi.namespace.extender.ExtenderNamespace.EXTENDER_NAMESPACE;
-import static org.osgi.service.cdi.CdiExtenderConstants.CDI_EXTENDER;
+import static org.osgi.service.cdi.CdiConstants.CDI_CAPABILITY_NAME;
 
 import java.util.Comparator;
 import java.util.Dictionary;
@@ -128,7 +128,7 @@ public class Activator extends AbstractE
 			Map<String, Object> attributes = bundleWire.getCapability().getAttributes();
 
 			if (attributes.containsKey(EXTENDER_NAMESPACE) &&
-				attributes.get(EXTENDER_NAMESPACE).equals(CDI_EXTENDER)) {
+				attributes.get(EXTENDER_NAMESPACE).equals(CDI_CAPABILITY_NAME)) {
 
 				Bundle providerWiringBundle = bundleWire.getProviderWiring().getBundle();
 

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/BundleContextBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/BundleContextBean.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/BundleContextBean.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/BundleContextBean.java Thu May  4 18:41:59 2017
@@ -56,7 +56,7 @@ public class BundleContextBean implement
 
 	@Override
 	public String getName() {
-		return "BundleContext";
+		return "bundleContext";
 	}
 
 	@Override
@@ -89,6 +89,11 @@ public class BundleContextBean implement
 		return false;
 	}
 
+	@Override
+	public String toString() {
+		return "BundleContextBean[bundleContext]";
+	}
+
 	private static final Set<Annotation> DEFAULT_QUALIFIERS = Sets.hashSet(
 		DefaultLiteral.INSTANCE, AnyLiteral.INSTANCE);
 	private static final Set<Type> TYPES = Sets.immutableHashSet(BundleContext.class, Object.class);

Copied: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ConfigurationBean.java (from r1792762, aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java)
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ConfigurationBean.java?p2=aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ConfigurationBean.java&p1=aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java&r1=1792762&r2=1793847&rev=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ConfigurationBean.java Thu May  4 18:41:59 2017
@@ -18,8 +18,8 @@ import static org.apache.aries.cdi.conta
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.util.AbstractMap;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -29,45 +29,35 @@ import javax.enterprise.context.spi.Crea
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Named;
 
-import org.apache.aries.cdi.container.internal.container.BindType;
+import org.apache.aries.cdi.container.internal.container.ConfigurationDependency;
 import org.apache.aries.cdi.container.internal.literal.AnyLiteral;
 import org.apache.aries.cdi.container.internal.literal.DefaultLiteral;
+import org.apache.aries.cdi.container.internal.util.Conversions;
 import org.apache.aries.cdi.container.internal.util.Sets;
 import org.jboss.weld.injection.CurrentInjectionPoint;
 import org.jboss.weld.injection.EmptyInjectionPoint;
 import org.jboss.weld.manager.BeanManagerImpl;
 import org.jboss.weld.util.Decorators;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceObjects;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ReferenceBean implements Bean<Object> {
-
-	public ReferenceBean(
-		BeanManagerImpl beanManagerImpl, BundleContext bundleContext, Type injectionPointType, Class<?> beanClass,
-		BindType bindType, ServiceReference<?> serviceReference) {
 
-		_beanManagerImpl = beanManagerImpl;
-		_bundleContext = bundleContext;
+public class ConfigurationBean implements Bean<Object> {
 
-		_typesForMatchingBeansToInjectionPoints = Sets.immutableHashSet(injectionPointType, Object.class);
-		_beanClass = beanClass;
-		_bindType = bindType;
-		_serviceReference = serviceReference;
+	public ConfigurationBean(
+		ConfigurationDependency configurationDependency, BeanManagerImpl beanManagerImpl, Type injectionPointType,
+		Set<Annotation> qualifiers) {
 
+		_configurationDependency = configurationDependency;
+		_beanManagerImpl = beanManagerImpl;
+		_typesForMatchingBeansToInjectionPoints = Sets.immutableHashSet(injectionPointType, Object.class);
 		_currentInjectionPoint = _beanManagerImpl.getServices().get(CurrentInjectionPoint.class);
-		_qualifiers = Sets.hashSet(DefaultLiteral.INSTANCE, AnyLiteral.INSTANCE);
-	}
+		_qualifiers = Sets.hashSet(qualifiers, DefaultLiteral.INSTANCE, AnyLiteral.INSTANCE);
 
-	public void addQualifier(Annotation annotation) {
-		_qualifiers.add(annotation);
-	}
-
-	public void addQualifiers(Set<Annotation> qualifiers) {
-		_qualifiers.addAll(qualifiers);
+		for (Annotation qualifier : _qualifiers) {
+			if (qualifier.annotationType().equals(Named.class)) {
+				_name = ((Named)qualifier).value();
+			}
+		}
 	}
 
 	@Override
@@ -76,29 +66,12 @@ public class ReferenceBean implements Be
 	}
 
 	@Override
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public void destroy(Object instance, CreationalContext creationalContext) {
-		if (_serviceObjects == null) {
-			return;
-		}
-
-		try {
-			_serviceObjects.ungetService(instance);
-		}
-		catch (Throwable t) {
-			if (_log.isWarnEnabled()) {
-				_log.warn("CDIe - UngetService resulted in error", t);
-			}
-		}
+	public void destroy(Object arg0, CreationalContext<Object> arg1) {
 	}
 
 	@Override
 	public Class<?> getBeanClass() {
-		return _beanClass;
-	}
-
-	public BindType getBindType() {
-		return _bindType;
+		return _configurationDependency.getBeanClass();
 	}
 
 	@Override
@@ -108,7 +81,7 @@ public class ReferenceBean implements Be
 
 	@Override
 	public String getName() {
-		return toString() + "#" + System.identityHashCode(this);
+		return _name;
 	}
 
 	@Override
@@ -143,13 +116,25 @@ public class ReferenceBean implements Be
 
 	@Override
 	public String toString() {
-		return "ReferenceBean(" + _serviceReference + ")";
+		return "ConfigurationBean[" + _currentInjectionPoint + "]";
 	}
 
 	protected <T> T create0(CreationalContext<T> creationalContext) {
+		Map<String, Object> map = new AbstractMap<String, Object>() {
+
+			@Override
+			public Set<java.util.Map.Entry<String, Object>> entrySet() {
+				return _configurationDependency.getConfiguration().entrySet();
+			}
+
+		};
+
+		T instance = cast(Conversions.c().convert(map).to(_configurationDependency.getBeanClass()));
 		InjectionPoint ip = getInjectionPoint(_currentInjectionPoint);
+		if (ip == null) {
+			return instance;
+		}
 		List<Decorator<?>> decorators = getDecorators(ip);
-		T instance = cast(getServiceImpl());
 		if (decorators.isEmpty()) {
 			return instance;
 		}
@@ -166,38 +151,11 @@ public class ReferenceBean implements Be
 		return EmptyInjectionPoint.INSTANCE.equals(ip) ? null : ip;
 	}
 
-	protected Object getServiceImpl() {
-		if (ServiceReference.class.equals(_beanClass)) {
-			return _serviceReference;
-		}
-		else if (Map.class.equals(_beanClass)) {
-			Map<String, Object> properties = new HashMap<>();
-
-			for (String key : _serviceReference.getPropertyKeys()) {
-				properties.put(key, _serviceReference.getProperty(key));
-			}
-
-			return properties;
-		}
-
-		if (_serviceObjects == null) {
-			_serviceObjects = _bundleContext.getServiceObjects(_serviceReference);
-		}
-
-		return _serviceObjects.getService();
-	}
-
-	private static final Logger _log = LoggerFactory.getLogger(ReferenceBean.class);
-
-	private final Class<?> _beanClass;
-	private final BindType _bindType;
-	private final BundleContext _bundleContext;
-	private final CurrentInjectionPoint _currentInjectionPoint;
 	private final BeanManagerImpl _beanManagerImpl;
+	private final ConfigurationDependency _configurationDependency;
+	private final CurrentInjectionPoint _currentInjectionPoint;
+	private String _name;
 	private final Set<Annotation> _qualifiers;
-	@SuppressWarnings("rawtypes")
-	private volatile ServiceObjects _serviceObjects;
-	private final ServiceReference<?> _serviceReference;
 	private final Set<Type> _typesForMatchingBeansToInjectionPoints;
 
-}
\ No newline at end of file
+}

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/bean/ReferenceBean.java Thu May  4 18:41:59 2017
@@ -29,6 +29,7 @@ import javax.enterprise.context.spi.Crea
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Named;
 
 import org.apache.aries.cdi.container.internal.container.BindType;
 import org.apache.aries.cdi.container.internal.literal.AnyLiteral;
@@ -52,14 +53,18 @@ public class ReferenceBean implements Be
 
 		_beanManagerImpl = beanManagerImpl;
 		_bundleContext = bundleContext;
-
 		_typesForMatchingBeansToInjectionPoints = Sets.immutableHashSet(injectionPointType, Object.class);
 		_beanClass = beanClass;
 		_bindType = bindType;
 		_serviceReference = serviceReference;
-
 		_currentInjectionPoint = _beanManagerImpl.getServices().get(CurrentInjectionPoint.class);
 		_qualifiers = Sets.hashSet(DefaultLiteral.INSTANCE, AnyLiteral.INSTANCE);
+
+		for (Annotation qualifier : _qualifiers) {
+			if (qualifier.annotationType().equals(Named.class)) {
+				_name = ((Named)qualifier).value();
+			}
+		}
 	}
 
 	public void addQualifier(Annotation annotation) {
@@ -108,7 +113,7 @@ public class ReferenceBean implements Be
 
 	@Override
 	public String getName() {
-		return toString() + "#" + System.identityHashCode(this);
+		return _name;
 	}
 
 	@Override
@@ -143,13 +148,16 @@ public class ReferenceBean implements Be
 
 	@Override
 	public String toString() {
-		return "ReferenceBean(" + _serviceReference + ")";
+		return "ReferenceBean[" + _serviceReference + "]";
 	}
 
 	protected <T> T create0(CreationalContext<T> creationalContext) {
+		T instance = cast(getServiceImpl());
 		InjectionPoint ip = getInjectionPoint(_currentInjectionPoint);
+		if (ip == null) {
+			return instance;
+		}
 		List<Decorator<?>> decorators = getDecorators(ip);
-		T instance = cast(getServiceImpl());
 		if (decorators.isEmpty()) {
 			return instance;
 		}
@@ -190,10 +198,11 @@ public class ReferenceBean implements Be
 	private static final Logger _log = LoggerFactory.getLogger(ReferenceBean.class);
 
 	private final Class<?> _beanClass;
+	private final BeanManagerImpl _beanManagerImpl;
 	private final BindType _bindType;
 	private final BundleContext _bundleContext;
 	private final CurrentInjectionPoint _currentInjectionPoint;
-	private final BeanManagerImpl _beanManagerImpl;
+	private String _name;
 	private final Set<Annotation> _qualifiers;
 	@SuppressWarnings("rawtypes")
 	private volatile ServiceObjects _serviceObjects;

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/command/CdiCommand.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/command/CdiCommand.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/command/CdiCommand.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/command/CdiCommand.java Thu May  4 18:41:59 2017
@@ -16,19 +16,17 @@ package org.apache.aries.cdi.container.i
 
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.aries.cdi.container.internal.container.CdiContainerState;
 import org.apache.aries.cdi.container.internal.container.ConfigurationDependency;
 import org.apache.aries.cdi.container.internal.container.ExtensionDependency;
 import org.apache.aries.cdi.container.internal.container.ReferenceDependency;
+import org.apache.aries.cdi.container.internal.util.Conversions;
 
 public class CdiCommand {
 
-	public CdiCommand() {
-
-	}
-
 	public void list() {
 		for (CdiContainerState cdiContainerState : _states.values()) {
 			System.out.printf("[%s] %s\n", cdiContainerState.getId(), cdiContainerState.getLastState());
@@ -49,7 +47,7 @@ public class CdiCommand {
 		if (!extensionDependencies.isEmpty()) {
 			System.out.println("  [EXTENSIONS]");
 			for (ExtensionDependency extensionDependency : extensionDependencies) {
-				System.out.printf("    %s%s\n", extensionDependency.toString(), " ???is this resolved???");
+				System.out.printf("    Extension: %s%s\n", extensionDependency.toString(), " ???is this resolved???");
 			}
 		}
 		List<ConfigurationDependency> configurationDependencies = cdiContainerState.getConfigurationDependencies();
@@ -58,8 +56,18 @@ public class CdiCommand {
 			for (ConfigurationDependency configurationDependency : configurationDependencies) {
 				for (String pid : configurationDependency.pids()) {
 					System.out.printf(
-						"    %s\n      : %s\n", pid,
-						!configurationDependency.isResolved(pid) ? " UNRESOLVED" : "resolved");
+						"    PID: %s\n      Status: %s\n      Required: %s\n", pid,
+						!configurationDependency.isResolved(pid) ? "UNRESOLVED" : "resolved",
+						configurationDependency.isRequired());
+					Map<String, Object> configuration = configurationDependency.getConfiguration();
+
+					if (!configuration.isEmpty()) {
+						System.out.println("      Properties:");
+						for (Entry<String, Object> entry : configuration.entrySet()) {
+							String value = Conversions.toString(entry.getValue());
+							System.out.printf("        %s = %s%n", entry.getKey(), value);
+						}
+					}
 				}
 			}
 		}
@@ -68,9 +76,9 @@ public class CdiCommand {
 			System.out.println("  [REFERENCES]");
 			for (ReferenceDependency referenceDependency : referenceDependencies) {
 				System.out.printf(
-					"    %s\n      Status: %s\n      Min Cardinality: %s\n",
+					"    Reference: %s\n      Status: %s\n      Min Cardinality: %s\n",
 					referenceDependency.toString(),
-					!referenceDependency.isResolved() ? " UNRESOLVED" : "resolved",
+					!referenceDependency.isResolved() ? "UNRESOLVED" : "resolved",
 					referenceDependency.getMinCardinality());
 			}
 		}
@@ -86,4 +94,5 @@ public class CdiCommand {
 
 	private final Map<Long, CdiContainerState> _states = new ConcurrentHashMap<>();
 
+
 }
\ No newline at end of file

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BindType.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BindType.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BindType.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BindType.java Thu May  4 18:41:59 2017
@@ -1,3 +1,17 @@
+/**
+ * Licensed 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.aries.cdi.container.internal.container;
 
 public enum BindType {

Added: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BootstrapContainer.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BootstrapContainer.java?rev=1793847&view=auto
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BootstrapContainer.java (added)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/BootstrapContainer.java Thu May  4 18:41:59 2017
@@ -0,0 +1,259 @@
+/**
+ * Licensed 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.aries.cdi.container.internal.container;
+
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.enterprise.inject.spi.Extension;
+
+import org.apache.aries.cdi.container.internal.literal.ReferenceLiteral;
+import org.apache.aries.cdi.container.internal.model.BeansModel;
+import org.apache.aries.cdi.container.internal.model.ConfigurationInjectionPoint;
+import org.apache.aries.cdi.container.internal.model.ConfigurationModel;
+import org.apache.aries.cdi.container.internal.model.ReferenceInjectionPoint;
+import org.apache.aries.cdi.container.internal.model.ReferenceModel;
+import org.apache.aries.cdi.container.internal.model.ServiceModel;
+import org.jboss.weld.bootstrap.WeldBootstrap;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.bootstrap.spi.Metadata;
+import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.util.ServiceLoader;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.cdi.CdiEvent.Type;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BootstrapContainer {
+
+	public BootstrapContainer(
+		BundleWiring bundleWiring, Map<ServiceReference<Extension>, Metadata<Extension>> extensions,
+		CdiContainerState cdiContainerState) {
+
+		_bundleWiring = bundleWiring;
+		_externalExtensions = extensions;
+		_cdiContainerState = cdiContainerState;
+
+		_bundle = _bundleWiring.getBundle();
+
+		// Add the internal extensions
+		_extensions.add(
+			new ExtensionMetadata(
+				new ConfigurationExtension(_configurations, _bundle.getBundleContext()), _bundle.toString()));
+		_extensions.add(
+			new ExtensionMetadata(
+				new ReferenceExtension(_references, _bundle.getBundleContext()), _bundle.toString()));
+		_extensions.add(new ExtensionMetadata(new ServiceExtension(_services), _bundle.toString()));
+
+		// Add extensions found from the bundle's classloader, such as those in the Bundle-ClassPath
+		for (Metadata<Extension> meta : ServiceLoader.load(Extension.class, _bundleWiring.getClassLoader())) {
+			_extensions.add(meta);
+		}
+
+		// Add external extensions
+		for (Metadata<Extension> meta : _externalExtensions.values()) {
+			_extensions.add(meta);
+		}
+
+		BeansModel beansModel = _cdiContainerState.getBeansModel();
+
+		BeanDeploymentArchive beanDeploymentArchive = new BundleDeploymentArchive(
+			bundleWiring, _cdiContainerState.getId(), beansModel.getBeanClassNames(), beansModel.getBeansXml(),
+			_cdiContainerState.getExtenderBundle());
+
+		Deployment deployment = new BundleDeployment(_extensions, beanDeploymentArchive);
+
+		_bootstrap = new WeldBootstrap();
+
+		_bootstrap.startContainer(_cdiContainerState.getId(), new SimpleEnvironment(), deployment);
+
+		_beanManagerImpl = _bootstrap.getManager(beanDeploymentArchive);
+
+		_cdiContainerState.setBeanManager(_beanManagerImpl);
+		_cdiContainerState.setConfigurationDependencies(_configurations);
+		_cdiContainerState.setReferenceDependencies(_references);
+
+		_bootstrap.startInitialization();
+		_bootstrap.deployBeans();
+
+		processDescriptorConfigurations();
+		processDescriptorReferences();
+	}
+
+	@Override
+	protected BootstrapContainer clone() {
+		BootstrapContainer bootstrapContainer = new BootstrapContainer(
+			_bundleWiring, _externalExtensions, _cdiContainerState);
+
+		bootstrapContainer._configurations.clear();
+		bootstrapContainer._configurations.addAll(_configurations);
+
+		return bootstrapContainer;
+	}
+
+	public void fire(Type state) {
+		_cdiContainerState.fire(state);
+	}
+
+	public void fire(Type state, String payload) {
+		_cdiContainerState.fire(state, payload);
+	}
+
+	public void fire(Type state, Throwable cause) {
+		_cdiContainerState.fire(state, cause);
+
+	}
+
+	public BeanManagerImpl getBeanManagerImpl() {
+		return _beanManagerImpl;
+	}
+
+	public WeldBootstrap getBootstrap() {
+		return _bootstrap;
+	}
+
+	public Bundle getBundle() {
+		return _bundle;
+	}
+
+	public BundleContext getBundleContext() {
+		return _bundle.getBundleContext();
+	}
+
+	public CdiContainerState getCdiContainerState() {
+		return _cdiContainerState;
+	}
+
+	public List<ConfigurationDependency> getConfigurations() {
+		return _configurations;
+	}
+
+	public Collection<ReferenceModel> getReferenceModels() {
+		return _cdiContainerState.getBeansModel().getReferenceModels();
+	}
+
+	public List<ReferenceDependency> getReferences() {
+		return _references;
+	}
+
+	public Collection<ServiceModel> getServiceModels() {
+		return _cdiContainerState.getBeansModel().getServiceModels();
+	}
+
+	public List<ServiceDeclaration> getServices() {
+		return _services;
+	}
+
+	public boolean hasConfigurations() {
+		return !_configurations.isEmpty();
+	}
+
+	public boolean hasReferences() {
+		return !_references.isEmpty();
+	}
+
+	public Class<?> loadClass(String clazz) throws ClassNotFoundException {
+		return _bundle.loadClass(clazz);
+	}
+
+	public ServiceRegistration<?> registerService(
+		String[] classNames, Object serviceInstance, Dictionary<String, Object> properties) {
+
+		return getBundleContext().registerService(classNames, serviceInstance, properties);
+	}
+
+	public void shutdown() {
+		_bootstrap.shutdown();
+	}
+
+	private void processConfigurationModel(ConfigurationModel configurationModel) {
+		try {
+			Class<?> beanClass = _bundle.loadClass(configurationModel.beanClass());
+
+			String[] pids = configurationModel.pids();
+
+			ConfigurationDependency configurationDependency = new ConfigurationDependency(
+				_bundle.getBundleContext(), pids, configurationModel.required(), beanClass.getName(),
+				new ConfigurationInjectionPoint(beanClass, pids));
+
+			_configurations.add(configurationDependency);
+		}
+		catch (ClassNotFoundException cnfe) {
+			_log.error(
+				"CDIe - osgi bean descriptor configuration processing cannot load class {}",
+				configurationModel.beanClass(), cnfe);
+		}
+	}
+
+	private void processDescriptorConfigurations() {
+		Collection<ConfigurationModel> configurationModels =
+			_cdiContainerState.getBeansModel().getConfigurationModels();
+
+		for (ConfigurationModel configurationModel : configurationModels) {
+			processConfigurationModel(configurationModel);
+		}
+	}
+
+	private void processDescriptorReferences() {
+		Collection<ReferenceModel> referenceModels = _cdiContainerState.getBeansModel().getReferenceModels();
+
+		for (ReferenceModel referenceModel : referenceModels) {
+			processReferenceModel(referenceModel);
+		}
+	}
+
+	private void processReferenceModel(ReferenceModel referenceModel) {
+		try {
+			Class<?> beanClass = _bundle.loadClass(referenceModel.getBeanClass());
+
+			ReferenceDependency referenceDependency = new ReferenceDependency(
+				_beanManagerImpl, ReferenceLiteral.from(referenceModel.getTarget()),
+				new ReferenceInjectionPoint(beanClass, referenceModel.getTarget()));
+
+			_references.add(referenceDependency);
+		}
+		catch (ClassNotFoundException cnfe) {
+			_log.error(
+				"CDIe - osgi bean descriptor reference processing cannot load class {}",
+				referenceModel.getBeanClass(), cnfe);
+		}
+		catch (InvalidSyntaxException ise) {
+			_log.error("CDIe - osgi bean descriptor reference processing error", ise);
+		}
+	}
+
+	private static final Logger _log = LoggerFactory.getLogger(BootstrapContainer.class);
+
+	private final BeanManagerImpl _beanManagerImpl;
+	private final WeldBootstrap _bootstrap;
+	private final Bundle _bundle;
+	private final BundleWiring _bundleWiring;
+	private final CdiContainerState _cdiContainerState;
+	private final List<ConfigurationDependency> _configurations = new CopyOnWriteArrayList<>();
+	private final List<Metadata<Extension>> _extensions = new CopyOnWriteArrayList<>();
+	private final Map<ServiceReference<Extension>, Metadata<Extension>> _externalExtensions;
+	private final List<ReferenceDependency> _references = new CopyOnWriteArrayList<>();
+	private final List<ServiceDeclaration> _services = new CopyOnWriteArrayList<>();
+
+}
\ No newline at end of file

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerService.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerService.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerService.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerService.java Thu May  4 18:41:59 2017
@@ -1,3 +1,17 @@
+/**
+ * Licensed 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.aries.cdi.container.internal.container;
 
 import javax.enterprise.inject.spi.BeanManager;

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerState.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerState.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerState.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/CdiContainerState.java Thu May  4 18:41:59 2017
@@ -17,21 +17,19 @@ package org.apache.aries.cdi.container.i
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.ReentrantLock;
 
 import javax.enterprise.inject.Any;
-import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.util.AnnotationLiteral;
 
 import org.apache.aries.cdi.container.internal.model.BeansModel;
+import org.jboss.weld.manager.BeanManagerImpl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cdi.CdiConstants;
 import org.osgi.service.cdi.CdiContainer;
 import org.osgi.service.cdi.CdiEvent;
 import org.osgi.service.cdi.CdiEvent.Type;
-import org.osgi.service.cdi.CdiExtenderConstants;
 import org.osgi.service.cdi.CdiListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,7 +51,7 @@ public class CdiContainerState {
 
 		Hashtable<String, Object> properties = new Hashtable<>();
 
-		properties.put(CdiExtenderConstants.CDI_EXTENDER_CONTAINER_STATE, CdiEvent.Type.CREATING);
+		properties.put(CdiConstants.CDI_CONTAINER_STATE, CdiEvent.Type.CREATING);
 
 		_cdiContainerRegistration = _bundle.getBundleContext().registerService(
 			CdiContainer.class, _cdiContainerService, properties);
@@ -70,10 +68,6 @@ public class CdiContainerState {
 		}
 	}
 
-	public BeanManager getBeanManager() {
-		return _beanManager;
-	}
-
 	public BeansModel getBeansModel() {
 		return _beansModel;
 	}
@@ -110,20 +104,24 @@ public class CdiContainerState {
 		Type type = event.getType();
 
 		if ((_lastState == CdiEvent.Type.DESTROYING) &&
-			((type == CdiEvent.Type.WAITING_FOR_EXTENSIONS) ||
+			((type == CdiEvent.Type.WAITING_FOR_CONFIGURATIONS) ||
+			(type == CdiEvent.Type.WAITING_FOR_EXTENSIONS) ||
 			(type == CdiEvent.Type.WAITING_FOR_SERVICES))) {
 
 			return;
 		}
 
-		if (_log.isDebugEnabled()) {
-			_log.debug("CDIe - Event {}", event, event.getCause());
+		if (_log.isErrorEnabled() && (event.getCause() != null)) {
+			_log.error("CDIe - Event {}", event, event.getCause());
+		}
+		else if (_log.isDebugEnabled()) {
+			_log.debug("CDIe - Event {}", event);
 		}
 
 		updateState(event);
 
-		if (_beanManager != null) {
-			_beanManager.fireEvent(event);
+		if (_beanManagerImpl != null) {
+			_beanManagerImpl.fireEvent(event);
 		}
 
 		for (CdiListener listener : _listeners.values()) {
@@ -150,9 +148,9 @@ public class CdiContainerState {
 		fire(new CdiEvent(state, _bundle, _extenderBundle, null, cause));
 	}
 
-	public void setBeanManager(BeanManager beanManager) {
-		_beanManager = beanManager;
-		_cdiContainerService.setBeanManager(beanManager);
+	public void setBeanManager(BeanManagerImpl beanManagerImpl) {
+		_beanManagerImpl = beanManagerImpl;
+		_cdiContainerService.setBeanManager(beanManagerImpl);
 	}
 
 	public void setBeansModel(BeansModel beansModel) {
@@ -176,7 +174,7 @@ public class CdiContainerState {
 
 		ServiceReference<CdiContainer> reference = _cdiContainerRegistration.getReference();
 
-		if (type == reference.getProperty(CdiExtenderConstants.CDI_EXTENDER_CONTAINER_STATE)) {
+		if (type == reference.getProperty(CdiConstants.CDI_CONTAINER_STATE)) {
 			return;
 		}
 
@@ -188,14 +186,14 @@ public class CdiContainerState {
 			properties.put(key, reference.getProperty(key));
 		}
 
-		properties.put(CdiExtenderConstants.CDI_EXTENDER_CONTAINER_STATE, type);
+		properties.put(CdiConstants.CDI_CONTAINER_STATE, type);
 
 		_cdiContainerRegistration.setProperties(properties);
 	}
 
 	private static final Logger _log = LoggerFactory.getLogger(CdiContainerState.class);
 
-	private volatile BeanManager _beanManager;
+	private volatile BeanManagerImpl _beanManagerImpl;
 	private BeansModel _beansModel;
 	private final Bundle _bundle;
 	private final ServiceRegistration<CdiContainer> _cdiContainerRegistration;

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationDependency.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationDependency.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationDependency.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationDependency.java Thu May  4 18:41:59 2017
@@ -1,33 +1,172 @@
+/**
+ * Licensed 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.aries.cdi.container.internal.container;
 
+import static org.apache.aries.cdi.container.internal.util.Reflection.cast;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ManagedService;
 
 public class ConfigurationDependency {
 
-	public ConfigurationDependency(String[] pids, String defaultPid) {
+	public ConfigurationDependency(
+		BundleContext bundleContext, String[] pids, boolean required, String defaultPid,
+		InjectionPoint injectionPoint) {
+
+		_bundleContext = bundleContext;
 		_pids = pids;
+		_required = required;
+		_injectionPoint = injectionPoint;
+		_beanClass = getConfigurationType();
 
-		for (int i = 0; i > pids.length; i++) {
+		for (int i = 0; i < _pids.length; i++) {
 			if ("$".equals(_pids[i])) {
 				_pids[i] = defaultPid;
 			}
 		}
 	}
 
+	public void close() {
+		for (Entry entry : _registrations) {
+			entry.getValue().unregister();
+		}
+
+		_registrations.clear();
+	}
+
+	public Class<?> getBeanClass() {
+		return _beanClass;
+	}
+
+	public InjectionPoint getInjectionPoint() {
+		return _injectionPoint;
+	}
+
+	public Map<String, Object> getConfiguration() {
+		Map<String, Object> map = new HashMap<>();
+
+		for (Entry entry : _registrations) {
+			Dictionary<String, ?> properties = entry.getKey().getProperties();
+
+			if (properties == null) {
+				continue;
+			}
+
+			Enumeration<String> keys = properties.keys();
+
+			while (keys.hasMoreElements()) {
+				String key = keys.nextElement();
+
+				if (Constants.SERVICE_PID.equals(key)) continue;
+
+				if (!map.containsKey(key)) {
+					map.put(key, properties.get(key));
+				}
+			}
+		}
+
+		return map;
+	}
+
+	public Object isRequired() {
+		return _required;
+	}
+
+	public boolean isResolved() {
+		for (Entry entry : _registrations) {
+			ConfigurationManagedService configurationManagedService = entry.getKey();
+
+			if (!configurationManagedService.isResolved()) {
+				return false;
+			}
+		}
+
+		return true;
+	}
+
 	public boolean isResolved(String pid) {
-		// TODO Auto-generated method stub
+		for (Entry entry : _registrations) {
+			ConfigurationManagedService configurationManagedService = entry.getKey();
+
+			if ((configurationManagedService._pid.equals(pid)) && configurationManagedService.isResolved()) {
+				return true;
+			}
+		}
+
 		return false;
 	}
 
+	public void open(ConfigurationResolveAction resolveAction) {
+		for (String pid : pids()) {
+			Dictionary<String, Object> properties = new Hashtable<>();
+
+			properties.put("service.pid", pid);
+
+			ConfigurationManagedService managedService = new ConfigurationManagedService(
+				pid, _required, _injectionPoint, resolveAction);
+
+			ServiceRegistration<ManagedService> serviceRegistration = _bundleContext.registerService(
+				ManagedService.class, managedService, properties);
+
+			_registrations.add(new Entry(managedService, serviceRegistration));
+		}
+	}
+
 	public String[] pids() {
 		return Arrays.copyOf(_pids, _pids.length);
 	}
 
 	@Override
 	public String toString() {
-		return Arrays.toString(_pids);
+		return _injectionPoint.getMember() + Arrays.toString(_pids);
+	}
+
+	private Class<?> getConfigurationType() {
+		Type type = _injectionPoint.getType();
+
+		if (!(type instanceof ParameterizedType)) {
+			return cast(type);
+		}
+
+		ParameterizedType parameterizedType = cast(type);
+
+		Type rawType = parameterizedType.getRawType();
+
+		return cast(rawType);
 	}
 
+	private final Class<?> _beanClass;
+	private final BundleContext _bundleContext;
+	private final InjectionPoint _injectionPoint;
 	private final String[] _pids;
+	private final List<Entry> _registrations = new CopyOnWriteArrayList<>();
+	private final boolean _required;
 
 }

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationExtension.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationExtension.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationExtension.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationExtension.java Thu May  4 18:41:59 2017
@@ -19,11 +19,12 @@ import java.util.List;
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.Annotated;
-import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ProcessInjectionPoint;
+import javax.inject.Named;
 
+import org.osgi.framework.BundleContext;
 import org.osgi.service.cdi.annotations.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -31,12 +32,13 @@ import org.slf4j.LoggerFactory;
 @ApplicationScoped
 public class ConfigurationExtension implements Extension {
 
-	public ConfigurationExtension(List<ConfigurationDependency> configurations) {
+	public ConfigurationExtension(List<ConfigurationDependency> configurations, BundleContext bundleContext) {
 		_configurations = configurations;
+		_bundleContext = bundleContext;
 	}
 
 	void processInjectionTarget(
-		@Observes @SuppressWarnings("rawtypes") ProcessInjectionPoint pip, BeanManager manager) {
+		@Observes @SuppressWarnings("rawtypes") ProcessInjectionPoint pip) {
 
 		InjectionPoint injectionPoint = pip.getInjectionPoint();
 		Annotated annotated = injectionPoint.getAnnotated();
@@ -48,8 +50,17 @@ public class ConfigurationExtension impl
 
 		Class<?> beanClass = injectionPoint.getBean().getBeanClass();
 
+		String name = beanClass.getName();
+
+		Named named = annotated.getAnnotation(Named.class);
+
+		if (named != null) {
+			name = named.value();
+		}
+
 		ConfigurationDependency configurationDependency = new ConfigurationDependency(
-			configuration.value(), beanClass.getName());
+			_bundleContext, configuration.value(), configuration.required(), name,
+			injectionPoint);
 
 		_configurations.add(configurationDependency);
 
@@ -58,8 +69,9 @@ public class ConfigurationExtension impl
 		}
 	}
 
-	private static final Logger _log = LoggerFactory.getLogger(ReferenceExtension.class);
+	private static final Logger _log = LoggerFactory.getLogger(ConfigurationExtension.class);
 
+	private final BundleContext _bundleContext;
 	private final List<ConfigurationDependency> _configurations;
 
 }

Added: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationManagedService.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationManagedService.java?rev=1793847&view=auto
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationManagedService.java (added)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationManagedService.java Thu May  4 18:41:59 2017
@@ -0,0 +1,62 @@
+package org.apache.aries.cdi.container.internal.container;
+
+import java.util.Dictionary;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+
+class ConfigurationManagedService implements ManagedService {
+
+	public ConfigurationManagedService(
+		String pid, boolean required, InjectionPoint injectionPoint, ConfigurationResolveAction resolveAction) {
+
+		_pid = pid;
+		_required = required;
+		_injectionPoint = injectionPoint;
+		_resolveAction = resolveAction;
+
+		_resolveAction.add(this);
+	}
+
+	public String getPid() {
+		return _pid;
+	}
+
+	public synchronized Dictionary<String, ?> getProperties() {
+		return _properties;
+	}
+
+	public synchronized boolean isResolved() {
+		return _required ? (_properties != null) : true;
+	}
+
+	@Override
+	public synchronized void updated(Dictionary<String, ?> properties) throws ConfigurationException {
+		if ((_properties == null) && (properties != null)) {
+			_properties = properties;
+			_resolveAction.addingConfiguration();
+		}
+		else if ((_properties != null) && (properties == null)) {
+			_properties = properties;
+			_resolveAction.removeProperties();
+		}
+		else {
+			_properties = properties;
+			_resolveAction.updateProperties();
+		}
+	}
+
+	@Override
+	public String toString() {
+		return "ConfigurationManagedService[" + _pid + ", " + _injectionPoint + "]";
+	}
+
+	private final InjectionPoint _injectionPoint;
+	final String _pid;
+	private volatile Dictionary<String, ?> _properties;
+	private final boolean _required;
+	private final ConfigurationResolveAction _resolveAction;
+
+}
\ No newline at end of file

Added: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationResolveAction.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationResolveAction.java?rev=1793847&view=auto
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationResolveAction.java (added)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ConfigurationResolveAction.java Thu May  4 18:41:59 2017
@@ -0,0 +1,166 @@
+/**
+ * Licensed 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.aries.cdi.container.internal.container;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.osgi.service.cdi.CdiEvent;
+
+class ConfigurationResolveAction {
+
+	public ConfigurationResolveAction(BootstrapContainer bc) {
+		_bc = bc;
+	}
+
+	public void add(ConfigurationManagedService configurationManagedService) {
+		try {
+			_lock.lock();
+
+			_managedServices.add(configurationManagedService);
+		}
+		finally {
+			_lock.unlock();
+		}
+	}
+
+	public void close() {
+		try {
+			_lock.lock();
+
+			_closing = true;
+
+			_nextPhase.close();
+
+			_nextPhase = null;
+
+			for (ConfigurationDependency configurationDependency : _bc.getConfigurations()) {
+				configurationDependency.close();
+			}
+		}
+		finally {
+			_lock.unlock();
+		}
+	}
+
+	public void open() {
+		try {
+			_lock.lock();
+
+			_closing = false;
+
+			for (ConfigurationDependency configurationDependency : _bc.getConfigurations()) {
+				configurationDependency.open(this);
+			}
+
+			if (configurationsAreResolved()) {
+				_nextPhase = new Phase_Reference(_bc);
+
+				_nextPhase.open();
+			}
+		}
+		finally {
+			_lock.unlock();
+		}
+	}
+
+	public void addingConfiguration() {
+		try {
+			_lock.lock();
+
+			if (_closing) return;
+
+			if (!_resolved && configurationsAreResolved()) {
+				_resolved = true;
+
+				if (_nextPhase != null) {
+					close();
+
+					_bc = _bc.clone();
+
+					_bc.fire(CdiEvent.Type.WAITING_FOR_CONFIGURATIONS, _bc.getConfigurations().toString());
+
+					open();
+				}
+
+				if (_nextPhase == null) {
+					_nextPhase = new Phase_Reference(_bc);
+
+					_nextPhase.open();
+				}
+			}
+		}
+		catch (Throwable t) {
+			_bc.fire(CdiEvent.Type.FAILURE, t);
+
+			// TODO this should close the CDI container!
+		}
+		finally {
+			_lock.unlock();
+		}
+	}
+
+	public void removeProperties() {
+		try {
+			_lock.lock();
+
+			if (_closing) return;
+
+			if (_nextPhase != null) {
+				_resolved = false;
+
+				close();
+
+				_bc = _bc.clone();
+
+				_bc.fire(CdiEvent.Type.WAITING_FOR_CONFIGURATIONS, _bc.getConfigurations().toString());
+
+				open();
+			}
+		}
+		catch (Throwable t) {
+			_bc.fire(CdiEvent.Type.FAILURE, t);
+
+			// TODO this should close the CDI container!
+		}
+		finally {
+			_lock.unlock();
+		}
+	}
+
+	public void updateProperties() {
+	}
+
+	private boolean configurationsAreResolved() {
+		for (ConfigurationDependency dependency : _bc.getConfigurations()) {
+			if (!dependency.isResolved()) {
+				return false;
+			}
+		}
+
+		return true;
+	}
+
+	private volatile BootstrapContainer _bc;
+	private volatile boolean _closing = false;
+	private volatile Phase _nextPhase;
+	private volatile boolean _resolved = false;
+
+	private final Lock _lock = new ReentrantLock();
+	private final List<ConfigurationManagedService> _managedServices = new CopyOnWriteArrayList<>();
+
+}
\ No newline at end of file

Added: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Entry.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Entry.java?rev=1793847&view=auto
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Entry.java (added)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Entry.java Thu May  4 18:41:59 2017
@@ -0,0 +1,15 @@
+package org.apache.aries.cdi.container.internal.container;
+
+import java.util.AbstractMap.SimpleImmutableEntry;
+
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ManagedService;
+
+class Entry extends SimpleImmutableEntry<ConfigurationManagedService, ServiceRegistration<ManagedService>> {
+
+	private static final long serialVersionUID = 1L;
+
+	public Entry(ConfigurationManagedService key, ServiceRegistration<ManagedService> value) {
+		super(key, value);
+	}
+}
\ No newline at end of file

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ExtensionDependency.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ExtensionDependency.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ExtensionDependency.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ExtensionDependency.java Thu May  4 18:41:59 2017
@@ -20,13 +20,13 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.cdi.CdiExtenderConstants;
+import org.osgi.service.cdi.CdiConstants;
 
 public class ExtensionDependency {
 
 	public ExtensionDependency(BundleContext bundleContext, Long bundleId, String name) {
 		_string = "(&(" + org.osgi.framework.Constants.SERVICE_BUNDLEID + "=" + bundleId + ")(" +
-			CdiExtenderConstants.CDI_EXTENSION + "=" + name + "))";
+			CdiConstants.CDI_EXTENSION_NAMESPACE + "=" + name + "))";
 
 		try {
 			_filter = bundleContext.createFilter(_string);

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase.java Thu May  4 18:41:59 2017
@@ -1,3 +1,17 @@
+/**
+ * Licensed 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.aries.cdi.container.internal.container;
 
 public interface Phase {

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Configuration.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Configuration.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Configuration.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Configuration.java Thu May  4 18:41:59 2017
@@ -14,166 +14,62 @@
 
 package org.apache.aries.cdi.container.internal.container;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
 import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
 
-import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Extension;
 
-import org.apache.aries.cdi.container.internal.model.BeansModel;
-import org.apache.aries.cdi.container.internal.model.ConfigurationModel;
-import org.jboss.weld.bootstrap.WeldBootstrap;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
 import org.jboss.weld.bootstrap.spi.Metadata;
-import org.jboss.weld.manager.BeanManagerImpl;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.service.cdi.CdiEvent;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.cm.ConfigurationListener;
-import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class Phase_Configuration implements Phase {
 
 	public Phase_Configuration(
-		Bundle bundle, CdiContainerState cdiContainerState, Map<ServiceReference<Extension>,
-		Metadata<Extension>> extensions) {
+		CdiContainerState cdiContainerState,
+		Map<ServiceReference<Extension>, Metadata<Extension>> extensions) {
 
-		_bundle = bundle;
 		_cdiContainerState = cdiContainerState;
 		_extensions = extensions;
-		_bundleContext = _bundle.getBundleContext();
-		_bundleWiring = _bundle.adapt(BundleWiring.class);
-
-		_configAdminTracker = new ServiceTracker<>(
-			_cdiContainerState.getExtenderBundle().getBundleContext(), ConfigurationAdmin.class, null);
-
-		_configAdminTracker.open();
-
-		_cdiContainerState.setConfigurationDependencies(_configurations);
-		_cdiContainerState.setReferenceDependencies(_references);
+		_bundleWiring = _cdiContainerState.getBundle().adapt(BundleWiring.class);
 	}
 
 	@Override
 	public void close() {
-//		if (_serviceTracker != null) {
-//			_serviceTracker.close();
-//
-//			_serviceTracker = null;
-//		}
-//		else {
-			if (_nextPhase != null) {
-				_nextPhase.close();
-
-				_nextPhase = null;
-			}
-//		}
-
-		_configAdminTracker.close();
-	}
-
-	@Override
-	public void open() {
-		BeansModel beansModel = _cdiContainerState.getBeansModel();
+		if (_resolveAction != null) {
+			_resolveAction.close();
 
-		BeanDeploymentArchive beanDeploymentArchive = new BundleDeploymentArchive(
-			_bundleWiring, _cdiContainerState.getId(), beansModel.getBeanClassNames(), beansModel.getBeansXml(),
-			_cdiContainerState.getExtenderBundle());
-
-		WeldBootstrap bootstrap = new WeldBootstrap();
-
-		List<Metadata<Extension>> extensions = new ArrayList<>();
-
-		// Add the internal extensions
-		extensions.add(
-			new ExtensionMetadata(new ConfigurationExtension(_configurations), _bundle.toString()));
-		extensions.add(
-			new ExtensionMetadata(new ReferenceExtension(_references, _bundleContext), _bundle.toString()));
-		extensions.add(new ExtensionMetadata(new ServiceExtension(_services), _bundle.toString()));
-
-		// Add extensions found from the bundle's classloader, such as those in the Bundle-ClassPath
-		for (Metadata<Extension> meta : bootstrap.loadExtensions(_bundleWiring.getClassLoader())) {
-			extensions.add(meta);
+			_resolveAction = null;
 		}
+		else if (_nextPhase != null) {
+			_nextPhase.close();
 
-		// Add external extensions
-		for (Metadata<Extension> meta : _extensions.values()) {
-			extensions.add(meta);
+			_nextPhase = null;
 		}
+	}
 
-		Deployment deployment = new BundleDeployment(extensions, beanDeploymentArchive);
-
-		bootstrap.startContainer(_cdiContainerState.getId(), new SimpleEnvironment(), deployment);
-
-		BeanManager beanManager = bootstrap.getManager(beanDeploymentArchive);
-
-		_cdiContainerState.setBeanManager(beanManager);
-
-		bootstrap.startInitialization();
-		bootstrap.deployBeans();
-
-		processDescriptorConfigurations((BeanManagerImpl)beanManager);
+	@Override
+	public void open() {
+		BootstrapContainer bc = new BootstrapContainer(_bundleWiring, _extensions, _cdiContainerState);
 
-		if (!_configurations.isEmpty()) {
-			_cdiContainerState.fire(CdiEvent.Type.WAITING_FOR_CONFIGURATIONS, _configurations.toString());
+		if (bc.hasConfigurations()) {
+			_cdiContainerState.fire(CdiEvent.Type.WAITING_FOR_CONFIGURATIONS, bc.getConfigurations().toString());
 
-			// TODO configuration listener
-			temporary: {
-				_nextPhase = new Phase_Reference(_references, _services, _cdiContainerState, bootstrap);
+			_resolveAction = new ConfigurationResolveAction(bc);
 
-				_nextPhase.open();
-			}
+			_resolveAction.open();
 		}
 		else {
-			_nextPhase = new Phase_Reference(_references, _services, _cdiContainerState, bootstrap);
+			_nextPhase = new Phase_Reference(bc);
 
 			_nextPhase.open();
 		}
 	}
 
-	private void processConfigurationModel(ConfigurationModel configurationModel, BeanManagerImpl beanManagerImpl) {
-		_configurations.add(
-			new ConfigurationDependency(new String[] {configurationModel.getPid()}, configurationModel.getPid()));
-	}
-
-	private void processDescriptorConfigurations(BeanManagerImpl beanManagerImpl) {
-		Collection<ConfigurationModel> configurationModels =
-			_cdiContainerState.getBeansModel().getConfigurationModels();
-
-		for (ConfigurationModel configurationModel : configurationModels) {
-			processConfigurationModel(configurationModel, beanManagerImpl);
-		}
-	}
-
-	private static final Logger _log = LoggerFactory.getLogger(Phase_Configuration.class);
-
-	private final Bundle _bundle;
-	private final BundleContext _bundleContext;
 	private final BundleWiring _bundleWiring;
 	private final CdiContainerState _cdiContainerState;
-	private final ServiceTracker<ConfigurationAdmin, ConfigurationAdmin> _configAdminTracker;
-	private final List<ConfigurationDependency> _configurations = new CopyOnWriteArrayList<>();
 	private final Map<ServiceReference<Extension>, Metadata<Extension>> _extensions;
 	private Phase _nextPhase;
-	private final List<ReferenceDependency> _references = new CopyOnWriteArrayList<>();
-	private final List<ServiceDeclaration> _services = new CopyOnWriteArrayList<>();
-
-	class ConfigurationDependencyListener implements ConfigurationListener {
-
-		@Override
-		public void configurationEvent(ConfigurationEvent event) {
-			_log.info("CDIe - configuration event {}", event);
-		}
-
-	}
+	private ConfigurationResolveAction _resolveAction;
 
 }
\ No newline at end of file

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Extension.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Extension.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Extension.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Extension.java Thu May  4 18:41:59 2017
@@ -23,14 +23,13 @@ import java.util.concurrent.CopyOnWriteA
 import javax.enterprise.inject.spi.Extension;
 
 import org.jboss.weld.bootstrap.spi.Metadata;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.wiring.BundleWire;
 import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.cdi.CdiConstants;
 import org.osgi.service.cdi.CdiEvent;
-import org.osgi.service.cdi.CdiExtenderConstants;
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 import org.slf4j.Logger;
@@ -38,11 +37,11 @@ import org.slf4j.LoggerFactory;
 
 public class Phase_Extension implements Phase {
 
-	public Phase_Extension(Bundle bundle, CdiContainerState cdiContainerState) {
-		_bundle = bundle;
+	public Phase_Extension(CdiContainerState cdiContainerState) {
 		_cdiContainerState = cdiContainerState;
-		_bundleContext = bundle.getBundleContext();
-		_extensionDependencies = findExtensionDependencies(bundle.adapt(BundleWiring.class));
+		_bundleContext = _cdiContainerState.getBundle().getBundleContext();
+		_extensionDependencies = findExtensionDependencies(
+			_cdiContainerState.getBundle().adapt(BundleWiring.class));
 		_extensions = new ConcurrentSkipListMap<>(Comparator.reverseOrder());
 
 		_cdiContainerState.setExtensionDependencies(_extensionDependencies);
@@ -82,7 +81,7 @@ public class Phase_Extension implements
 			_extensionTracker.open();
 		}
 		else {
-			_nextPhase = new Phase_Configuration(_bundle, _cdiContainerState, _extensions);
+			_nextPhase = new Phase_Configuration(_cdiContainerState, _extensions);
 
 			_nextPhase.open();
 		}
@@ -90,12 +89,12 @@ public class Phase_Extension implements
 
 	List<ExtensionDependency> findExtensionDependencies(BundleWiring bundleWiring) {
 		List<ExtensionDependency> extensionDependencies = new CopyOnWriteArrayList<>();
-		List<BundleWire> requiredWires = bundleWiring.getRequiredWires(CdiExtenderConstants.CDI_EXTENSION);
+		List<BundleWire> requiredWires = bundleWiring.getRequiredWires(CdiConstants.CDI_EXTENSION_NAMESPACE);
 
 		for (BundleWire wire : requiredWires) {
 			Map<String, Object> attributes = wire.getCapability().getAttributes();
 
-			String extension = (String)attributes.get(CdiExtenderConstants.CDI_EXTENSION);
+			String extension = (String)attributes.get(CdiConstants.CDI_EXTENSION_NAMESPACE);
 
 			if (extension != null) {
 				ExtensionDependency extensionDependency = new ExtensionDependency(
@@ -110,7 +109,6 @@ public class Phase_Extension implements
 
 	private static final Logger _log = LoggerFactory.getLogger(Phase_Extension.class);
 
-	private final Bundle _bundle;
 	private final BundleContext _bundleContext;
 	private final CdiContainerState _cdiContainerState;
 	private final Map<ServiceReference<Extension>, Metadata<Extension>> _extensions;
@@ -139,7 +137,7 @@ public class Phase_Extension implements
 			}
 
 			if ((trackedDependency != null) && _extensionDependencies.isEmpty()) {
-				_nextPhase = new Phase_Configuration(_bundle, _cdiContainerState, _extensions);
+				_nextPhase = new Phase_Configuration(_cdiContainerState, _extensions);
 
 				_nextPhase.open();
 			}

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Init.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Init.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Init.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Init.java Thu May  4 18:41:59 2017
@@ -28,7 +28,7 @@ public class Phase_Init implements Phase
 
 		cdiContainerState.setBeansModel(beansModel);
 
-		_extensionPhase = new Phase_Extension(bundle, cdiContainerState);
+		_extensionPhase = new Phase_Extension(cdiContainerState);
 	}
 
 	@Override

Modified: aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Publish.java
URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Publish.java?rev=1793847&r1=1793846&r2=1793847&view=diff
==============================================================================
--- aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Publish.java (original)
+++ aries/trunk/cdi/cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/Phase_Publish.java Thu May  4 18:41:59 2017
@@ -27,15 +27,15 @@ import java.util.concurrent.CopyOnWriteA
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
 
+import org.apache.aries.cdi.container.internal.bean.ConfigurationBean;
 import org.apache.aries.cdi.container.internal.bean.ReferenceBean;
 import org.apache.aries.cdi.container.internal.literal.AnyLiteral;
 import org.apache.aries.cdi.container.internal.literal.ServiceLiteral;
 import org.apache.aries.cdi.container.internal.model.ServiceModel;
-import org.jboss.weld.bootstrap.api.Bootstrap;
+import org.jboss.weld.bootstrap.WeldBootstrap;
 import org.jboss.weld.manager.BeanManagerImpl;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cdi.CdiEvent;
@@ -44,16 +44,8 @@ import org.slf4j.LoggerFactory;
 
 public class Phase_Publish implements Phase {
 
-	public Phase_Publish(
-		List<ReferenceDependency> references, List<ServiceDeclaration> services, CdiContainerState cdiContainerState,
-		Bootstrap bootstrap) {
-
-		_references = references;
-		_services = services;
-		_cdiContainerState = cdiContainerState;
-		_bootstrap = bootstrap;
-		_bundle = cdiContainerState.getBundle();
-		_bundleContext = _bundle.getBundleContext();
+	public Phase_Publish(BootstrapContainer bc) {
+		_bc = bc;
 	}
 
 	@Override
@@ -83,33 +75,48 @@ public class Phase_Publish implements Ph
 			}
 		}
 
-		_bootstrap.shutdown();
+		_bc.shutdown();
 	}
 
 	@Override
 	public void open() {
-		_cdiContainerState.fire(CdiEvent.Type.SATISFIED);
+		_bc.fire(CdiEvent.Type.SATISFIED);
 
-		BeanManager beanManager = _cdiContainerState.getBeanManager();
+		BeanManagerImpl beanManagerImpl = _bc.getBeanManagerImpl();
 
-		processReferenceDependencies((BeanManagerImpl)beanManager);
+		processConfigurationDependencies(beanManagerImpl);
+		processReferenceDependencies(beanManagerImpl);
 
-		_bootstrap.validateBeans();
-		_bootstrap.endInitialization();
+		WeldBootstrap bootstrap = _bc.getBootstrap();
 
-		processRequirementDefinedServices((BeanManagerImpl)beanManager);
+		bootstrap.validateBeans();
+		bootstrap.endInitialization();
+
+		processRequirementDefinedServices(beanManagerImpl);
 		processServiceDeclarations();
 
-		_beanManagerRegistration = _bundleContext.registerService(
-			BeanManager.class, beanManager, null);
+		_beanManagerRegistration = _bc.getBundleContext().registerService(
+			BeanManager.class, beanManagerImpl, null);
+
+		_bc.fire(CdiEvent.Type.CREATED);
+	}
+
+	private void processConfigurationDependencies(BeanManagerImpl beanManagerImpl) {
+		for (ConfigurationDependency configurationDependency : _bc.getConfigurations()) {
+			InjectionPoint injectionPoint = configurationDependency.getInjectionPoint();
+
+			ConfigurationBean bean = new ConfigurationBean(
+				configurationDependency, beanManagerImpl, injectionPoint.getType(),
+				injectionPoint.getQualifiers());
 
-		_cdiContainerState.fire(CdiEvent.Type.CREATED);
+			beanManagerImpl.addBean(bean);
+		}
 	}
 
 	private void processReferenceDependencies(BeanManagerImpl beanManagerImpl) {
 		Map<ServiceReference<?>, Set<ReferenceBean>> beans = new HashMap<>();
 
-		for (ReferenceDependency referenceDependency : _references) {
+		for (ReferenceDependency referenceDependency : _bc.getReferences()) {
 			for (ServiceReference<?> matchingReference : referenceDependency.getMatchingReferences()) {
 				Set<ReferenceBean> set = beans.get(matchingReference);
 
@@ -136,7 +143,7 @@ public class Phase_Publish implements Ph
 				}
 				else {
 					ReferenceBean bean = new ReferenceBean(
-						beanManagerImpl, _bundleContext, referenceDependency.getInjectionPointType(),
+						beanManagerImpl, _bc.getBundleContext(), referenceDependency.getInjectionPointType(),
 						referenceDependency.getBeanClass(), referenceDependency.getBindType(), matchingReference);
 
 					bean.addQualifier(referenceDependency.getReference());
@@ -151,11 +158,11 @@ public class Phase_Publish implements Ph
 	}
 
 	private void processRequirementDefinedServices(BeanManagerImpl beanManagerImpl) {
-		Collection<ServiceModel> serviceModels = _cdiContainerState.getBeansModel().getServiceModels();
+		Collection<ServiceModel> serviceModels = _bc.getServiceModels();
 
 		for (ServiceModel serviceModel : serviceModels) {
 			try {
-				Class<?> beanClass = _bundle.loadClass(serviceModel.getBeanClass());
+				Class<?> beanClass = _bc.loadClass(serviceModel.getBeanClass());
 
 				Set<Bean<?>> beans = beanManagerImpl.getBeans(beanClass, AnyLiteral.INSTANCE);
 
@@ -175,7 +182,7 @@ public class Phase_Publish implements Ph
 
 				for (String provide : provides) {
 					try {
-						interfaces.add(_bundle.loadClass(provide));
+						interfaces.add(_bc.loadClass(provide));
 					}
 					catch (Exception e) {
 						_log.error("CDIe - Failure loading provided interface for service {}", provide);
@@ -196,14 +203,14 @@ public class Phase_Publish implements Ph
 	}
 
 	private void processServiceDeclarations() {
-		for (ServiceDeclaration serviceDeclaration : _services) {
+		for (ServiceDeclaration serviceDeclaration : _bc.getServices()) {
 			processServiceDeclaration(serviceDeclaration);
 		}
 	}
 
 	private void processServiceDeclaration(ServiceDeclaration serviceDeclaration) {
 		if (_log.isDebugEnabled()) {
-			_log.debug("CDIe - Publishing bean {} as service.", serviceDeclaration);
+			_log.debug("CDIe - Publishing bean {} as service.", serviceDeclaration.getBean());
 		}
 
 		String[] classNames = serviceDeclaration.getClassNames();
@@ -211,18 +218,13 @@ public class Phase_Publish implements Ph
 		Dictionary<String,Object> properties = serviceDeclaration.getProperties();
 
 		_registrations.add(
-			_bundleContext.registerService(classNames, serviceInstance, properties));
+			_bc.getBundleContext().registerService(classNames, serviceInstance, properties));
 	}
 
 	private static final Logger _log = LoggerFactory.getLogger(Phase_Publish.class);
 
-	private final Bootstrap _bootstrap;
-	private final Bundle _bundle;
-	private final BundleContext _bundleContext;
-	private final CdiContainerState _cdiContainerState;
-	private final List<ReferenceDependency> _references;
+	private final BootstrapContainer _bc;
 	private final List<ServiceRegistration<?>> _registrations = new CopyOnWriteArrayList<>();
-	private final List<ServiceDeclaration> _services;
 
 	private ServiceRegistration<BeanManager> _beanManagerRegistration;
 



Mime
View raw message