aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r1075149 [21/23] - in /aries/tags/blueprint-0.3.1: ./ blueprint-annotation-api/ blueprint-annotation-api/src/ blueprint-annotation-api/src/main/ blueprint-annotation-api/src/main/java/ blueprint-annotation-api/src/main/java/org/ blueprint-a...
Date Sun, 27 Feb 2011 21:21:22 GMT
Added: aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerBTCustomizerTest.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.itests;
+
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.framework.CompositeBundle;
+import org.osgi.service.framework.CompositeBundleFactory;
+
+/**
+ * This test is based on the BlueprintContainerTest.  The difference is that in this test,
+ * the blueprint sample is installed into a child framework that is associated with a composite
+ * bundle created from CompositeBundleFactory.  This test only runs when the CompositeBundleFactory 
+ * service is avail in the OSGi service registry.
+ *
+ */
+@RunWith(JUnit4TestRunner.class)
+public class BlueprintContainerBTCustomizerTest extends AbstractIntegrationTest {
+
+    @Test
+    public void test() throws Exception {
+        // Create a config to check the property placeholder
+        ConfigurationAdmin ca = getOsgiService(ConfigurationAdmin.class);
+        Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
+        Hashtable props = new Hashtable();
+        props.put("key.b", "10");
+        cf.update(props);
+
+        
+        ServiceReference sr = bundleContext.getServiceReference("org.osgi.service.framework.CompositeBundleFactory");
+        if (sr != null) {
+             // install blueprint.sample into the composite context
+            CompositeBundleFactory cbf = (CompositeBundleFactory)bundleContext.getService(sr);
+            
+            Map<String, String> frameworkConfig = new HashMap<String, String>();
+            // turn on the line below to enable telnet localhost 10000 to the child framework osgi console
+            // frameworkConfig.put("osgi.console", "10000");
+            
+            // construct composite bundle information
+            Map<String, String> compositeManifest = new HashMap<String, String>();
+            compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, "test-composite");
+            compositeManifest.put(Constants.BUNDLE_VERSION, "1.0.0");
+            // this import-package is used by the blueprint.sample
+            compositeManifest.put(Constants.IMPORT_PACKAGE, "org.osgi.service.blueprint;version=\"[1.0.0,2.0.0)\", org.osgi.service.blueprint.container;version=1.0");
+            // this export-package is used by pax junit runner as it needs to see the blueprint sample package 
+            // for the test after the blueprint sample is started.
+            compositeManifest.put(Constants.EXPORT_PACKAGE, "org.apache.aries.blueprint.sample");
+            
+            CompositeBundle cb = cbf.installCompositeBundle(frameworkConfig, "test-composite", compositeManifest);
+
+            BundleContext compositeBundleContext = cb.getCompositeFramework().getBundleContext();
+            // install the blueprint sample onto the framework associated with the composite bundle
+            MavenArtifactProvisionOption mapo = mavenBundleInTest("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample");
+            // let's use input stream to avoid invoking mvn url handler which isn't avail in the child framework.
+            InputStream is = new URL(mapo.getURL()).openStream();
+            Bundle bundle = compositeBundleContext.installBundle(mapo.getURL(), is);
+            assertNotNull(bundle);
+            
+            // start the composite bundle then the blueprint sample
+            cb.start();
+            bundle.start();
+
+            // do the test
+            testBlueprintContainer(compositeBundleContext, bundle);
+            
+            // unget the service
+            bundleContext.ungetService(sr);
+            
+        }
+    }
+
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        Option[] options = options(
+            // Log
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+            // Felix Config Admin
+            mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+            // Felix mvn url handler
+            mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+
+            // this is how you set the default log level when using pax logging (logProfile)
+            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+            // Bundles
+            mavenBundle("org.apache.aries", "org.apache.aries.util"),
+            mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+            mavenBundle("asm", "asm-all"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+            // don't install the blueprint sample here as it will be installed onto the same framework as the blueprint core bundle
+            //mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample").noStart(),
+            mavenBundle("org.osgi", "org.osgi.compendium"),
+//            org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+
+            /* For debugging, uncomment the next two lines */
+//          vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"),
+//          waitForFrameworkStartup(),
+
+          /* For debugging, uncomment the next two lines
+          and add these imports:
+          import static org.ops4j.pax.exam.CoreOptions.waitForFrameworkStartup;
+          import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+          */
+            equinox().version("3.5.1")
+        );
+        options = updateOptions(options);
+        return options;
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/BlueprintContainerTest.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.text.SimpleDateFormat;
+import java.util.Currency;
+import java.util.Hashtable;
+import java.util.HashSet;
+
+import org.apache.aries.blueprint.sample.Bar;
+import org.apache.aries.blueprint.sample.Foo;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+@RunWith(JUnit4TestRunner.class)
+public class BlueprintContainerTest extends AbstractIntegrationTest {
+
+    @Test
+    public void test() throws Exception {
+        // Create a config to check the property placeholder
+        ConfigurationAdmin ca = getOsgiService(ConfigurationAdmin.class);
+        Configuration cf = ca.getConfiguration("blueprint-sample-placeholder", null);
+        Hashtable props = new Hashtable();
+        props.put("key.b", "10");
+        cf.update(props);
+
+        Bundle bundle = getInstalledBundle("org.apache.aries.blueprint.sample");
+        assertNotNull(bundle);
+
+        bundle.start();
+        
+        // do the test
+        testBlueprintContainer(bundle);
+    }
+    
+    @Test
+    public void testDeadlock() throws Exception {
+      bundleContext.registerService("java.util.Set",new HashSet<Object>(), null);
+      
+      Bundle bundle = getInstalledBundle("org.apache.aries.blueprint.sample");
+      assertNotNull(bundle);
+
+      bundle.start();
+      
+      getBlueprintContainerForBundle(bundleContext, "org.apache.aries.blueprint.sample",DEFAULT_TIMEOUT);
+      
+      // no actual assertions, we just don't want to deadlock
+    }
+
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        Option[] options = options(
+            // Log
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+            // Felix Config Admin
+            mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+            // Felix mvn url handler
+            mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+
+            // this is how you set the default log level when using pax logging (logProfile)
+            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+            // Bundles
+            mavenBundle("org.apache.aries", "org.apache.aries.util"),
+            mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+            mavenBundle("asm", "asm-all"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample").noStart(),
+            mavenBundle("org.osgi", "org.osgi.compendium"),
+            //org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+
+            equinox().version("3.5.0")
+        );
+        options = updateOptions(options);
+        return options;
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.itests;
+
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+@RunWith(JUnit4TestRunner.class)
+public class MultiBundleWithAsmTest extends AbstractMultiBundleTest{
+    @Test
+    public void doMultiBundleAsmTest() throws Exception{
+        doCommonMultiBundleTest();
+    }
+    
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        Option[] options = options(
+            // Log
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+            // Felix Config Admin
+            mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+            // Felix mvn url handler
+            mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+            // this is how you set the default log level when using pax logging (logProfile)
+            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+            // Bundles
+            mavenBundle("org.apache.aries", "org.apache.aries.util"),
+            mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+            mavenBundle("asm", "asm-all"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.testbundlea").noStart(),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.testbundleb").noStart(),
+            mavenBundle("org.osgi", "org.osgi.compendium"),
+            // org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+
+            equinox().version("3.5.0")
+        );
+        options = updateOptions(options);
+        return options;
+    }     
+}

Added: aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,410 @@
+/*  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.itests;
+
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.OptionUtils.combine;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.aries.blueprint.testquiescebundle.TestBean;
+import org.apache.aries.quiesce.manager.QuiesceCallback;
+import org.apache.aries.quiesce.participant.QuiesceParticipant;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.container.def.options.VMOption;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.options.BootDelegationOption;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.util.tracker.ServiceTracker;
+
+@RunWith(JUnit4TestRunner.class)
+public class QuiesceBlueprintTest extends AbstractIntegrationTest{
+
+  private static class TestQuiesceCallback implements QuiesceCallback
+  {
+    private int calls = 0;
+
+	public void bundleQuiesced(Bundle... bundlesQuiesced) {
+		System.out.println("bundleQuiesced "+ bundlesQuiesced);
+	      calls++;
+	}
+	
+	public int getCalls() {
+		return calls;
+	}
+  }
+  
+  @Inject
+  protected BundleContext bundleContext;
+ 
+  
+  private QuiesceParticipant getParticipant(String bundleName) throws InvalidSyntaxException {
+    ServiceReference[] refs = bundleContext.getServiceReferences(QuiesceParticipant.class.getName(), null);
+    
+    if(refs != null) {
+      for(ServiceReference ref : refs) {
+        if(ref.getBundle().getSymbolicName().equals(bundleName))
+          return (QuiesceParticipant) bundleContext.getService(ref);
+        else System.out.println(ref.getBundle().getSymbolicName());
+      }
+    }
+    
+    
+    return null;
+  }
+
+  @org.ops4j.pax.exam.junit.Configuration
+  public static Option[] configuration() {
+    Option[] options = options(
+        bootDelegationPackages("javax.transaction", "javax.transaction.*"),
+        vmOption("-Dorg.osgi.framework.system.packages=javax.accessibility,javax.activation,javax.activity,javax.annotation,javax.annotation.processing,javax.crypto,javax.crypto.interfaces,javax.crypto.spec,javax.imageio,javax.imageio.event,javax.imageio.metadata,javax.imageio.plugins.bmp,javax.imageio.plugins.jpeg,javax.imageio.spi,javax.imageio.stream,javax.jws,javax.jws.soap,javax.lang.model,javax.lang.model.element,javax.lang.model.type,javax.lang.model.util,javax.management,javax.management.loading,javax.management.modelmbean,javax.management.monitor,javax.management.openmbean,javax.management.relation,javax.management.remote,javax.management.remote.rmi,javax.management.timer,javax.naming,javax.naming.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,javax.net,javax.net.ssl,javax.print,javax.print.attribute,javax.print.attribute.standard,javax.print.event,javax.rmi,javax.rmi.CORBA,javax.rmi.ssl,javax.script,javax.security.auth,javax.security.auth.callback,
 javax.security.auth.kerberos,javax.security.auth.login,javax.security.auth.spi,javax.security.auth.x500,javax.security.cert,javax.security.sasl,javax.sound.midi,javax.sound.midi.spi,javax.sound.sampled,javax.sound.sampled.spi,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,javax.sql.rowset.spi,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.plaf.metal,javax.swing.plaf.multi,javax.swing.plaf.synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.text.html.parser,javax.swing.text.rtf,javax.swing.tree,javax.swing.undo,javax.tools,javax.xml,javax.xml.bind,javax.xml.bind.annotation,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.bind.helpers,javax.xml.bind.util,javax.xml.crypto,javax.xml.crypto.dom,javax.xml.crypto.dsig,javax.xml.crypto.dsig.dom,javax.xml.crypto.dsig.keyinfo,javax.xml.crypto.dsig.spec,javax.xml.datatype,javax.xml.name
 space,javax.xml.parsers,javax.xml.soap,javax.xml.stream,javax.xml.stream.events,javax.xml.stream.util,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,javax.xml.validation,javax.xml.ws,javax.xml.ws.handler,javax.xml.ws.handler.soap,javax.xml.ws.http,javax.xml.ws.soap,javax.xml.ws.spi,javax.xml.xpath,org.ietf.jgss,org.omg.CORBA,org.omg.CORBA.DynAnyPackage,org.omg.CORBA.ORBPackage,org.omg.CORBA.TypeCodePackage,org.omg.CORBA.portable,org.omg.CORBA_2_3,org.omg.CORBA_2_3.portable,org.omg.CosNaming,org.omg.CosNaming.NamingContextExtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.Dynamic,org.omg.DynamicAny,org.omg.DynamicAny.DynAnyFactoryPackage,org.omg.DynamicAny.DynAnyPackage,org.omg.IOP,org.omg.IOP.CodecFactoryPackage,org.omg.IOP.CodecPackage,org.omg.Messaging,org.omg.PortableInterceptor,org.omg.PortableInterceptor.ORBInitInfoPackage,org.omg.PortableServer,org.omg.PortableServer.CurrentPackage,org.omg.
 PortableServer.POAManagerPackage,org.omg.PortableServer.POAPackage,org.omg.PortableServer.ServantLocatorPackage,org.omg.PortableServer.portable,org.omg.SendingContext,org.omg.stub.java.rmi,org.w3c.dom,org.w3c.dom.bootstrap,org.w3c.dom.css,org.w3c.dom.events,org.w3c.dom.html,org.w3c.dom.ls,org.w3c.dom.ranges,org.w3c.dom.stylesheets,org.w3c.dom.traversal,org.w3c.dom.views,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers,javax.transaction;partial=true;mandatory:=partial,javax.transaction.xa;partial=true;mandatory:=partial"),
+        
+        // Log
+        mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+        mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+        // Felix Config Admin
+        mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+        // Felix mvn url handler
+        mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+        // this is how you set the default log level when using pax
+        // logging (logProfile)
+        systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+        // Bundles
+        mavenBundle("asm","asm-all"),
+        
+        mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api"),
+        mavenBundle("org.apache.aries", "org.apache.aries.util"),
+        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+        mavenBundle("asm", "asm-all"),
+        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"), 
+        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.testbundlea").noStart(),
+        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.testbundleb").noStart(),
+        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.testquiescebundle"),
+        //mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.cm"),
+        mavenBundle("org.osgi", "org.osgi.compendium"),
+        
+//        new VMOption( "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" ),
+        
+        equinox().version("3.5.0"));
+    options = updateOptions(options);
+    return options;
+  }
+  
+  
+  protected Bundle getBundle(String symbolicName) {
+    return getBundle(symbolicName, null);
+  }
+
+  protected Bundle getBundle(String bundleSymbolicName, String version) {
+    Bundle result = null;
+    for (Bundle b : bundleContext.getBundles()) {
+      if (b.getSymbolicName().equals(bundleSymbolicName)) {
+        if (version == null
+            || b.getVersion().equals(Version.parseVersion(version))) {
+          result = b;
+          break;
+        }
+      }
+    }
+    return result;
+  }
+
+  public static BootDelegationOption bootDelegation() {
+    return new BootDelegationOption("org.apache.aries.unittest.fixture");
+  }
+  
+  public static MavenArtifactProvisionOption mavenBundle(String groupId,
+      String artifactId) {
+    return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId)
+        .versionAsInProject();
+  }
+
+  @Test
+  public void testBasicQuieseEmptyCounter() throws Exception 
+  {
+	  //This test checks that a single bundle when called will not quiesce while 
+	  //there is an active request (method sleeps), but will quiesce after the 
+	  //request is completed. 
+	  
+	System.out.println("In testBasicQuieseEmptyCounter");
+	Object obj = getOsgiService(TestBean.class);
+	
+	if (obj != null)
+	{
+	  QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
+	  
+	  if (participant != null)
+	  {
+	    System.out.println(obj.getClass().getName());
+
+	    TestQuiesceCallback callback = new TestQuiesceCallback();
+	    
+	    Bundle bundle = getBundle("org.apache.aries.blueprint.testquiescebundle");
+	    
+	    System.out.println("Got the bundle");
+	    
+	    List<Bundle> bundles = new ArrayList<Bundle>();
+	    bundles.add(bundle);
+	    
+	    Thread t = new Thread(new TestBeanClient((TestBean)obj, 2000));
+	    t.start();
+
+	    System.out.println("Thread Started");
+	    
+	    participant.quiesce(callback, bundles);
+	    
+	    System.out.println("Called Quiesce");
+	    
+	    Thread.sleep(1000);
+	    
+	    Assert.assertTrue("Quiesce callback should not have occurred yet; calls should be 0, but it is "+callback.getCalls(), callback.getCalls()==0);
+	    
+	    Thread.sleep(1500);
+	    
+	    System.out.println("After second sleep");
+	    
+	    Assert.assertTrue("Quiesce callback should have occurred once; calls should be 1, but it is "+callback.getCalls(), callback.getCalls()==1);
+	    
+ 	  }
+  	  else
+	  {
+		throw new Exception("No Quiesce Participant found for the blueprint service");
+	  }
+  
+	  System.out.println("done");
+	}
+	else
+	{
+		throw new Exception("No Service returned for " + TestBean.class);
+	}
+  }
+  
+  @Test
+  public void testNoServicesQuiesce() throws Exception {
+   
+   //This test covers the case where one of the bundles being asked to quiesce has no 
+   //services. It should be quiesced immediately.
+	  
+   System.out.println("In testNoServicesQuiesce");
+	Object obj = getOsgiService(TestBean.class);
+	
+	if (obj != null)
+	{    
+		QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
+		
+		if (participant != null)
+		{
+			TestQuiesceCallback callbackA = new TestQuiesceCallback();
+			TestQuiesceCallback callbackB = new TestQuiesceCallback();
+		    
+			//bundlea provides the ns handlers, bean processors, interceptors etc for this test.
+	        Bundle bundlea = getBundle("org.apache.aries.blueprint.testbundlea");
+	        assertNotNull(bundlea);
+	        bundlea.start();
+	        
+	        //bundleb has no services and makes use of the extensions provided by bundlea
+	        Bundle bundleb = getBundle("org.apache.aries.blueprint.testbundleb");
+	        assertNotNull(bundleb);
+	        bundleb.start();
+	        
+			participant.quiesce(callbackB, Collections.singletonList(getBundle(
+				"org.apache.aries.blueprint.testbundleb")));
+			
+		    System.out.println("Called Quiesce");
+		    
+		    Thread.sleep(200);
+		    
+		    Assert.assertTrue("Quiesce callback B should have occurred; calls should be 1, but it is "+callbackB.getCalls(), callbackB.getCalls()==1);
+		    Assert.assertTrue("Quiesce callback A should not have occurred yet; calls should be 0, but it is "+callbackA.getCalls(), callbackA.getCalls()==0);
+		    
+		    participant.quiesce(callbackA, Collections.singletonList(getBundle(
+			"org.apache.aries.blueprint.testbundlea")));
+				    
+		    Thread.sleep(1000);
+		    
+		    System.out.println("After second sleep");
+		    
+		    Assert.assertTrue("Quiesce callback A should have occurred once; calls should be 1, but it is "+callbackA.getCalls(), callbackA.getCalls()==1);
+		    Assert.assertTrue("Quiesce callback B should have occurred once; calls should be 1, but it is "+callbackB.getCalls(), callbackB.getCalls()==1);
+		    
+		}else{
+			throw new Exception("No Quiesce Participant found for the blueprint service");
+		}
+	}else{
+		throw new Exception("No Service returned for " + TestBean.class);
+	}
+  }
+
+  @Test
+  public void testMultiBundleQuiesce() throws Exception {
+   
+   //This test covers the case where two bundles are quiesced at the same time. 
+   //Bundle A should quiesce immediately, quiesce bundle should quiesce after the 
+   //request has completed.
+	  
+   System.out.println("In testMultiBundleQuiesce");
+	Object obj = getOsgiService(TestBean.class);
+	
+	if (obj != null)
+	{    
+		QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
+		
+		if (participant != null)
+		{
+			TestQuiesceCallback callback = new TestQuiesceCallback();
+		    
+			//bundlea provides the ns handlers, bean processors, interceptors etc for this test.
+	        Bundle bundlea = getBundle("org.apache.aries.blueprint.testbundlea");
+	        assertNotNull(bundlea);
+	        bundlea.start();
+	        
+	        //quiesce bundle will sleep for a second so will quiesce after that
+		    Bundle bundleq = getBundle("org.apache.aries.blueprint.testquiescebundle");
+		    
+		    System.out.println("Got the bundle");
+		    
+		    List<Bundle> bundles = new ArrayList<Bundle>();
+		    bundles.add(bundlea);
+		    bundles.add(bundleq);
+		    
+		    Thread t = new Thread(new TestBeanClient((TestBean)obj, 1500));
+		    t.start();
+		    Thread.sleep(200);
+	        
+			participant.quiesce(callback, bundles);
+			
+		    System.out.println("Called Quiesce");
+		    
+		    Thread.sleep(500);
+		    
+		    Assert.assertTrue("Quiesce callback should have occurred once for bundle a but not for bundle q; calls should be 1, but it is "+callback.getCalls(), callback.getCalls()==1);
+		    
+		    Thread.sleep(1500);
+		    
+		    System.out.println("After second sleep");
+		    
+		    Assert.assertTrue("Quiesce callback should have occurred twice, once for bundle a and q respectively; calls should be 2, but it is "+callback.getCalls(), callback.getCalls()==2);
+		    
+		}else{
+			throw new Exception("No Quiesce Participant found for the blueprint service");
+		}
+	}else{
+		throw new Exception("No Service returned for " + TestBean.class);
+	}
+  }
+  
+  @Test
+  public void testMultiRequestQuiesce() throws Exception {
+   
+   //This test covers the case where we have two active requests when 
+   //the bundle is being quiesced.
+	  
+   System.out.println("In testMultiRequestQuiesce");
+	Object obj = getOsgiService(TestBean.class);
+	
+	if (obj != null)
+	{    
+		QuiesceParticipant participant = getParticipant("org.apache.aries.blueprint");
+		
+		if (participant != null)
+		{
+			TestQuiesceCallback callback = new TestQuiesceCallback();
+			TestBeanClient client =  new TestBeanClient((TestBean)obj, 1500);
+		    
+
+	        //quiesce bundle will sleep for a second so will quiesce after that
+		    Bundle bundle = getBundle("org.apache.aries.blueprint.testquiescebundle");
+		    
+		    System.out.println("Got the bundle");
+		    
+		    List<Bundle> bundles = new ArrayList<Bundle>();
+		    bundles.add(bundle);
+		    
+		    Thread t = new Thread(client);
+		    t.start();
+	        
+			participant.quiesce(callback, bundles);
+			
+		    System.out.println("Called Quiesce, putting in a new request");
+		    
+		    Thread t2 = new Thread(client);
+		    t2.start();
+		    
+		    Thread.sleep(5000);
+		    
+		    Assert.assertTrue("Quiesce callback should have occurred once; calls should be 1, but it is "+callback.getCalls(), callback.getCalls()==1);
+		    
+   
+		}else{
+			throw new Exception("No Quiesce Participant found for the blueprint service");
+		}
+	}else{
+		throw new Exception("No Service returned for " + TestBean.class);
+	}
+  }
+  
+  
+  private class TestBeanClient implements Runnable
+  {
+    private TestBean myService;
+    private int time;
+    
+    public TestBeanClient(TestBean myService, int time)
+    {
+      this.myService = myService;
+      this.time = time;
+    }
+	  
+	public void run() 
+	{
+	  try
+	  {
+		System.out.println("In Test Bean Client - Sleeping zzzzzzz");
+		myService.sleep(time);
+		System.out.println("Woken up");
+	  }
+	  catch (InterruptedException ie)
+	  {
+		  ie.printStackTrace();
+	  }
+	}
+	  
+  }
+}

Added: aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestConfigAdmin.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.util.Currency;
+import java.util.Hashtable;
+
+import org.apache.aries.blueprint.sample.Foo;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Bundle;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+@RunWith(JUnit4TestRunner.class)
+public class TestConfigAdmin extends AbstractIntegrationTest {
+
+    @Test
+    public void testStrategyNone() throws Exception {
+        ConfigurationAdmin ca = getOsgiService(ConfigurationAdmin.class);
+        Configuration cf = ca.getConfiguration("blueprint-sample-managed.none", null);
+        Hashtable<String,String> props = new Hashtable<String,String>();
+        props.put("a", "5");
+        props.put("currency", "PLN");
+        cf.update(props);
+
+        Bundle bundle = getInstalledBundle("org.apache.aries.blueprint.sample");
+        assertNotNull(bundle);
+        bundle.start();
+
+        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle("org.apache.aries.blueprint.sample", DEFAULT_TIMEOUT);
+        assertNotNull(blueprintContainer);
+
+        Foo foo = (Foo) blueprintContainer.getComponentInstance("none-managed");
+        assertNotNull(foo);
+
+        assertEquals(5, foo.getA());
+        assertEquals(Currency.getInstance("PLN"), foo.getCurrency());
+
+        props = new Hashtable<String,String>();
+        props.put("a", "10");
+        props.put("currency", "USD");
+        cf = ca.getConfiguration("blueprint-sample-managed.none", null);
+        cf.update(props);
+
+        Thread.sleep(100);
+
+        assertEquals(5, foo.getA());
+        assertEquals(Currency.getInstance("PLN"), foo.getCurrency());
+    }
+
+    @Test
+    public void testStrategyContainer() throws Exception {
+        ConfigurationAdmin ca = getOsgiService(ConfigurationAdmin.class);
+        Configuration cf = ca.getConfiguration("blueprint-sample-managed.container", null);
+        Hashtable<String,String> props = new Hashtable<String,String>();
+        props.put("a", "5");
+        props.put("currency", "PLN");
+        cf.update(props);
+
+        Bundle bundle = getInstalledBundle("org.apache.aries.blueprint.sample");
+        assertNotNull(bundle);
+        bundle.start();
+
+        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle("org.apache.aries.blueprint.sample", DEFAULT_TIMEOUT);
+        assertNotNull(blueprintContainer);
+
+        Foo foo = (Foo) blueprintContainer.getComponentInstance("container-managed");
+        assertNotNull(foo);
+
+        assertEquals(5, foo.getA());
+        assertEquals(Currency.getInstance("PLN"), foo.getCurrency());
+
+        props = new Hashtable<String,String>();
+        props.put("a", "10");
+        props.put("currency", "USD");
+        cf.update(props);
+
+        Thread.sleep(100);
+
+        assertEquals(10, foo.getA());
+        assertEquals(Currency.getInstance("USD"), foo.getCurrency());
+    }
+
+    @Test
+    public void testStrategyComponent() throws Exception {
+        ConfigurationAdmin ca = getOsgiService(ConfigurationAdmin.class);
+        Configuration cf = ca.getConfiguration("blueprint-sample-managed.component", null);
+        Hashtable<String,String> props = new Hashtable<String,String>();
+        props.put("a", "5");
+        props.put("currency", "PLN");
+        cf.update(props);
+
+        Bundle bundle = getInstalledBundle("org.apache.aries.blueprint.sample");
+        assertNotNull(bundle);
+        bundle.start();
+
+        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle("org.apache.aries.blueprint.sample", DEFAULT_TIMEOUT);
+        assertNotNull(blueprintContainer);
+
+        Foo foo = (Foo) blueprintContainer.getComponentInstance("component-managed");
+        assertNotNull(foo);
+
+        assertEquals(5, foo.getA());
+        assertEquals(Currency.getInstance("PLN"), foo.getCurrency());
+
+        props = new Hashtable<String,String>();
+        props.put("a", "10");
+        props.put("currency", "USD");
+        cf.update(props);
+
+        Thread.sleep(100);
+
+        assertEquals(5, foo.getA());
+        assertEquals(Currency.getInstance("PLN"), foo.getCurrency());
+        assertNotNull(foo.getProps());
+        assertEquals("10", foo.getProps().get("a"));
+        assertEquals("USD", foo.getProps().get("currency"));
+    }
+
+    @Test
+    public void testManagedServiceFactory() throws Exception {
+        ConfigurationAdmin ca = getOsgiService(ConfigurationAdmin.class);
+        Configuration cf = ca.createFactoryConfiguration("blueprint-sample-managed-service-factory", null);
+        Hashtable<String,String> props = new Hashtable<String,String>();
+        props.put("a", "5");
+        props.put("currency", "PLN");
+        cf.update(props);
+
+        Bundle bundle = getInstalledBundle("org.apache.aries.blueprint.sample");
+        assertNotNull(bundle);
+        bundle.start();
+
+        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle("org.apache.aries.blueprint.sample", DEFAULT_TIMEOUT);
+        assertNotNull(blueprintContainer);
+
+        Thread.sleep(5000);
+    }
+
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        Option[] options = options(
+            // Log
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+            // Felix Config Admin
+            mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+            // Felix mvn url handler
+            mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+
+            // this is how you set the default log level when using pax logging (logProfile)
+            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+            // Bundles
+            mavenBundle("org.apache.aries", "org.apache.aries.util"),
+            mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+            mavenBundle("asm", "asm-all"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample").noStart(),
+            mavenBundle("org.osgi","org.osgi.compendium"),
+//            org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+
+            equinox().version("3.5.0")
+        );
+        options = updateOptions(options);
+        return options;
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestReferences.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.util.Hashtable;
+import java.util.List;
+
+import org.apache.aries.blueprint.sample.BindingListener;
+import org.apache.aries.blueprint.sample.InterfaceA;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.ServiceUnavailableException;
+
+@RunWith(JUnit4TestRunner.class)
+public class TestReferences extends AbstractIntegrationTest {
+
+    @Test
+    public void testUnaryReference() throws Exception {
+        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle("org.apache.aries.blueprint.sample");
+        assertNotNull(blueprintContainer);
+
+        BindingListener listener = (BindingListener) blueprintContainer.getComponentInstance("bindingListener");
+        assertNull(listener.getA());
+        assertNull(listener.getReference());
+
+        InterfaceA a = (InterfaceA) blueprintContainer.getComponentInstance("ref2");
+        try {
+            a.hello("world");
+            fail("A ServiceUnavailableException should have been thrown");
+        } catch (ServiceUnavailableException e) {
+            // Ignore, expected
+        }
+
+        ServiceRegistration reg1 = bundleContext.registerService(InterfaceA.class.getName(), new InterfaceA() {
+            public String hello(String msg) {
+                return "Hello " + msg + "!";
+            }
+        }, null);
+        assertNotNull(listener.getA());
+        assertNotNull(listener.getReference());
+        assertEquals("Hello world!", a.hello("world"));
+
+        Hashtable props = new Hashtable();
+        props.put(Constants.SERVICE_RANKING, Integer.valueOf(1));
+        ServiceRegistration reg2 = bundleContext.registerService(InterfaceA.class.getName(), new InterfaceA() {
+            public String hello(String msg) {
+                return "Good morning " + msg + "!";
+            }
+        }, props);
+
+        assertNotNull(listener.getA());
+        assertNotNull(listener.getReference());
+        assertEquals("Hello world!", a.hello("world"));
+
+        reg1.unregister();
+        assertNotNull(listener.getA());
+        assertNotNull(listener.getReference());
+        assertEquals("Good morning world!", a.hello("world"));
+
+        reg2.unregister();
+        assertNull(listener.getA());
+        assertNull(listener.getReference());
+        try {
+            a.hello("world");
+            fail("A ServiceUnavailableException should have been thrown");
+        } catch (ServiceUnavailableException e) {
+            // Ignore, expected
+        }
+    }
+
+    @Test
+    public void testListReferences() throws Exception {
+        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle("org.apache.aries.blueprint.sample");
+        assertNotNull(blueprintContainer);
+
+        BindingListener listener = (BindingListener) blueprintContainer.getComponentInstance("listBindingListener");
+        assertNull(listener.getA());
+        assertNull(listener.getReference());
+
+        List refs = (List) blueprintContainer.getComponentInstance("ref-list");
+        assertNotNull(refs);
+        assertTrue(refs.isEmpty());
+
+        ServiceRegistration reg1 = bundleContext.registerService(InterfaceA.class.getName(), new InterfaceA() {
+            public String hello(String msg) {
+                return "Hello " + msg + "!";
+            }
+        }, null);
+        assertNotNull(listener.getA());
+        assertNotNull(listener.getReference());
+        assertEquals(1, refs.size());
+        InterfaceA a = (InterfaceA) refs.get(0);
+        assertNotNull(a);
+        assertEquals("Hello world!", a.hello("world"));
+
+    }
+
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        Option[] options = options(
+            // Log
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+            mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+            // Felix Config Admin
+            mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+            // Felix mvn url handler
+            mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+            // this is how you set the default log level when using pax logging (logProfile)
+            systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+            // Bundles
+            mavenBundle("org.apache.aries", "org.apache.aries.util"),
+            mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+            mavenBundle("asm", "asm-all"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+            mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample"),
+            mavenBundle("org.osgi", "org.osgi.compendium"),
+
+//            org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+
+            equinox().version("3.5.0")
+        );
+        options = updateOptions(options);
+        return options;
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/TestRegistrationListener.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.util.Map;
+
+import org.apache.aries.blueprint.BlueprintConstants;
+import org.apache.aries.blueprint.sample.Foo;
+import org.apache.aries.blueprint.sample.FooRegistrationListener;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+
+@RunWith(JUnit4TestRunner.class)
+public class TestRegistrationListener extends AbstractIntegrationTest {
+
+    @Test
+    public void testWithAutoExportEnabled() throws Exception {
+
+        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle("org.apache.aries.blueprint.sample");
+        assertNotNull(blueprintContainer);
+
+        Foo foo = getOsgiService(Foo.class, "(" + BlueprintConstants.COMPONENT_NAME_PROPERTY + "=foo)", DEFAULT_TIMEOUT);
+        assertEquals(5, foo.getA());
+
+        FooRegistrationListener listener = 
+            (FooRegistrationListener) blueprintContainer.getComponentInstance("fooRegistrationListener");
+
+        // If registration listener works fine, the registration method should
+        // have already been called and properties that were passed to this
+        // method should have been not null
+
+        Map props = listener.getProperties();
+        assertNotNull(props);
+
+        assertTrue(props.containsKey(BlueprintConstants.COMPONENT_NAME_PROPERTY));
+        assertEquals("foo", props.get(BlueprintConstants.COMPONENT_NAME_PROPERTY));
+
+        assertTrue(props.containsKey("key"));
+        assertEquals("value", props.get("key"));
+
+    }
+
+    @org.ops4j.pax.exam.junit.Configuration
+    public static Option[] configuration() {
+        Option[] options = options(
+                // Log
+                mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+                mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+                // Felix Config Admin
+                mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+                // Felix mvn url handler
+                mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+                // this is how you set the default log level when using pax
+                // logging (logProfile)
+                systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+                // Bundles
+                mavenBundle("org.apache.aries", "org.apache.aries.util"), 
+                mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+                mavenBundle("asm", "asm-all"),
+                mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"), 
+                mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.sample"),
+                mavenBundle("org.osgi", "org.osgi.compendium"),
+
+                // org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+
+                equinox().version("3.5.0"));
+        options = updateOptions(options);
+        return options;
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-itests/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-itests/src/test/resources/log4j.properties?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-itests/src/test/resources/log4j.properties (added)
+++ aries/tags/blueprint-0.3.1/blueprint-itests/src/test/resources/log4j.properties Sun Feb 27 21:21:05 2011
@@ -0,0 +1,33 @@
+################################################################################
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+################################################################################
+
+# Root logger
+log4j.rootLogger=DEBUG, stdout
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
+log4j.appender.out.file=${karaf.base}/data/log/karaf.log
+log4j.appender.out.append=true

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/pom.xml?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/pom.xml (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/pom.xml Sun Feb 27 21:21:05 2011
@@ -0,0 +1,86 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+    
+       http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.blueprint</groupId>
+        <artifactId>blueprint</artifactId>
+        <version>0.3.1</version>
+    </parent>
+
+    <artifactId>org.apache.aries.blueprint.sample-annotation</artifactId>
+    <name>Apache Aries Blueprint Sample for Testing Annotation</name>
+    <packaging>bundle</packaging>
+    <description>
+        Example blueprint application, mostly used for annotation tests.
+    </description>
+
+    <properties>
+		<aries.osgi.export>
+			org.apache.aries.blueprint.sample;-noimport:=true
+		</aries.osgi.export>
+        <aries.osgi.activator>
+            org.apache.aries.blueprint.sample.Activator
+        </aries.osgi.activator>
+        <aries.osgi.import>
+            org.apache.aries.blueprint.annotation,
+            *
+        </aries.osgi.import>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.eclipse</groupId>
+            <artifactId>osgi</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.annotation.api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+	<build>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<groupId>org.apache.felix</groupId>
+					<artifactId>maven-bundle-plugin</artifactId>
+					<extensions>true</extensions>
+					<inherited>true</inherited>
+					<configuration>
+						<excludeDependencies>${aries.osgi.exclude.dependencies}</excludeDependencies>
+						<instructions>
+							<Bundle-Blueprint-Annotation>true</Bundle-Blueprint-Annotation>
+						</instructions>
+						<versions>
+							<aries.osgi.version.clean>${project.version}</aries.osgi.version.clean>
+						</versions>
+					</configuration>
+				</plugin>
+
+			</plugins>
+		</pluginManagement>
+	</build>
+    
+
+</project>

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Account.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Account.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Account.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Account.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,38 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import org.apache.aries.blueprint.annotation.Arg;
+import org.apache.aries.blueprint.annotation.Bean;
+
+@Bean(id="accountOne", args=@Arg(value="1"))
+public class Account {
+    
+    private long accountNumber;
+    
+    public Account(long number) {
+        this.accountNumber = number;
+    }
+    
+    public long getAccountNumber() {
+        return this.accountNumber;
+    }
+    
+    public void setAccountNumber(long number) {
+        this.accountNumber = number;
+    }
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/AccountFactory.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,38 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import org.apache.aries.blueprint.annotation.Bean;
+import org.apache.aries.blueprint.annotation.Arg;
+
+@Bean(id="accountFactory", args=@Arg(value="account factory"))
+public class AccountFactory {
+    private String factoryName;
+
+    public AccountFactory(String factoryName) {
+        this.factoryName = factoryName;
+    }
+
+    public NewAccount createAccount(long number) {
+        return new NewAccount(number);
+    }
+    
+    public String getFactoryName() {
+        return this.factoryName;
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Activator.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Activator.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Activator.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Activator.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,32 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+    public void start(BundleContext context) {
+        System.out.println("Bundle start");
+    }
+
+    public void stop(BundleContext context) {
+        System.out.println("Bundle stop");
+    }
+   
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Bar.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Bar.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Bar.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Bar.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,73 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import java.util.List;
+
+import org.osgi.framework.BundleContext;
+import org.apache.aries.blueprint.annotation.Blueprint;
+import org.apache.aries.blueprint.annotation.Bean;
+import org.apache.aries.blueprint.annotation.Inject;
+import org.apache.aries.blueprint.annotation.Element;
+import org.apache.aries.blueprint.annotation.Element.ElementType;
+
+@Blueprint(defaultActivation="eager", defaultTimeout=300, defaultAvailability="optional")
+@Bean(id="bar")
+public class Bar {
+    
+    @Inject(value="Hello FooBar")
+    private String value;
+
+    @Inject(ref="blueprintBundleContext")
+    private BundleContext context;
+
+    /*@Inject 
+    @org.apache.aries.blueprint.annotation.List ({ 
+        @Element(value="a list element"), 
+        @Element(value="5", type=ElementType.INTEGER) 
+    })*/
+    private List list;
+
+    public BundleContext getContext() {
+        return context;
+    }
+
+    public void setContext(BundleContext ctx) {
+        context = ctx;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String s) {
+        value = s;
+    }
+
+    public List getList() {
+        return list;
+    }
+
+    public void setList(List l) {
+        list = l;
+    }
+
+    public String toString() {
+        return hashCode() + ": " + value + " " + context + " " + list;
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/BindingListener.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,88 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.aries.blueprint.annotation.Bean;
+import org.apache.aries.blueprint.annotation.Bind;
+import org.apache.aries.blueprint.annotation.Init;
+import org.apache.aries.blueprint.annotation.Inject;
+import org.apache.aries.blueprint.annotation.Reference;
+import org.apache.aries.blueprint.annotation.ReferenceListener;
+import org.apache.aries.blueprint.annotation.Unbind;
+import org.osgi.framework.ServiceReference;
+
+@Bean(id="bindingListener")
+@ReferenceListener
+public class BindingListener {
+
+    @Inject @Reference (id="ref2", 
+            serviceInterface = InterfaceA.class,
+            timeout=100, referenceListeners=@ReferenceListener(ref="bindingListener"))
+    private InterfaceA a;
+    private Map props;
+    private ServiceReference reference;
+    private List list;
+
+    public InterfaceA getA() {
+        return a;
+    }
+
+    public Map getProps() {
+        return props;
+    }
+
+    public ServiceReference getReference() {
+        return reference;
+    }
+
+    public List getList() {
+        return list;
+    }
+
+    public void setList(List list) {
+        this.list = list;
+    }
+
+    @Init
+    public void init() {
+    }
+
+    @Bind
+    public void bind(InterfaceA a, Map props) {
+        this.a = a;
+        this.props = props;
+    }
+
+    @Bind
+    public void bind(ServiceReference ref) {
+        this.reference = ref;
+    }
+
+    @Unbind
+    public void unbind(InterfaceA a, Map props) {
+        this.a = null;
+        this.props = null;
+    }
+
+    @Unbind
+    public void unbind(ServiceReference ref) {
+        this.reference = null;
+    }
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/CurrencyTypeConverter.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,36 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import java.util.Currency;
+
+import org.apache.aries.blueprint.annotation.Bean;
+import org.osgi.service.blueprint.container.Converter;
+import org.osgi.service.blueprint.container.ReifiedType;
+
+@Bean(id="converter2")
+public class CurrencyTypeConverter implements Converter {
+
+    public boolean canConvert(Object fromValue, ReifiedType toType) {
+        return Currency.class.isAssignableFrom(toType.getRawClass());
+    }
+
+    public Object convert(Object source, ReifiedType toType) throws Exception {
+        return Currency.getInstance(source.toString());
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/DateTypeConverter.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,46 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.aries.blueprint.annotation.Bean;
+import org.apache.aries.blueprint.annotation.Inject;
+import org.osgi.service.blueprint.container.Converter;
+import org.osgi.service.blueprint.container.ReifiedType;
+
+@Bean(id="converter1")
+public class DateTypeConverter implements Converter {
+
+    @Inject(name="format", value="yyyy.MM.dd")
+    DateFormat dateFormat;
+    
+    public void setFormat(String format) {
+        this.dateFormat = new SimpleDateFormat(format);
+    }
+    
+    public Object convert(Object source, ReifiedType toType) throws Exception {
+        return this.dateFormat.parse(source.toString());
+    }
+
+    public boolean canConvert(Object fromValue, ReifiedType toType) {
+        return Date.class.isAssignableFrom(toType.getRawClass());
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Foo.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Foo.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Foo.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/Foo.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,131 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import java.io.Serializable;
+import java.util.Currency;
+import java.util.Date;
+import java.util.Map;
+
+import org.apache.aries.blueprint.annotation.Bean;
+import org.apache.aries.blueprint.annotation.Destroy;
+import org.apache.aries.blueprint.annotation.Init;
+import org.apache.aries.blueprint.annotation.Inject;
+import org.apache.aries.blueprint.annotation.RegistrationListener;
+import org.apache.aries.blueprint.annotation.Service;
+import org.apache.aries.blueprint.annotation.ServiceProperty;
+
+@Bean(id="foo")
+@Service(autoExport="all-classes",
+        serviceProperties = @ServiceProperty(key="blueprint.annotation.sample", value="true"),
+        registerationListeners = @RegistrationListener(ref="fooRegistrationListener"), 
+        ranking=0)
+public class Foo implements Serializable {
+    
+    @Inject(value="5")
+    private int a;
+    
+    //@Inject(value="${key.b}")
+    private int b;
+    
+    //@Inject(ref="bar")
+    private Bar bar;
+    
+    @Inject(value="PLN")
+    private Currency currency;
+    
+    @Inject(value="2009.04.17")
+    private Date date;
+
+    public boolean initialized;
+    public boolean destroyed;
+    private Map<String, Object> props;
+
+    public int getA() {
+        return a;
+    }
+
+    public void setA(int i) {
+        a = i;
+    }
+
+    public int getB() {
+        return b;
+    }
+
+    public void setB(int i) {
+        b = i;
+    }
+
+    public Bar getBar() {
+        return bar;
+    }
+
+    @Inject(ref="bar")
+    public void setBar(Bar b) {
+        bar = b;
+    }
+
+    public Currency getCurrency() {
+        return currency;
+    }
+
+    public void setCurrency(Currency c) {
+        currency = c;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date d) {
+        date = d;
+    }
+
+    public String toString() {
+        return a + " " + b + " " + bar + " " + currency + " " + date;
+    }
+
+    @Init
+    public void init() {
+        System.out.println("======== Initializing Foo =========");
+        initialized = true;
+    }
+
+    @Destroy
+    public void destroy() {
+        System.out.println("======== Destroying Foo =========");
+        destroyed = true;
+    }
+
+    public boolean isInitialized() {
+        return initialized;
+    }
+
+    public boolean isDestroyed() {
+        return destroyed;
+    }
+
+    public void update(Map<String,Object> props) {
+        this.props = props;
+    }
+
+    public Map<String, Object> getProps() {
+        return props;
+    }
+}
+

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/FooRegistrationListener.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,41 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.apache.aries.blueprint.annotation.Bean;
+import org.apache.aries.blueprint.annotation.Register;
+import org.apache.aries.blueprint.annotation.RegistrationListener;
+import org.apache.aries.blueprint.annotation.Unregister;
+
+@Bean(id="fooRegistrationListener")
+@RegistrationListener
+public class FooRegistrationListener {
+        
+    @Register
+    public void serviceRegistered(Serializable foo, Map props) {
+        System.out.println("Service registration notification: " + foo + " " + props);
+    }
+    
+    @Unregister
+    public void serviceUnregistered(Foo foo, Map props) {
+        System.out.println("Service unregistration notification: " + foo + " " + props);
+    }
+
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/InterfaceA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/InterfaceA.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/InterfaceA.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/InterfaceA.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,22 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+public interface InterfaceA {
+
+    String hello(String msg);
+}

Added: aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/InterfaceB.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/InterfaceB.java?rev=1075149&view=auto
==============================================================================
--- aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/InterfaceB.java (added)
+++ aries/tags/blueprint-0.3.1/blueprint-sample-annotation/src/main/java/org/apache/aries/blueprint/sample/InterfaceB.java Sun Feb 27 21:21:05 2011
@@ -0,0 +1,22 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.aries.blueprint.sample;
+
+public interface InterfaceB {
+
+    String hello(String msg);
+}



Mime
View raw message