aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1565220 - in /aries/trunk/spi-fly/spi-fly-examples: ./ spi-fly-example-provider-consumer-bundle/ spi-fly-example-provider-consumer-bundle/src/ spi-fly-example-provider-consumer-bundle/src/main/ spi-fly-example-provider-consumer-bundle/src/...
Date Thu, 06 Feb 2014 13:04:33 GMT
Author: davidb
Date: Thu Feb  6 13:04:33 2014
New Revision: 1565220

URL: http://svn.apache.org/r1565220
Log:
Additional example that shows a single bundle being a provider and consumer at the same time.

Added:
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/pom.xml
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/
    aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/Activator.java
Modified:
    aries/trunk/spi-fly/spi-fly-examples/pom.xml

Modified: aries/trunk/spi-fly/spi-fly-examples/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-examples/pom.xml?rev=1565220&r1=1565219&r2=1565220&view=diff
==============================================================================
--- aries/trunk/spi-fly/spi-fly-examples/pom.xml (original)
+++ aries/trunk/spi-fly/spi-fly-examples/pom.xml Thu Feb  6 13:04:33 2014
@@ -51,6 +51,7 @@
         <module>spi-fly-example-client1-jar</module>
         <module>spi-fly-example-client1-bundle</module>
         <module>spi-fly-example-client2-bundle</module>
+        <module>spi-fly-example-provider-consumer-bundle</module>
         <module>spi-fly-example-resource-provider-bundle</module>
         <module>spi-fly-example-resource-client-bundle</module>
     </modules>

Added: aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/pom.xml?rev=1565220&view=auto
==============================================================================
--- aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/pom.xml
(added)
+++ aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/pom.xml
Thu Feb  6 13:04:33 2014
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+    <!--
+ 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.spifly.examples</groupId>
+        <artifactId>spi-fly-examples</artifactId>
+        <version>1.0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>org.apache.aries.spifly.examples.provider.consumer.bundle</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Aries Example SPI Provider Consumer Bundle</name>
+    <description>
+        A Bundle which is both an SPI provider as well as a consumer.
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.spifly.examples</groupId>
+            <artifactId>org.apache.aries.spifly.examples.spi.bundle</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>        
+        
+        <dependency>
+            <groupId>org.apache.aries.spifly.examples</groupId>
+            <artifactId>org.apache.aries.spifly.examples.client1.jar</artifactId>
+            <version>${project.version}</version>
+        </dependency>        
+
+        <dependency>
+            <groupId>org.apache.aries.spifly.examples</groupId>
+            <artifactId>org.apache.aries.spifly.examples.provider1.jar</artifactId>
+            <version>${project.version}</version>
+        </dependency>                
+
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>        
+    </dependencies>
+
+    <properties>
+        <aries.osgi.export.pkg />
+        <aries.osgi.private.pkg />
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Import-Package>
+                            *
+                        </Import-Package>
+                        <Export-Package />
+                        <Private-Package>org.apache.aries.spifly.pc.bundle</Private-Package>
+                        <Embed-Dependency>*;scope=compile;inline=false</Embed-Dependency>
+                        <Bundle-Activator>org.apache.aries.spifly.pc.bundle.Activator</Bundle-Activator>
+                        <SPI-Consumer>*</SPI-Consumer>
+                        <SPI-Provider>*</SPI-Provider>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/Activator.java?rev=1565220&view=auto
==============================================================================
--- aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/Activator.java
(added)
+++ aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/src/main/java/org/apache/aries/spifly/pc/bundle/Activator.java
Thu Feb  6 13:04:33 2014
@@ -0,0 +1,51 @@
+/**
+ * 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.spifly.pc.bundle;
+
+import org.apache.aries.spifly.client.jar.Consumer;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/** The activator invokes the SPI Consumer, which is also provided by this bundle. It does
so
+ * asynchronously to give the SPI-Fly extender a chance to register the provider, which is
done
+ * asynchronously as well.
+ */
+public class Activator implements BundleActivator {
+    @Override
+    public void start(BundleContext context) throws Exception {
+        Thread t = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                System.out.println("*** Asynchronous invocation to let the extender do its
work.");
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException e) {
+                    // ignore
+                }
+                Consumer consumer = new Consumer();
+                System.out.println("*** Result from invoking the SPI consumer via library:
" + consumer.callSPI());
+            }
+        });
+        t.start();
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+    }
+}



Mime
View raw message