You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by da...@apache.org on 2010/06/16 17:47:43 UTC

svn commit: r955276 - in /incubator/aries/trunk/spi-fly/contrib: ./ pilot_unmodified_consumer/ pilot_unmodified_consumer/MyServiceImpl/ pilot_unmodified_consumer/MyServiceImpl/META-INF/ pilot_unmodified_consumer/MyServiceImpl/META-INF/services/ pilot_u...

Author: davidb
Date: Wed Jun 16 15:47:41 2010
New Revision: 955276

URL: http://svn.apache.org/viewvc?rev=955276&view=rev
Log:
Adding the prototype as discussed on aries-dev to the code base. 

This is by no means finished work, but I wanted to share the current state as it may help collaboration on this issue.
These are all eclipse projects that implement the prototype as is being discussed here: 
http://mail-archives.apache.org/mod_mbox/incubator-aries-dev/201006.mbox/%3CAANLkTimFFHzYfrYX72hPxng6RDGEufTUzp5kFlzFQJ2j@mail.gmail.com%3E

Added:
    incubator/aries/trunk/spi-fly/contrib/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.classpath
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.project
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/MANIFEST.MF
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/services/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/services/org.apache.aries.spifly.mysvc.SPIProvider
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/build.properties
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/impl/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/impl/SPIProviderImpl.java
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/internal/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/internal/Activator.java
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.classpath
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.project
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/META-INF/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/META-INF/MANIFEST.MF
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/build.properties
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/aries/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/aries/spifly/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/aries/spifly/mysvc/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/aries/spifly/mysvc/SPIProvider.java
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.classpath
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.project
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/META-INF/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/META-INF/MANIFEST.MF
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/build.properties
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/Activator.java
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/BundleAspect.aj
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.classpath
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.project
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/META-INF/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/META-INF/MANIFEST.MF
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/build.properties
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/aries/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/aries/spifly/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/aries/spifly/api/
    incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/aries/spifly/api/SPIClassloaderAdviceService.java

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.classpath
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.classpath?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.classpath (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.classpath Wed Jun 16 15:47:41 2010
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.project
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.project?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.project (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/.project Wed Jun 16 15:47:41 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>MyServiceImpl</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/MANIFEST.MF?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/MANIFEST.MF (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/MANIFEST.MF Wed Jun 16 15:47:41 2010
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ServiceLoaderService
+Bundle-SymbolicName: MyServiceImpl
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.apache.aries.spifly.api,
+ org.apache.aries.spifly.mysvc,
+ org.osgi.framework
+Export-Package: org.apache.aries.spifly.mysvc.impl
+Bundle-Activator: org.apache.aries.spifly.mysvc.internal.Activator
+SPI-Provider: org.apache.aries.spifly.mysvc.SPIProvider

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/services/org.apache.aries.spifly.mysvc.SPIProvider
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/services/org.apache.aries.spifly.mysvc.SPIProvider?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/services/org.apache.aries.spifly.mysvc.SPIProvider (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/META-INF/services/org.apache.aries.spifly.mysvc.SPIProvider Wed Jun 16 15:47:41 2010
@@ -0,0 +1 @@
+org.apache.aries.spifly.mysvc.impl.SPIProviderImpl
\ No newline at end of file

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/build.properties
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/build.properties?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/build.properties (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/build.properties Wed Jun 16 15:47:41 2010
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/impl/SPIProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/impl/SPIProviderImpl.java?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/impl/SPIProviderImpl.java (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/impl/SPIProviderImpl.java Wed Jun 16 15:47:41 2010
@@ -0,0 +1,28 @@
+/**
+ * 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.mysvc.impl;
+
+import org.apache.aries.spifly.mysvc.SPIProvider;
+
+public class SPIProviderImpl extends SPIProvider {
+	@Override
+	public void doit() {
+		System.out.println("Doing it!");
+	}
+}

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/internal/Activator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/internal/Activator.java?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/internal/Activator.java (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceImpl/src/org/apache/aries/spifly/mysvc/internal/Activator.java Wed Jun 16 15:47:41 2010
@@ -0,0 +1,56 @@
+/**
+ * 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.mysvc.internal;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.aries.spifly.api.SPIClassloaderAdviceService;
+import org.apache.aries.spifly.mysvc.SPIProvider;
+import org.apache.aries.spifly.mysvc.impl.SPIProviderImpl;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+// Everything that happens here could also be done with an extender...
+public class Activator implements BundleActivator {
+    private ServiceRegistration reg;
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        SPIClassloaderAdviceService svc = new SPIClassloaderAdviceService() {            
+            @Override
+            public ClassLoader getServiceClassLoader(Class<?> cls) {
+                if (cls.equals(SPIProvider.class)) {
+                    return SPIProviderImpl.class.getClassLoader();
+                }
+                return null;
+            }
+        };
+
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put("AdviceClass", SPIProvider.class.getName());
+        reg = context.registerService(SPIClassloaderAdviceService.class.getName(), svc, props);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        reg.unregister();
+    }
+}

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.classpath
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.classpath?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.classpath (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.classpath Wed Jun 16 15:47:41 2010
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.project
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.project?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.project (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/.project Wed Jun 16 15:47:41 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>MyServiceSPI</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/META-INF/MANIFEST.MF?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/META-INF/MANIFEST.MF (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/META-INF/MANIFEST.MF Wed Jun 16 15:47:41 2010
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ServiceLoaderSPI
+Bundle-SymbolicName: MyServiceSPI
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.apache.aries.spifly.mysvc
+Import-Package: org.apache.aries.spifly.mysvc

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/build.properties
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/build.properties?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/build.properties (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/build.properties Wed Jun 16 15:47:41 2010
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/aries/spifly/mysvc/SPIProvider.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/aries/spifly/mysvc/SPIProvider.java?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/aries/spifly/mysvc/SPIProvider.java (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/MyServiceSPI/src/org/apache/aries/spifly/mysvc/SPIProvider.java Wed Jun 16 15:47:41 2010
@@ -0,0 +1,23 @@
+/**
+ * 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.mysvc;
+
+public abstract class SPIProvider {
+	public abstract void doit();
+}

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.classpath
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.classpath?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.classpath (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.classpath Wed Jun 16 15:47:41 2010
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.project
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.project?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.project (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/.project Wed Jun 16 15:47:41 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>SPIConsumerBundle</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.ajdt.core.ajbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.ajdt.ui.ajnature</nature>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/META-INF/MANIFEST.MF?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/META-INF/MANIFEST.MF (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/META-INF/MANIFEST.MF Wed Jun 16 15:47:41 2010
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: SPI_ConsumerBundle
+Bundle-SymbolicName: SPIConsumerBundle
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.apache.aries.spifly.consumer.Activator
+Import-Package: org.apache.aries.spifly.api,
+ org.apache.aries.spifly.mysvc,
+ org.apache.aries.spifly.mysvc.impl,
+ org.osgi.framework;version="1.3.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.aspectj.runtime
+SPI-Consumer: org.apache.aries.spifly.mysvc.SPIProvider;provider="somebundle"

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/build.properties
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/build.properties?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/build.properties (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/build.properties Wed Jun 16 15:47:41 2010
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/Activator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/Activator.java?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/Activator.java (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/Activator.java Wed Jun 16 15:47:41 2010
@@ -0,0 +1,37 @@
+/**
+ * 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.consumer;
+
+import java.util.ServiceLoader;
+
+import org.apache.aries.spifly.mysvc.SPIProvider;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+	public void start(BundleContext context) throws Exception {
+		ServiceLoader<SPIProvider> ldr = ServiceLoader.load(SPIProvider.class);
+        for (SPIProvider spiObject : ldr) {
+            spiObject.doit(); // invoke the SPI object
+        }
+	}
+	
+	public void stop(BundleContext context) throws Exception {
+	}
+}

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/BundleAspect.aj
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/BundleAspect.aj?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/BundleAspect.aj (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/SPIConsumerBundle/src/org/apache/aries/spifly/consumer/BundleAspect.aj Wed Jun 16 15:47:41 2010
@@ -0,0 +1,79 @@
+/**
+ * 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.consumer;
+
+import java.util.Arrays;
+import java.util.ServiceLoader;
+
+import org.apache.aries.spifly.api.SPIClassloaderAdviceService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleReference;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+public aspect BundleAspect {
+    pointcut serviceloader(Class cls) : 
+        args(cls) && call(ServiceLoader ServiceLoader.load(Class));
+    
+    ServiceLoader around(Class cls) : serviceloader(cls) {
+        ClassLoader loader = SPIClassloaderAdviceService.class.getClassLoader();
+        System.out.println("++++++++++++++++" + loader);
+        if (!(loader instanceof BundleReference)) { 
+            return proceed(cls);
+        }
+        BundleReference bref = (BundleReference) loader;
+        Bundle b = bref.getBundle();
+        System.out.println("Bundle: " + b);
+
+        BundleContext ctx = b.getBundleContext();
+        ClassLoader targetLoader = null;
+        try {
+            ServiceReference[] refs = ctx.getServiceReferences(SPIClassloaderAdviceService.class.getName(), 
+                    "(AdviceClass=" + cls.getName() + ")");
+            if (refs == null) {
+                return proceed(cls);
+            }
+            
+            System.out.println("Services: " + Arrays.toString(refs));
+            for (int i=0 ; i < refs.length && targetLoader == null; i++) {
+                Object svc = ctx.getService(refs[i]);
+                if (svc instanceof SPIClassloaderAdviceService) {
+                    targetLoader = ((SPIClassloaderAdviceService) svc).getServiceClassLoader(cls);
+                }
+            }
+        } catch (InvalidSyntaxException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        if (targetLoader == null) {
+            return proceed(cls);
+        }        
+        
+        ClassLoader prevCl = Thread.currentThread().getContextClassLoader();                
+        try {
+            System.out.println("Setting thread context classloader to " + targetLoader);
+            Thread.currentThread().setContextClassLoader(targetLoader);
+            return proceed(cls);            
+        } finally {
+            Thread.currentThread().setContextClassLoader(prevCl);                       
+        }
+    }
+}

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.classpath
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.classpath?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.classpath (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.classpath Wed Jun 16 15:47:41 2010
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.project
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.project?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.project (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/.project Wed Jun 16 15:47:41 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ServiceLoaderAPI</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/META-INF/MANIFEST.MF?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/META-INF/MANIFEST.MF (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/META-INF/MANIFEST.MF Wed Jun 16 15:47:41 2010
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ServiceLoaderInfra
+Bundle-SymbolicName: ServiceLoaderAPI
+Bundle-Version: 1.0.0.qualifier
+Import-Package: org.apache.aries.spifly.api,
+ org.osgi.framework;version="1.3.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.apache.aries.spifly.api

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/build.properties
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/build.properties?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/build.properties (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/build.properties Wed Jun 16 15:47:41 2010
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/aries/spifly/api/SPIClassloaderAdviceService.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/aries/spifly/api/SPIClassloaderAdviceService.java?rev=955276&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/aries/spifly/api/SPIClassloaderAdviceService.java (added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_unmodified_consumer/ServiceLoaderAPI/src/org/apache/aries/spifly/api/SPIClassloaderAdviceService.java Wed Jun 16 15:47:41 2010
@@ -0,0 +1,23 @@
+/**
+ * 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.api;
+
+public interface SPIClassloaderAdviceService {
+    ClassLoader getServiceClassLoader(Class<?> cls);
+}