Modified: aries/trunk/cdi/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/model/ModelTest.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/model/ModelTest.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/model/ModelTest.java (original) +++ aries/trunk/cdi/cdi-extender/src/test/java/org/apache/aries/cdi/container/internal/model/ModelTest.java Thu May 4 18:41:59 2017 @@ -1,23 +1,23 @@ package org.apache.aries.cdi.container.internal.model; -import java.lang.reflect.Type; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.net.URL; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Map; -import org.osgi.service.cdi.CdiExtenderConstants; -import org.osgi.service.cdi.annotations.PropertyType; -import org.osgi.service.cdi.annotations.ServiceProperty; -import org.osgi.util.converter.Converter; -import org.osgi.util.converter.StandardConverter; - -import junit.framework.TestCase; +import org.junit.Test; +import org.osgi.service.cdi.CdiConstants; -public class ModelTest extends TestCase { +public class ModelTest { + @Test public void testModelWithBeansOnly() throws Exception { AbstractModelBuilder builder = getBuilder("OSGI-INF/cdi/beans-only.xml"); BeansModel beansModel = builder.build(); @@ -28,6 +28,7 @@ public class ModelTest extends TestCase assertEquals("com.foo.FooImpl", beanClassNames.iterator().next()); } + @Test public void testModelWithConfiguration() throws Exception { AbstractModelBuilder builder = getBuilder("OSGI-INF/cdi/beans-configuration.xml"); BeansModel beansModel = builder.build(); @@ -38,11 +39,25 @@ public class ModelTest extends TestCase assertEquals("com.foo.FooImpl", beanClassNames.iterator().next()); Collection<ConfigurationModel> configurationModels = beansModel.getConfigurationModels(); - assertEquals(2, configurationModels.size()); - ConfigurationModel configurationModel = configurationModels.iterator().next(); - assertEquals("com.foo.FooImpl", configurationModel.getPid()); + assertEquals(3, configurationModels.size()); + Iterator<ConfigurationModel> iterator = configurationModels.iterator(); + + ConfigurationModel configurationModel = iterator.next(); + assertArrayEquals(new String[] {"com.foo.FooImpl"}, configurationModel.pids()); + assertEquals("com.foo.Config", configurationModel.beanClass()); + assertEquals(true, configurationModel.required()); + + configurationModel = iterator.next(); + assertArrayEquals(new String[] {"com.foo.other", "and.another"}, configurationModel.pids()); + assertEquals("com.foo.Baz", configurationModel.beanClass()); + assertEquals(true, configurationModel.required()); + + configurationModel = iterator.next(); + assertArrayEquals(new String[] {"an.optional.configuration"}, configurationModel.pids()); + assertEquals(false, configurationModel.required()); } + @Test public void testModelWithReferences() throws Exception { AbstractModelBuilder builder = getBuilder("OSGI-INF/cdi/beans-references.xml"); BeansModel beansModel = builder.build(); @@ -59,6 +74,7 @@ public class ModelTest extends TestCase assertEquals("(objectClass=java.util.concurrent.Callable)", referenceModel.getTarget()); } + @Test public void testModelWithServices() throws Exception { AbstractModelBuilder builder = getBuilder("OSGI-INF/cdi/beans-services.xml"); BeansModel beansModel = builder.build(); @@ -74,88 +90,66 @@ public class ModelTest extends TestCase List<String> provides = serviceModel.getProvides(); assertEquals(2, provides.size()); assertEquals("com.foo.Foo", provides.get(0)); - ServiceProperty[] serviceProperties = serviceModel.getProperties(); - assertEquals(18, serviceProperties.length); + String[] serviceProperties = serviceModel.getProperties(); + assertEquals(33, serviceProperties.length); + + assertEquals("foo:String=fum", serviceProperties[0]); + assertEquals("foo1:String=baz", serviceProperties[1]); + assertEquals("foo2:Long=345987643", serviceProperties[2]); + assertEquals("foo3:Double=3459.87643", serviceProperties[3]); + assertEquals("foo4:Float=3459.87", serviceProperties[4]); + assertEquals("foo5:Integer=724559", serviceProperties[5]); + assertEquals("foo6:Byte=127", serviceProperties[6]); + assertEquals("foo7:Character=X", serviceProperties[7]); + assertEquals("foo8:Boolean=true", serviceProperties[8]); + assertEquals("foo9:Short=32767", serviceProperties[9]); + assertEquals("foo11:String=frog", serviceProperties[10]); + assertEquals("foo11:String=drum", serviceProperties[11]); + assertEquals("foo12:Long=345987643", serviceProperties[12]); + assertEquals("foo12:Long=34", serviceProperties[13]); + assertEquals("foo13:Double=3459.87643", serviceProperties[14]); + assertEquals("foo13:Double=34.3456", serviceProperties[15]); + assertEquals("foo14:Float=3459.87", serviceProperties[16]); + assertEquals("foo14:Float=35.23", serviceProperties[17]); + assertEquals("foo15:Integer=724559", serviceProperties[18]); + assertEquals("foo15:Integer=345", serviceProperties[19]); + assertEquals("foo16:Byte=127", serviceProperties[20]); + assertEquals("foo16:Byte=23", serviceProperties[21]); + assertEquals("foo17:Character=X", serviceProperties[22]); + assertEquals("foo17:Character=t", serviceProperties[23]); + assertEquals("foo18:Boolean=true", serviceProperties[24]); + assertEquals("foo18:Boolean=false", serviceProperties[25]); + assertEquals("foo19:Short=32767", serviceProperties[26]); + assertEquals("foo19:Short=2345", serviceProperties[27]); + assertEquals("foo20:String=bar", serviceProperties[28]); + assertEquals("foo21:List<Short>=32767", serviceProperties[29]); + assertEquals("foo21:List<Short>=2345", serviceProperties[30]); + assertEquals("foo22:Set<Short>=32767", serviceProperties[31]); + assertEquals("foo22:Set<Short>=2345", serviceProperties[32]); + } + + @Test + public void testModelWithAllDescriptors() throws Exception { + AbstractModelBuilder builder = getBuilder(null); + BeansModel beansModel = builder.build(); + assertNotNull(beansModel); - assertEquals("foo", serviceProperties[0].key()); - assertEquals(PropertyType.String, serviceProperties[0].type()); - assertEquals("fum", getValue(serviceProperties[0])); - - assertEquals("foo2", serviceProperties[1].key()); - assertEquals(PropertyType.Long, serviceProperties[1].type()); - assertEquals(345987643L, getValue(serviceProperties[1])); - - assertEquals("foo3", serviceProperties[2].key()); - assertEquals(PropertyType.Double, serviceProperties[2].type()); - assertEquals(3459.87643D, getValue(serviceProperties[2])); - - assertEquals("foo4", serviceProperties[3].key()); - assertEquals(PropertyType.Float, serviceProperties[3].type()); - assertEquals(3459.87F, getValue(serviceProperties[3])); - - assertEquals("foo5", serviceProperties[4].key()); - assertEquals(PropertyType.Integer, serviceProperties[4].type()); - assertEquals(724559, getValue(serviceProperties[4])); - - assertEquals("foo6", serviceProperties[5].key()); - assertEquals(PropertyType.Byte, serviceProperties[5].type()); - assertEquals(new Byte("127"), getValue(serviceProperties[5])); - - assertEquals("foo7", serviceProperties[6].key()); - assertEquals(PropertyType.Character, serviceProperties[6].type()); - assertEquals(new Character('X'), getValue(serviceProperties[6])); - - assertEquals("foo8", serviceProperties[7].key()); - assertEquals(PropertyType.Boolean, serviceProperties[7].type()); - assertEquals(true, getValue(serviceProperties[7])); - - assertEquals("foo9", serviceProperties[8].key()); - assertEquals(PropertyType.Short, serviceProperties[8].type()); - assertEquals(new Short("32767"), getValue(serviceProperties[8])); - - assertEquals("foo11", serviceProperties[9].key()); - assertEquals(PropertyType.String_Array, serviceProperties[9].type()); - assertTrue(Arrays.equals(new String[] {"frog", "drum"}, (String[])getValue(serviceProperties[9]))); - - assertEquals("foo12", serviceProperties[10].key()); - assertEquals(PropertyType.Long_Array, serviceProperties[10].type()); - assertTrue(Arrays.equals(new Long[] {345987643L, 34L}, (Long[])getValue(serviceProperties[10]))); - - assertEquals("foo13", serviceProperties[11].key()); - assertEquals(PropertyType.Double_Array, serviceProperties[11].type()); - assertTrue(Arrays.equals(new Double[] {3459.87643D, 34.3456D}, (Double[])getValue(serviceProperties[11]))); - - assertEquals("foo14", serviceProperties[12].key()); - assertEquals(PropertyType.Float_Array, serviceProperties[12].type()); - assertTrue(Arrays.equals(new Float[] {3459.87F, 35.23F}, (Float[])getValue(serviceProperties[12]))); - - assertEquals("foo15", serviceProperties[13].key()); - assertEquals(PropertyType.Integer_Array, serviceProperties[13].type()); - assertTrue(Arrays.equals(new Integer[] {724559, 345}, (Integer[])getValue(serviceProperties[13]))); - - assertEquals("foo16", serviceProperties[14].key()); - assertEquals(PropertyType.Byte_Array, serviceProperties[14].type()); - assertTrue(Arrays.equals(new Byte[] {127, 23}, (Byte[])getValue(serviceProperties[14]))); - - assertEquals("foo17", serviceProperties[15].key()); - assertEquals(PropertyType.Character_Array, serviceProperties[15].type()); - assertTrue(Arrays.equals(new Character[] {'X', 't'}, (Character[])getValue(serviceProperties[15]))); - - assertEquals("foo18", serviceProperties[16].key()); - assertEquals(PropertyType.Boolean_Array, serviceProperties[16].type()); - assertTrue(Arrays.equals(new Boolean[] {true, false}, (Boolean[])getValue(serviceProperties[16]))); - - assertEquals("foo19", serviceProperties[17].key()); - assertEquals(PropertyType.Short_Array, serviceProperties[17].type()); - assertTrue(Arrays.equals(new Short[] {32767, 2345}, (Short[])getValue(serviceProperties[17]))); + Collection<String> beanClassNames = beansModel.getBeanClassNames(); + assertEquals(2, beanClassNames.size()); + assertEquals("com.foo.FooImpl", beanClassNames.iterator().next()); } AbstractModelBuilder getBuilder(final String osgiBeansFile) { return new AbstractModelBuilder() { @Override - Collection<String> getResources(String descriptorString) { - return null; + List<String> getDefaultResources() { + return Arrays.asList( + "OSGI-INF/cdi/beans-configuration.xml", + "OSGI-INF/cdi/beans-only.xml", + "OSGI-INF/cdi/beans-references.xml", + "OSGI-INF/cdi/beans-services.xml" + ); } @Override @@ -170,18 +164,14 @@ public class ModelTest extends TestCase @Override Map<String, Object> getAttributes() { + if (osgiBeansFile == null) { + return Collections.emptyMap(); + } + return Collections.singletonMap( - CdiExtenderConstants.REQUIREMENT_OSGI_BEANS_ATTRIBUTE, osgiBeansFile); + CdiConstants.REQUIREMENT_OSGI_BEANS_ATTRIBUTE, Arrays.asList(osgiBeansFile)); } }; } - Object getValue(ServiceProperty serviceProperty) { - Type type = serviceProperty.type().getType(); - String[] value = serviceProperty.value(); - return _converter.convert(value).to(type); - } - - private static final Converter _converter = new StandardConverter(); - }
Modified: aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-configuration.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-configuration.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-configuration.xml (original) +++ aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-configuration.xml Thu May 4 18:41:59 2017 @@ -1,8 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="com.foo.FooImpl" /> - <bean class="com.foo.BarImpl" /> - <configuration pid="com.foo.FooImpl" /> - <configuration pid="com.foo.other" /> -</cdi:beans> \ No newline at end of file +<beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <cdi:bean class="com.foo.FooImpl" /> + <cdi:bean class="com.foo.BarImpl" /> + <cdi:configuration beanClass="com.foo.Config" pid="com.foo.FooImpl" /> + <cdi:configuration beanClass="com.foo.Baz" pid="com.foo.other and.another" /> + <cdi:configuration beanClass="com.foo.Fum" required="false" pid="an.optional.configuration" /> +</beans> \ No newline at end of file Modified: aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-only.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-only.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-only.xml (original) +++ aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-only.xml Thu May 4 18:41:59 2017 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="com.foo.FooImpl" /> - <bean class="com.foo.BarImpl" /> -</cdi:beans> \ No newline at end of file +<beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <cdi:bean class="com.foo.FooImpl" /> + <cdi:bean class="com.foo.BarImpl" /> +</beans> \ No newline at end of file Modified: aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-references.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-references.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-references.xml (original) +++ aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-references.xml Thu May 4 18:41:59 2017 @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="com.foo.FooImpl" /> - <bean class="com.foo.BarImpl" /> - <reference beanClass="java.util.concurrent.Callable" target="(objectClass=java.util.concurrent.Callable)" /> - <reference beanClass="java.util.Map" target="(objectClass=java.util.Map)" /> -</cdi:beans> \ No newline at end of file +<beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <cdi:bean class="com.foo.FooImpl" /> + <cdi:bean class="com.foo.BarImpl" /> + <cdi:reference beanClass="java.util.concurrent.Callable" target="(objectClass=java.util.concurrent.Callable)" /> + <cdi:reference beanClass="java.util.Map" target="(objectClass=java.util.Map)" /> +</beans> \ No newline at end of file Modified: aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-services.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-services.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-services.xml (original) +++ aries/trunk/cdi/cdi-extender/src/test/resources/OSGI-INF/cdi/beans-services.xml Thu May 4 18:41:59 2017 @@ -1,56 +1,90 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="com.foo.FooImpl"> +<beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <cdi:bean class="com.foo.FooImpl"> <service> <provide interface="com.foo.Foo" /> <provide interface="java.lang.Clonable" /> - <property name="foo" type="String" value="fum" /> - <property name="foo2" type="Long" value="345987643" /> - <property name="foo3" type="Double" value="3459.87643" /> - <property name="foo4" type="Float" value="3459.87" /> - <property name="foo5" type="Integer" value="724559" /> - <property name="foo6" type="Byte" value="127" /> - <property name="foo7" type="Character" value="X" /> - <property name="foo8" type="Boolean" value="true" /> - <property name="foo9" type="Short" value="32767" /> - <property name="foo11" type="String"> - frog - drum - </property> - <property name="foo12" type="Long"> - 345987643 - 34 - </property> - <property name="foo13" type="Double"> - 3459.87643 - 34.3456 - </property> - <property name="foo14" type="Float"> - 3459.87 - 35.23 - </property> - <property name="foo15" type="Integer"> - 724559 - 345 - </property> - <property name="foo16" type="Byte"> - 127 - 23 - </property> - <property name="foo17" type="Character"> - X - t - </property> - <property name="foo18" type="Boolean"> - true - false - </property> - <property name="foo19" type="Short"> - 32767 - 2345 + <property name="foo" value-type="String" value="fum" /> + <property name="foo1" value="baz" /> + <property name="foo2" value-type="Long" value="345987643" /> + <property name="foo3" value-type="Double" value="3459.87643" /> + <property name="foo4" value-type="Float" value="3459.87" /> + <property name="foo5" value-type="Integer" value="724559" /> + <property name="foo6" value-type="Byte" value="127" /> + <property name="foo7" value-type="Character" value="X" /> + <property name="foo8" value-type="Boolean" value="true" /> + <property name="foo9" value-type="Short" value="32767" /> + <property name="foo11"> + <array> + <value>frog</value> + <value>drum</value> + </array> + </property> + <property name="foo12" value-type="Long"> + <array> + <value>345987643</value> + <value>34</value> + </array> + </property> + <property name="foo13" value-type="Double"> + <array> + <value>3459.87643</value> + <value>34.3456</value> + </array> + </property> + <property name="foo14" value-type="Float"> + <array> + <value>3459.87</value> + <value>35.23</value> + </array> + </property> + <property name="foo15" value-type="Integer"> + <array> + <value>724559</value> + <value>345</value> + </array> + </property> + <property name="foo16" value-type="Byte"> + <array> + <value>127</value> + <value>23</value> + </array> + </property> + <property name="foo17" value-type="Character"> + <array> + <value>X</value> + <value>t</value> + </array> + </property> + <property name="foo18" value-type="Boolean"> + <array> + <value>true</value> + <value>false</value> + </array> + </property> + <property name="foo19" value-type="Short"> + <array> + <value>32767</value> + <value>2345</value> + </array> + </property> + <property name="foo20" value-type="String"> + bar + </property> + <property name="foo21" value-type="Short"> + <list> + <value>32767</value> + <value>2345</value> + </list> + </property> + <property name="foo22" value-type="Short"> + <set> + <value>32767</value> + <value>2345</value> + </set> </property> </service> - </bean> - <bean class="com.foo.BarImpl" /> -</cdi:beans> \ No newline at end of file + </cdi:bean> + <cdi:bean class="com.foo.BarImpl" /> +</beans> \ No newline at end of file Modified: aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/Activator.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/Activator.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/Activator.java (original) +++ aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/Activator.java Thu May 4 18:41:59 2017 @@ -23,7 +23,7 @@ import javax.naming.spi.ObjectFactory; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import org.osgi.service.cdi.CdiExtenderConstants; +import org.osgi.service.cdi.CdiConstants; import org.osgi.service.jndi.JNDIConstants; public class Activator implements BundleActivator { @@ -31,27 +31,20 @@ public class Activator implements Bundle @Override public void start(BundleContext bundleContext) throws Exception { Dictionary<String, Object> properties = new Hashtable<>(); - properties.put(CdiExtenderConstants.CDI_EXTENSION, "jndi"); - JndiExtensionFactory jndiExtensionFactory = new JndiExtensionFactory(); - - _jndiExtensionFactoryRegistration = bundleContext.registerService( - Extension.class, jndiExtensionFactory, properties); - - properties = new Hashtable<>(); + properties.put(CdiConstants.CDI_EXTENSION_NAMESPACE, "jndi"); properties.put(JNDIConstants.JNDI_URLSCHEME, "java"); - _objectFactoryRegistration = bundleContext.registerService( - ObjectFactory.class, new JndiObjectFactory(jndiExtensionFactory), properties); + _serviceRegistration = bundleContext.registerService( + new String[] {Extension.class.getName(), ObjectFactory.class.getName()}, + new JndiExtensionFactory(), properties); } @Override public void stop(BundleContext bundleContext) throws Exception { - _objectFactoryRegistration.unregister(); - _jndiExtensionFactoryRegistration.unregister(); + _serviceRegistration.unregister(); } - private ServiceRegistration<?> _jndiExtensionFactoryRegistration; - private ServiceRegistration<?> _objectFactoryRegistration; + private ServiceRegistration<?> _serviceRegistration; } Modified: aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtension.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtension.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtension.java (original) +++ aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtension.java Thu May 4 18:41:59 2017 @@ -1,20 +1,32 @@ package org.apache.aries.cdi.extension.jndi; +import java.util.Hashtable; + import javax.enterprise.event.Observes; import javax.enterprise.inject.spi.AfterDeploymentValidation; import javax.enterprise.inject.spi.BeanManager; import javax.enterprise.inject.spi.Extension; +import javax.naming.Name; +import javax.naming.spi.ObjectFactory; + +public class JndiExtension implements Extension, ObjectFactory { + + @Override + public Object getObjectInstance( + Object obj, Name name, javax.naming.Context context, Hashtable<?, ?> environment) + throws Exception { -public class JndiExtension implements Extension { + if (obj == null) { + return _jndiContext; + } - public BeanManager getBeanManager() { - return _beanManager; + return null; } void afterDeploymentValidation(@Observes AfterDeploymentValidation adv, BeanManager beanManager) { - _beanManager = beanManager; + _jndiContext = new JndiContext(beanManager); } - private BeanManager _beanManager; + private JndiContext _jndiContext; } Modified: aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtensionFactory.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtensionFactory.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtensionFactory.java (original) +++ aries/trunk/cdi/cdi-extension-jndi/src/main/java/org/apache/aries/cdi/extension/jndi/JndiExtensionFactory.java Thu May 4 18:41:59 2017 @@ -1,65 +1,19 @@ package org.apache.aries.cdi.extension.jndi; -import java.util.Hashtable; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.enterprise.inject.spi.Extension; -import javax.naming.Name; -import javax.naming.spi.ObjectFactory; - import org.osgi.framework.Bundle; import org.osgi.framework.ServiceFactory; import org.osgi.framework.ServiceRegistration; -public class JndiExtensionFactory implements ServiceFactory<Extension> { +public class JndiExtensionFactory implements ServiceFactory { @Override - public Extension getService(Bundle bundle, ServiceRegistration<Extension> registration) { - JndiExtension jndiExtension = new JndiExtension(); - _map.put(bundle, jndiExtension); - return jndiExtension; + public Object getService(Bundle bundle, ServiceRegistration registration) { + return new JndiExtension(); } @Override public void ungetService( - Bundle bundle, ServiceRegistration<Extension> registration, Extension extension) { - - _map.remove(bundle); - } - - ObjectFactory getObjectFactory(Bundle bundle) { - JndiExtension jndiExtension = _map.get(bundle); - - if (jndiExtension == null) { - return null; - } - - return new InnerObjectFactory(new JndiContext(jndiExtension.getBeanManager())); - } - - private final Map<Bundle, JndiExtension> _map = new ConcurrentHashMap<>(); - - private class InnerObjectFactory implements ObjectFactory { - - public InnerObjectFactory(JndiContext jndiContext) { - _jndiContext = jndiContext; - } - - @Override - public Object getObjectInstance( - Object obj, Name name, javax.naming.Context context, Hashtable<?, ?> environment) - throws Exception { - - if (obj == null) { - return _jndiContext; - } - - return null; - } - - private final JndiContext _jndiContext; - + Bundle bundle, ServiceRegistration registration, Object extension) { } } Modified: aries/trunk/cdi/cdi-itests/bnd.bnd URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/bnd.bnd?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/bnd.bnd (original) +++ aries/trunk/cdi/cdi-itests/bnd.bnd Thu May 4 18:41:59 2017 @@ -25,7 +25,8 @@ p = org.apache.aries.cdi.test tb1.jar,\ tb2.jar,\ tb3.jar,\ - tb4.jar + tb4.jar,\ + tb5.jar # Don't forget that we had to coax the `maven-jar-plugin` NOT to include the `sub-bundle` packages in # the root bundle: Modified: aries/trunk/cdi/cdi-itests/bnd/basic-beans.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/bnd/basic-beans.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/bnd/basic-beans.xml (original) +++ aries/trunk/cdi/cdi-itests/bnd/basic-beans.xml Thu May 4 18:41:59 2017 @@ -1,19 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="org.apache.aries.cdi.test.beans.BeanWithReference" /> - <bean class="org.apache.aries.cdi.test.beans.BundleContextBean" /> - <bean class="org.apache.aries.cdi.test.beans.CdiEventObserver" /> - <bean class="org.apache.aries.cdi.test.beans.ConstructorInjectedService" /> - <bean class="org.apache.aries.cdi.test.beans.FieldInjectedBundleScopedImpl" /> - <bean class="org.apache.aries.cdi.test.beans.FieldInjectedPrototypeScopedImpl" /> - <bean class="org.apache.aries.cdi.test.beans.FieldInjectedService" /> - <bean class="org.apache.aries.cdi.test.beans.InstanceBean" /> - <bean class="org.apache.aries.cdi.test.beans.InstanceCardinality0Bean" /> - <bean class="org.apache.aries.cdi.test.beans.InstanceOrderBean" /> - <bean class="org.apache.aries.cdi.test.beans.InstancePropertiesBean" /> - <bean class="org.apache.aries.cdi.test.beans.InstanceServiceReferenceBean" /> - <bean class="org.apache.aries.cdi.test.beans.MethodInjectedService" /> - <bean class="org.apache.aries.cdi.test.beans.PojoImpl" /> - <bean class="org.apache.aries.cdi.test.beans.ServiceWithProperties" /> -</cdi:beans> \ No newline at end of file +<beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <cdi:bean class="org.apache.aries.cdi.test.beans.BeanWithReference" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.BundleContextBean" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.CdiEventObserver" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.ConstructorInjectedService" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.FieldInjectedBundleScopedImpl" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.FieldInjectedPrototypeScopedImpl" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.FieldInjectedService" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.Instance_Optional" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.Instance_ServiceProperties" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.Instance_ServiceReference" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.MethodInjectedService" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.PojoImpl" /> + <cdi:bean class="org.apache.aries.cdi.test.beans.ServiceWithProperties" /> +</beans> \ No newline at end of file Modified: aries/trunk/cdi/cdi-itests/bnd/tb1-beans.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/bnd/tb1-beans.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/bnd/tb1-beans.xml (original) +++ aries/trunk/cdi/cdi-itests/bnd/tb1-beans.xml Thu May 4 18:41:59 2017 @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="org.apache.aries.cdi.test.tb1.BeanImpl" /> - <reference +<beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <cdi:bean class="org.apache.aries.cdi.test.tb1.BeanImpl" /> + <cdi:reference beanClass="org.apache.aries.cdi.test.interfaces.Pojo" target="(objectClass=org.apache.aries.cdi.test.interfaces.Pojo)" /> -</cdi:beans> \ No newline at end of file +</beans> \ No newline at end of file Modified: aries/trunk/cdi/cdi-itests/bnd/tb2-beans.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/bnd/tb2-beans.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/bnd/tb2-beans.xml (original) +++ aries/trunk/cdi/cdi-itests/bnd/tb2-beans.xml Thu May 4 18:41:59 2017 @@ -1,9 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="org.apache.aries.cdi.test.tb2.PojoImpl"> - <service> - <provide interface="org.apache.aries.cdi.test.interfaces.Pojo" /> - </service> - </bean> -</cdi:beans> \ No newline at end of file +<cdi:bean class="org.apache.aries.cdi.test.tb2.PojoImpl" xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <service> + <provide interface="org.apache.aries.cdi.test.interfaces.Pojo" /> + </service> +</cdi:bean> Modified: aries/trunk/cdi/cdi-itests/bnd/tb3-beans.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/bnd/tb3-beans.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/bnd/tb3-beans.xml (original) +++ aries/trunk/cdi/cdi-itests/bnd/tb3-beans.xml Thu May 4 18:41:59 2017 @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="org.apache.aries.cdi.test.tb3.ConfigurationBeanA" /> -</cdi:beans> \ No newline at end of file +<beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <cdi:bean class="org.apache.aries.cdi.test.tb3.ConfigurationBeanA" /> + <cdi:bean class="org.apache.aries.cdi.test.tb3.ConfigurationBeanB" /> +</beans> Modified: aries/trunk/cdi/cdi-itests/bnd/tb4-beans.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/bnd/tb4-beans.xml?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/bnd/tb4-beans.xml (original) +++ aries/trunk/cdi/cdi-itests/bnd/tb4-beans.xml Thu May 4 18:41:59 2017 @@ -1,10 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<cdi:beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> - <bean class="org.apache.aries.cdi.test.tb4.CallableImpl"> - <service> - <provide interface="java.util.concurrent.Callable" /> - <property name="a.service.property" value="The Value" type="String"/> - </service> - </bean> -</cdi:beans> \ No newline at end of file +<cdi:bean class="org.apache.aries.cdi.test.tb4.CallableImpl" xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <service> + <property name="a.service.property" value="The Value" type="String"/> + <provide interface="java.util.concurrent.Callable" /> + </service> +</cdi:bean> Added: aries/trunk/cdi/cdi-itests/bnd/tb5-beans.xml URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/bnd/tb5-beans.xml?rev=1793847&view=auto ============================================================================== --- aries/trunk/cdi/cdi-itests/bnd/tb5-beans.xml (added) +++ aries/trunk/cdi/cdi-itests/bnd/tb5-beans.xml Thu May 4 18:41:59 2017 @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<beans xmlns:cdi="http://www.osgi.org/xmlns/cdi/v1.0.0"> + <cdi:bean class="org.apache.aries.cdi.test.tb5.ConfigurationBeanC" /> +</beans> Added: aries/trunk/cdi/cdi-itests/bnd/tb5.bnd URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/bnd/tb5.bnd?rev=1793847&view=auto ============================================================================== --- aries/trunk/cdi/cdi-itests/bnd/tb5.bnd (added) +++ aries/trunk/cdi/cdi-itests/bnd/tb5.bnd Thu May 4 18:41:59 2017 @@ -0,0 +1,3 @@ +Export-Package: ${p}.tb5.* +Require-Capability: osgi.extender;filter:='(osgi.extender=osgi.cdi)' +-includeresource: OSGI-INF/cdi/osgi-beans.xml=bnd/tb5-beans.xml \ No newline at end of file Modified: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/BeanWithReference.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/BeanWithReference.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/BeanWithReference.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/BeanWithReference.java Thu May 4 18:41:59 2017 @@ -5,17 +5,16 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.enterprise.inject.Default; import javax.inject.Inject; import javax.inject.Qualifier; import org.apache.aries.cdi.test.interfaces.BundleScoped; import org.osgi.service.cdi.annotations.Reference; -import org.osgi.service.cdi.annotations.ReferenceFilter; public class BeanWithReference { @Qualifier - @ReferenceFilter @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR }) public @interface ComplexEnoughKey { @@ -23,7 +22,6 @@ public class BeanWithReference { } @Qualifier - @ReferenceFilter @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR }) public @interface ComplexAnnotation { @@ -31,10 +29,19 @@ public class BeanWithReference { int fo_fum(); } + @Qualifier + @Retention(value = RetentionPolicy.RUNTIME) + @Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR }) + public @interface SimpleAnnotation { + String value(); + } + @ComplexEnoughKey(complex_enough_key= "fum") @ComplexAnnotation(fee_fi = "fee", fo_fum = 23) + @SimpleAnnotation("blah") @Inject @Reference + @Default BundleScoped bundleScoped; } Copied: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_Optional.java (from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceCardinality0Bean.java) URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_Optional.java?p2=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_Optional.java&p1=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceCardinality0Bean.java&r1=1792762&r2=1793847&rev=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceCardinality0Bean.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_Optional.java Thu May 4 18:41:59 2017 @@ -8,13 +8,12 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.apache.aries.cdi.test.interfaces.BeanService; -import org.osgi.service.cdi.annotations.MinCardinality; import org.osgi.service.cdi.annotations.Reference; import org.osgi.service.cdi.annotations.Service; -@Service(type = {BeanService.class, InstanceCardinality0Bean.class}) +@Service(type = {BeanService.class, Instance_Optional.class}) @Singleton -public class InstanceCardinality0Bean implements BeanService<Callable<String>> { +public class Instance_Optional implements BeanService<Callable<String>> { @Override public String doSomething() { @@ -33,7 +32,6 @@ public class InstanceCardinality0Bean im } @Inject - @MinCardinality(0) @Reference Instance<Callable<String>> _instance; Copied: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceProperties.java (from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstancePropertiesBean.java) URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceProperties.java?p2=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceProperties.java&p1=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstancePropertiesBean.java&r1=1792762&r2=1793847&rev=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstancePropertiesBean.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceProperties.java Thu May 4 18:41:59 2017 @@ -12,9 +12,9 @@ import org.apache.aries.cdi.test.interfa import org.osgi.service.cdi.annotations.Reference; import org.osgi.service.cdi.annotations.Service; -@Service(type = {BeanService.class, InstancePropertiesBean.class}) +@Service(type = {BeanService.class, Instance_ServiceProperties.class}) @Singleton -public class InstancePropertiesBean implements BeanService<Map<String, Object>> { +public class Instance_ServiceProperties implements BeanService<Map<String, Object>> { @Override public String doSomething() { Copied: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceReference.java (from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceServiceReferenceBean.java) URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceReference.java?p2=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceReference.java&p1=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceServiceReferenceBean.java&r1=1792762&r2=1793847&rev=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/InstanceServiceReferenceBean.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/Instance_ServiceReference.java Thu May 4 18:41:59 2017 @@ -12,10 +12,10 @@ import org.osgi.framework.ServiceReferen import org.osgi.service.cdi.annotations.Reference; import org.osgi.service.cdi.annotations.Service; -@Service(type = {BeanService.class, InstanceServiceReferenceBean.class}) +@Service(type = {BeanService.class, Instance_ServiceReference.class}) @Singleton @SuppressWarnings("rawtypes") -public class InstanceServiceReferenceBean implements BeanService<ServiceReference> { +public class Instance_ServiceReference implements BeanService<ServiceReference> { @Override public String doSomething() { Modified: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/ServiceWithProperties.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/ServiceWithProperties.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/ServiceWithProperties.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/beans/ServiceWithProperties.java Thu May 4 18:41:59 2017 @@ -12,51 +12,119 @@ import javax.inject.Singleton; import org.apache.aries.cdi.test.beans.ServiceWithProperties.MoreProperties; import org.apache.aries.cdi.test.interfaces.BeanService; import org.apache.aries.cdi.test.interfaces.Pojo; -import org.osgi.service.cdi.annotations.PropertyType; import org.osgi.service.cdi.annotations.Service; -import org.osgi.service.cdi.annotations.ServiceProperty; @Service( - properties = { - @ServiceProperty(key = "test.key.b1", value = "test.value.b1"), - @ServiceProperty(key = "test.key.b2", value = "test.value.b2"), - - @ServiceProperty(key = "p.Boolean", value = "true", type = PropertyType.Boolean), - @ServiceProperty(key = "p.Boolean.array", value = {"true","false"}, type = PropertyType.Boolean_Array), - @ServiceProperty(key = "p.Boolean.list", value = {"false","true"}, type = PropertyType.Boolean_List), - @ServiceProperty(key = "p.Boolean.set", value = {"true", "true", "false"}, type = PropertyType.Boolean_Set), - @ServiceProperty(key = "p.Byte", value = "2", type = PropertyType.Byte), - @ServiceProperty(key = "p.Byte.array", value = {"2","34"}, type = PropertyType.Byte_Array), - @ServiceProperty(key = "p.Byte.list", value = {"34","2"}, type = PropertyType.Byte_List), - @ServiceProperty(key = "p.Byte.set", value = {"34","34","2"}, type = PropertyType.Byte_Set), - @ServiceProperty(key = "p.Character", value = "C", type = PropertyType.Character), - @ServiceProperty(key = "p.Character.array", value = {"C","D"}, type = PropertyType.Character_Array), - @ServiceProperty(key = "p.Character.list", value = {"D","C"}, type = PropertyType.Character_List), - @ServiceProperty(key = "p.Character.set", value = {"D","D","C"}, type = PropertyType.Character_Set), - @ServiceProperty(key = "p.Double", value = "2.5", type = PropertyType.Double), - @ServiceProperty(key = "p.Double.array", value = {"2.5","45.678"}, type = PropertyType.Double_Array), - @ServiceProperty(key = "p.Double.list", value = {"45.678","2.5"}, type = PropertyType.Double_List), - @ServiceProperty(key = "p.Double.set", value = {"45.678","45.678","2.5"}, type = PropertyType.Double_Set), - @ServiceProperty(key = "p.Float", value = "3.4", type = PropertyType.Float), - @ServiceProperty(key = "p.Float.array", value = {"3.4","78.9"}, type = PropertyType.Float_Array), - @ServiceProperty(key = "p.Float.list", value = {"78.9","3.4"}, type = PropertyType.Float_List), - @ServiceProperty(key = "p.Float.set", value = {"78.9","78.9","3.4"}, type = PropertyType.Float_Set), - @ServiceProperty(key = "p.Integer", value = "5", type = PropertyType.Integer), - @ServiceProperty(key = "p.Integer.array", value = {"5","34567"}, type = PropertyType.Integer_Array), - @ServiceProperty(key = "p.Integer.list", value = {"34567","5"}, type = PropertyType.Integer_List), - @ServiceProperty(key = "p.Integer.set", value = {"34567","34567","5"}, type = PropertyType.Integer_Set), - @ServiceProperty(key = "p.Long", value = "7", type = PropertyType.Long), - @ServiceProperty(key = "p.Long.array", value = {"7","7789654"}, type = PropertyType.Long_Array), - @ServiceProperty(key = "p.Long.list", value = {"7789654","7"}, type = PropertyType.Long_List), - @ServiceProperty(key = "p.Long.set", value = {"7789654","7789654","7"}, type = PropertyType.Long_Set), - @ServiceProperty(key = "p.Short", value = "25", type = PropertyType.Short), - @ServiceProperty(key = "p.Short.array", value = {"25","196"}, type = PropertyType.Short_Array), - @ServiceProperty(key = "p.Short.list", value = {"196","25"}, type = PropertyType.Short_List), - @ServiceProperty(key = "p.Short.set", value = {"196","196","25"}, type = PropertyType.Short_Set), - @ServiceProperty(key = "p.String", value = "black", type = PropertyType.String), - @ServiceProperty(key = "p.String.array", value = {"black","green"}, type = PropertyType.String_Array), - @ServiceProperty(key = "p.String.list", value = {"green","black"}, type = PropertyType.String_List), - @ServiceProperty(key = "p.String.set", value = {"green","green","black"}, type = PropertyType.String_Set) + property = { + "test.key.b1=test.value.b1", + "test.key.b2=test.value.b2", + + "p.Boolean:Boolean=true", + "p.Boolean.array:Boolean=true", + "p.Boolean.array:Boolean=false", + + "p.Boolean.list:List<Boolean>=false", + "p.Boolean.list:List<Boolean>=true", + + "p.Boolean.set:Set<Boolean>=true", + "p.Boolean.set:Set<Boolean>=true", + "p.Boolean.set:Set<Boolean>=false", + + "p.Byte:Byte=2", + + "p.Byte.array:Byte=2", + "p.Byte.array:Byte=34", + + "p.Byte.list:List<Byte>=34", + "p.Byte.list:List<Byte>=2", + + "p.Byte.set:Set<Byte>=34", + "p.Byte.set:Set<Byte>=34", + "p.Byte.set:Set<Byte>=2", + + "p.Character:Character=C", + + "p.Character.array:Character=C", + "p.Character.array:Character=D", + + "p.Character.list:List<Character>=D", + "p.Character.list:List<Character>=C", + + "p.Character.set:Set<Character>=D", + "p.Character.set:Set<Character>=D", + "p.Character.set:Set<Character>=C", + + "p.Double:Double=2.5", + + "p.Double.array:Double=2.5", + "p.Double.array:Double=45.678", + + "p.Double.list:List<Double>=45.678", + "p.Double.list:List<Double>=2.5", + + "p.Double.set:Set<Double>=45.678", + "p.Double.set:Set<Double>=45.678", + "p.Double.set:Set<Double>=2.5", + + "p.Float:Float=3.4", + + "p.Float.array:Float=3.4", + "p.Float.array:Float=78.9", + + "p.Float.list:List<Float>=78.9", + "p.Float.list:List<Float>=3.4", + + "p.Float.set:Set<Float>=78.9", + "p.Float.set:Set<Float>=78.9", + "p.Float.set:Set<Float>=3.4", + + "p.Integer:Integer=5", + + "p.Integer.array:Integer=5", + "p.Integer.array:Integer=34567", + + "p.Integer.list:List<Integer>=34567", + "p.Integer.list:List<Integer>=5", + + "p.Integer.set:Set<Integer>=34567", + "p.Integer.set:Set<Integer>=34567", + "p.Integer.set:Set<Integer>=5", + + "p.Long:Long=7", + + "p.Long.array:Long=7", + "p.Long.array:Long=7789654", + + "p.Long.list:List<Long>=7789654", + "p.Long.list:List<Long>=7", + + "p.Long.set:Set<Long>=7789654", + "p.Long.set:Set<Long>=7789654", + "p.Long.set:Set<Long>=7", + + "p.Short:Short=25", + + "p.Short.array:Short=25", + "p.Short.array:Short=196", + + "p.Short.list:List<Short>=196", + "p.Short.list:List<Short>=25", + + "p.Short.set:Set<Short>=196", + "p.Short.set:Set<Short>=196", + "p.Short.set:Set<Short>=25", + + "p.String=black", + + "p.String.array=black", + "p.String.array=green", + + "p.String.list:List<String>=green", + "p.String.list:List<String>=black", + + "p.String.set:Set<String>=green", + "p.String.set:Set<String>=green", + "p.String.set:Set<String>=black" }, type = {ServiceWithProperties.class, BeanService.class} ) Modified: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java Thu May 4 18:41:59 2017 @@ -21,9 +21,9 @@ import org.osgi.framework.InvalidSyntaxE import org.osgi.framework.wiring.BundleWire; import org.osgi.framework.wiring.BundleWiring; import org.osgi.namespace.extender.ExtenderNamespace; +import org.osgi.service.cdi.CdiConstants; import org.osgi.service.cdi.CdiContainer; import org.osgi.service.cdi.CdiEvent; -import org.osgi.service.cdi.CdiExtenderConstants; import org.osgi.util.tracker.ServiceTracker; import junit.framework.TestCase; @@ -76,7 +76,7 @@ public class AbstractTestCase extends Te Map<String, Object> attributes = wire.getCapability().getAttributes(); String extender = (String)attributes.get(ExtenderNamespace.EXTENDER_NAMESPACE); - if (CdiExtenderConstants.CDI_EXTENDER.equals(extender)) { + if (CdiConstants.CDI_CAPABILITY_NAME.equals(extender)) { return wire.getProvider().getBundle(); } } @@ -87,7 +87,7 @@ public class AbstractTestCase extends Te ServiceTracker<CdiContainer, CdiContainer> getServiceTracker(long bundleId) throws InvalidSyntaxException { Filter filter = bundleContext.createFilter( "(&(objectClass=" + CdiContainer.class.getName() + ")(service.bundleid=" + bundleId + ")(" + - CdiExtenderConstants.CDI_EXTENDER_CONTAINER_STATE + "=" + CdiEvent.Type.CREATED + "))"); + CdiConstants.CDI_CONTAINER_STATE + "=" + CdiEvent.Type.CREATED + "))"); ServiceTracker<CdiContainer, CdiContainer> serviceTracker = new ServiceTracker<>(bundleContext, filter, null); Modified: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/CdiBeanTests.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/CdiBeanTests.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/CdiBeanTests.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/CdiBeanTests.java Thu May 4 18:41:59 2017 @@ -14,7 +14,6 @@ import javax.enterprise.util.AnnotationL import org.apache.aries.cdi.test.interfaces.BeanService; import org.apache.aries.cdi.test.interfaces.BundleContextBeanQualifier; import org.apache.aries.cdi.test.interfaces.FieldInjectedReference; -import org.apache.aries.cdi.test.interfaces.SingletonScoped; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -234,28 +233,9 @@ public class CdiBeanTests extends Abstra assertTrue(bti.get() instanceof BundleContext); } - public void testInstance() throws Exception { - Iterator<ServiceReference<BeanService>> iterator = bundleContext.getServiceReferences( - BeanService.class, String.format("(objectClass=*.%s)","InstanceBean")).iterator(); - - assertTrue(iterator.hasNext()); - - ServiceReference<BeanService> serviceReference = iterator.next(); - - assertNotNull(serviceReference); - - @SuppressWarnings("unchecked") - BeanService<SingletonScoped<?>> bean = bundleContext.getService(serviceReference); - - assertNotNull(bean); - assertEquals(3, Integer.decode(bean.doSomething()).intValue()); - SingletonScoped<?> singletonScoped = bean.get(); - assertNotNull(singletonScoped); - } - public void testInstanceProperties() throws Exception { Iterator<ServiceReference<BeanService>> iterator = bundleContext.getServiceReferences( - BeanService.class, String.format("(objectClass=*.%s)","InstancePropertiesBean")).iterator(); + BeanService.class, String.format("(objectClass=*.%s)","Instance_ServiceProperties")).iterator(); assertTrue(iterator.hasNext()); @@ -274,7 +254,7 @@ public class CdiBeanTests extends Abstra public void testInstanceServiceReference() throws Exception { Iterator<ServiceReference<BeanService>> iterator = bundleContext.getServiceReferences( - BeanService.class, String.format("(objectClass=*.%s)","InstanceServiceReferenceBean")).iterator(); + BeanService.class, String.format("(objectClass=*.%s)","Instance_ServiceReference")).iterator(); assertTrue(iterator.hasNext()); @@ -291,31 +271,9 @@ public class CdiBeanTests extends Abstra assertNotNull(sr); } - public void testInstanceOrdering() throws Exception { - Iterator<ServiceReference<BeanService>> iterator = bundleContext.getServiceReferences( - BeanService.class, String.format("(objectClass=*.%s)","InstanceOrderBean")).iterator(); - - assertTrue(iterator.hasNext()); - - ServiceReference<BeanService> serviceReference = iterator.next(); - - assertNotNull(serviceReference); - - @SuppressWarnings("unchecked") - BeanService<List<ServiceReference<?>>> bean = bundleContext.getService(serviceReference); - - assertNotNull(bean); - assertEquals(3, Integer.decode(bean.doSomething()).intValue()); - List<ServiceReference<?>> sl = bean.get(); - assertNotNull(sl); - // TODO fix ordering! -// assertEquals(1, sl.get(0).compareTo(sl.get(1))); -// assertEquals(1, sl.get(1).compareTo(sl.get(2))); - } - - public void testInstanceCardinality0() throws Exception { + public void testInstance_Optional() throws Exception { Iterator<ServiceReference<BeanService>> iterator = bundleContext.getServiceReferences( - BeanService.class, String.format("(objectClass=*.%s)","InstanceCardinality0Bean")).iterator(); + BeanService.class, String.format("(objectClass=*.%s)","Instance_Optional")).iterator(); assertTrue(iterator.hasNext()); Modified: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/ConfigurationTests.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/ConfigurationTests.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/ConfigurationTests.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/ConfigurationTests.java Thu May 4 18:41:59 2017 @@ -1,30 +1,265 @@ package org.apache.aries.cdi.test.cases; +import static org.junit.Assert.assertArrayEquals; + +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; + +import javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.BeanManager; +import javax.enterprise.util.TypeLiteral; + +import org.apache.aries.cdi.test.interfaces.BeanService; +import org.osgi.framework.Bundle; +import org.osgi.framework.Filter; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cdi.CdiConstants; +import org.osgi.service.cdi.CdiContainer; +import org.osgi.service.cdi.CdiEvent; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.util.tracker.ServiceTracker; + public class ConfigurationTests extends AbstractTestCase { @SuppressWarnings({ "rawtypes", "unchecked" }) public void testConfiguration() throws Exception { -// Bundle tb3Bundle = installBundle("tb3.jar"); -// -// ServiceTracker<BeanService, BeanService> st = new ServiceTracker<BeanService, BeanService>( -// bundleContext, BeanService.class, null); -// st.open(true); -// -// try { -// BeanService<Callable<int[]>> beanService = st.waitForService(timeout); -// assertNotNull(beanService); -// } -// finally { -// tb3Bundle.uninstall(); -// } + Bundle tb3Bundle = installBundle("tb3.jar"); + + Configuration configurationA = null, configurationB = null; + + try { + Filter filter = bundleContext.createFilter( + "(&(objectClass=" + CdiContainer.class.getName() + ")(service.bundleid=" + tb3Bundle.getBundleId() + "))"); + + ServiceTracker<CdiContainer, CdiContainer> containerTracker = new ServiceTracker<>( + bundleContext, filter, null); + + containerTracker.open(); + + containerTracker.waitForService(timeout); + + ServiceReference<CdiContainer> serviceReference = containerTracker.getServiceReference(); + + assertNotNull(serviceReference); + + assertEquals( + CdiEvent.Type.WAITING_FOR_CONFIGURATIONS, + serviceReference.getProperty(CdiConstants.CDI_CONTAINER_STATE)); + + configurationA = configurationAdmin.getConfiguration("configA", "?"); + + Dictionary<String, Object> properties = new Hashtable<>(); + properties.put("ports", new int[] {12, 4567}); + configurationA.update(properties); + + configurationB = configurationAdmin.getConfiguration("configB", "?"); + + properties = new Hashtable<>(); + properties.put("color", "green"); + properties.put("ports", new int[] {80}); + configurationB.update(properties); + + containerTracker.close(); + + filter = bundleContext.createFilter( + "(&(objectClass=" + CdiContainer.class.getName() + ")(service.bundleid=" + tb3Bundle.getBundleId() + + ")(" + CdiConstants.CDI_CONTAINER_STATE + "=CREATED))"); + + containerTracker = new ServiceTracker<>(bundleContext, filter, null); + + containerTracker.open(); + + containerTracker.waitForService(timeout); + + ServiceTracker<BeanService, BeanService> stA = new ServiceTracker<BeanService, BeanService>( + bundleContext, bundleContext.createFilter( + "(&(objectClass=org.apache.aries.cdi.test.interfaces.BeanService)(bean=A))"), null); + stA.open(true); + + BeanService<Callable<int[]>> beanService = stA.waitForService(timeout); + + assertNotNull(beanService); + assertEquals("blue", beanService.doSomething()); + assertArrayEquals(new int[] {12, 4567}, beanService.get().call()); + + ServiceTracker<BeanService, BeanService> stB = new ServiceTracker<BeanService, BeanService>( + bundleContext, bundleContext.createFilter( + "(&(objectClass=org.apache.aries.cdi.test.interfaces.BeanService)(bean=B))"), null); + stB.open(true); + + beanService = stB.waitForService(timeout); + + assertNotNull(beanService); + assertEquals("green", beanService.doSomething()); + assertArrayEquals(new int[] {80}, beanService.get().call()); + } + finally { + if (configurationA != null) + configurationA.delete(); + if (configurationB != null) + configurationB.delete(); + tb3Bundle.uninstall(); + } + } + + @SuppressWarnings({ "unchecked", "serial" }) + public void testNamedConfiguration() throws Exception { + Bundle tb3Bundle = installBundle("tb3.jar"); + + Configuration configurationA = null, configurationB = null; + + try { + configurationA = configurationAdmin.getConfiguration("configA", "?"); + + Dictionary<String, Object> properties = new Hashtable<>(); + properties.put("ports", new int[] {12, 4567}); + configurationA.update(properties); + + configurationB = configurationAdmin.getConfiguration("configB", "?"); + + properties = new Hashtable<>(); + properties.put("color", "green"); + properties.put("ports", new int[] {80}); + configurationB.update(properties); + + Filter filter = bundleContext.createFilter( + "(&(objectClass=" + CdiContainer.class.getName() + ")(service.bundleid=" + tb3Bundle.getBundleId() + + ")(" + CdiConstants.CDI_CONTAINER_STATE + "=CREATED))"); + + ServiceTracker<CdiContainer, CdiContainer> serviceTracker = new ServiceTracker<>(bundleContext, filter, null); + + serviceTracker.open(); + + CdiContainer container = serviceTracker.waitForService(timeout); + + assertNotNull(container); + + int trackerCount = serviceTracker.getTrackingCount(); + + BeanManager beanManager = container.getBeanManager(); + Set<Bean<?>> beans = beanManager.getBeans("configB"); + assertNotNull(beans); + Bean<? extends Object> bean = beanManager.resolve(beans); + CreationalContext<?> ctx = beanManager.createCreationalContext(bean); + + Map<String, Object> config = (Map<String, Object>)beanManager.getReference( + bean, new TypeLiteral<Map<String, Object>>() {}.getType(), ctx); + + assertNotNull(config); + assertEquals("green", config.get("color")); + + assertArrayEquals(new int[] {80}, (int[])config.get("ports")); + + configurationA.delete(); + + while (trackerCount == serviceTracker.getTrackingCount()) { + Thread.sleep(10); + } + + assertTrue(serviceTracker.isEmpty()); + + serviceTracker.close(); + + filter = bundleContext.createFilter( + "(&(objectClass=" + CdiContainer.class.getName() + ")(service.bundleid=" + tb3Bundle.getBundleId() + + ")(" + CdiConstants.CDI_CONTAINER_STATE + "=" + CdiEvent.Type.WAITING_FOR_CONFIGURATIONS + "))"); + + serviceTracker = new ServiceTracker<>(bundleContext, filter, null); + + serviceTracker.open(); + + assertFalse(serviceTracker.isEmpty()); + } + finally { + if (configurationB != null) + configurationB.delete(); + tb3Bundle.uninstall(); + } + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testOptionalConfiguration() throws Exception { + Bundle tb5Bundle = installBundle("tb5.jar"); + + Configuration configurationC = null; + + try { + Filter filter = bundleContext.createFilter( + "(&(objectClass=" + CdiContainer.class.getName() + ")(service.bundleid=" + tb5Bundle.getBundleId() + + ")(" + CdiConstants.CDI_CONTAINER_STATE + "=CREATED))"); + + ServiceTracker<CdiContainer, CdiContainer> containerTracker = new ServiceTracker<>(bundleContext, filter, null); + + containerTracker.open(); + + containerTracker.waitForService(timeout); + + ServiceTracker<BeanService, BeanService> stC = new ServiceTracker<BeanService, BeanService>( + bundleContext, bundleContext.createFilter( + "(&(objectClass=org.apache.aries.cdi.test.interfaces.BeanService)(bean=C))"), null); + stC.open(true); + + BeanService<Callable<int[]>> beanService = stC.waitForService(timeout); + + int trackingCount = stC.getTrackingCount(); + + assertNotNull(beanService); + assertEquals("blue", beanService.doSomething()); + assertArrayEquals(new int[] {35777}, beanService.get().call()); + + configurationC = configurationAdmin.getConfiguration("foo.bar", "?"); + + Dictionary<String, Object> properties = new Hashtable<>(); + properties.put("ports", new int[] {12, 4567}); + configurationC.update(properties); + + do {Thread.sleep(100);} + while (trackingCount == stC.getTrackingCount()); + + beanService = stC.waitForService(timeout); + + trackingCount = stC.getTrackingCount(); + + assertNotNull(beanService); + assertEquals("blue", beanService.doSomething()); + assertArrayEquals(new int[] {12, 4567}, beanService.get().call()); + + configurationC.delete(); + + do {Thread.sleep(100);} + while (trackingCount == stC.getTrackingCount()); + + beanService = stC.waitForService(timeout); + + assertNotNull(beanService); + assertEquals("blue", beanService.doSomething()); + assertArrayEquals(new int[] {35777}, beanService.get().call()); + } + finally { + tb5Bundle.uninstall(); + } } @Override protected void setUp() throws Exception { + adminTracker = new ServiceTracker<>(bundleContext, ConfigurationAdmin.class, null); + + adminTracker.open(); + + configurationAdmin = adminTracker.getService(); } @Override protected void tearDown() throws Exception { + adminTracker.close(); } + private ServiceTracker<ConfigurationAdmin, ConfigurationAdmin> adminTracker; + private ConfigurationAdmin configurationAdmin; + } Modified: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/JndiExtensionTests.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/JndiExtensionTests.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/JndiExtensionTests.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/JndiExtensionTests.java Thu May 4 18:41:59 2017 @@ -13,9 +13,9 @@ import org.osgi.framework.ServiceReferen import org.osgi.framework.wiring.BundleCapability; import org.osgi.framework.wiring.BundleWiring; import org.osgi.resource.Capability; +import org.osgi.service.cdi.CdiConstants; import org.osgi.service.cdi.CdiContainer; import org.osgi.service.cdi.CdiEvent; -import org.osgi.service.cdi.CdiExtenderConstants; import org.osgi.service.jndi.JNDIConstants; import org.osgi.util.tracker.BundleTracker; import org.osgi.util.tracker.BundleTrackerCustomizer; @@ -46,7 +46,7 @@ public class JndiExtensionTests extends @Override public Bundle addingBundle(Bundle bundle, BundleEvent arg1) { List<BundleCapability> capabilities = bundle.adapt( - BundleWiring.class).getCapabilities(CdiExtenderConstants.CDI_EXTENSION); + BundleWiring.class).getCapabilities(CdiConstants.CDI_EXTENSION_NAMESPACE); if (capabilities.isEmpty()) { return null; @@ -87,21 +87,21 @@ public class JndiExtensionTests extends ServiceReference<CdiContainer> serviceReference = serviceReferences.iterator().next(); CdiEvent.Type state = (CdiEvent.Type)serviceReference.getProperty( - CdiExtenderConstants.CDI_EXTENDER_CONTAINER_STATE); + CdiConstants.CDI_CONTAINER_STATE); assertEquals(CdiEvent.Type.CREATED, state); extensionBundle.stop(); state = (CdiEvent.Type)serviceReference.getProperty( - CdiExtenderConstants.CDI_EXTENDER_CONTAINER_STATE); + CdiConstants.CDI_CONTAINER_STATE); assertEquals(CdiEvent.Type.WAITING_FOR_EXTENSIONS, state); extensionBundle.start(); state = (CdiEvent.Type)serviceReference.getProperty( - CdiExtenderConstants.CDI_EXTENDER_CONTAINER_STATE); + CdiConstants.CDI_CONTAINER_STATE); assertEquals(CdiEvent.Type.CREATED, state); } Modified: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/components/ServiceBundleScope.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/components/ServiceBundleScope.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/components/ServiceBundleScope.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/components/ServiceBundleScope.java Thu May 4 18:41:59 2017 @@ -9,7 +9,8 @@ import org.osgi.service.component.annota "fee.fi=fee", "fo.fum:Integer=23", "complex.enough.key=fum", - "key=value" + "key=value", + "simple.annotation=blah" }, scope = ServiceScope.BUNDLE ) Added: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/Config.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/Config.java?rev=1793847&view=auto ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/Config.java (added) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/Config.java Thu May 4 18:41:59 2017 @@ -0,0 +1,9 @@ +package org.apache.aries.cdi.test.tb3; + +@interface Config { + + String color() default "blue"; + + int[] ports() default 35777; + +} \ No newline at end of file Modified: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java?rev=1793847&r1=1793846&r2=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java Thu May 4 18:41:59 2017 @@ -3,12 +3,13 @@ package org.apache.aries.cdi.test.tb3; import java.util.concurrent.Callable; import javax.inject.Inject; +import javax.inject.Named; import org.apache.aries.cdi.test.interfaces.BeanService; import org.osgi.service.cdi.annotations.Configuration; import org.osgi.service.cdi.annotations.Service; -@Service +@Service(property = "bean=A") public class ConfigurationBeanA implements BeanService<Callable<int[]>> { @Override @@ -28,14 +29,7 @@ public class ConfigurationBeanA implemen @Configuration @Inject + @Named("configA") Config config; } - -@interface Config { - - String color() default "blue"; - - int[] ports() default 35777; - -} Copied: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanB.java (from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java) URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanB.java?p2=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanB.java&p1=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java&r1=1792762&r2=1793847&rev=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanB.java Thu May 4 18:41:59 2017 @@ -1,19 +1,21 @@ package org.apache.aries.cdi.test.tb3; +import java.util.Map; import java.util.concurrent.Callable; import javax.inject.Inject; +import javax.inject.Named; import org.apache.aries.cdi.test.interfaces.BeanService; import org.osgi.service.cdi.annotations.Configuration; import org.osgi.service.cdi.annotations.Service; -@Service -public class ConfigurationBeanA implements BeanService<Callable<int[]>> { +@Service(property = "bean=B") +public class ConfigurationBeanB implements BeanService<Callable<int[]>> { @Override public String doSomething() { - return config.color(); + return (String)config.get("color"); } @Override @@ -21,21 +23,14 @@ public class ConfigurationBeanA implemen return new Callable<int[]>() { @Override public int[] call() throws Exception { - return config.ports(); + return (int[])config.get("ports"); } }; } - @Configuration + @Configuration({"$", "configA"}) @Inject - Config config; - -} - -@interface Config { - - String color() default "blue"; - - int[] ports() default 35777; + @Named("configB") + Map<String, Object> config; } Added: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/Config.java URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/Config.java?rev=1793847&view=auto ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/Config.java (added) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/Config.java Thu May 4 18:41:59 2017 @@ -0,0 +1,9 @@ +package org.apache.aries.cdi.test.tb5; + +@interface Config { + + String color() default "blue"; + + int[] ports() default 35777; + +} \ No newline at end of file Copied: aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/ConfigurationBeanC.java (from r1792762, aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java) URL: http://svn.apache.org/viewvc/aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/ConfigurationBeanC.java?p2=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/ConfigurationBeanC.java&p1=aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java&r1=1792762&r2=1793847&rev=1793847&view=diff ============================================================================== --- aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb3/ConfigurationBeanA.java (original) +++ aries/trunk/cdi/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb5/ConfigurationBeanC.java Thu May 4 18:41:59 2017 @@ -1,15 +1,16 @@ -package org.apache.aries.cdi.test.tb3; +package org.apache.aries.cdi.test.tb5; import java.util.concurrent.Callable; import javax.inject.Inject; +import javax.inject.Named; import org.apache.aries.cdi.test.interfaces.BeanService; import org.osgi.service.cdi.annotations.Configuration; import org.osgi.service.cdi.annotations.Service; -@Service -public class ConfigurationBeanA implements BeanService<Callable<int[]>> { +@Service(property = "bean=C") +public class ConfigurationBeanC implements BeanService<Callable<int[]>> { @Override public String doSomething() { @@ -26,16 +27,9 @@ public class ConfigurationBeanA implemen }; } - @Configuration + @Configuration(required = false, value = "foo.bar") @Inject + @Named("configC") Config config; } - -@interface Config { - - String color() default "blue"; - - int[] ports() default 35777; - -}
