incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1030993 - in /incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook: ./ META-INF/ src/ src/testweavinghook/
Date Thu, 04 Nov 2010 13:56:04 GMT
Author: davidb
Date: Thu Nov  4 13:56:04 2010
New Revision: 1030993

URL: http://svn.apache.org/viewvc?rev=1030993&view=rev
Log:
Initial import.

Added:
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.classpath
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.project
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/META-INF/
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/META-INF/MANIFEST.MF
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/build.properties
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Activator.java
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/MyWeavingHook.java
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Streams.java
Modified:
    incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/   (props
changed)

Propchange: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Nov  4 13:56:04 2010
@@ -0,0 +1 @@
+.settings

Added: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.classpath
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.classpath?rev=1030993&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.classpath
(added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.classpath
Thu Nov  4 13:56:04 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_using_weavinghook/TestWeavingHook/.project
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.project?rev=1030993&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.project
(added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/.project
Thu Nov  4 13:56:04 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>TestWeavingHook</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_using_weavinghook/TestWeavingHook/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/META-INF/MANIFEST.MF?rev=1030993&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/META-INF/MANIFEST.MF
(added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/META-INF/MANIFEST.MF
Thu Nov  4 13:56:04 2010
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: TestWeavingHook
+Bundle-SymbolicName: TestWeavingHook
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: testweavinghook.Activator
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0",
+ org.osgi.framework.hooks.weaving;version="1.0.0",
+ org.osgi.framework.wiring;version="1.0.0"

Added: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/build.properties
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/build.properties?rev=1030993&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/build.properties
(added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/build.properties
Thu Nov  4 13:56:04 2010
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Activator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Activator.java?rev=1030993&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Activator.java
(added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Activator.java
Thu Nov  4 13:56:04 2010
@@ -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 testweavinghook;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.hooks.weaving.WeavingHook;
+
+public class Activator implements BundleActivator {
+	private ServiceRegistration<WeavingHook> reg;
+
+	public void start(BundleContext context) throws Exception {
+		System.out.println("Hello World!!");
+		
+		WeavingHook wh = new MyWeavingHook();
+		reg = context.registerService(WeavingHook.class, wh, null);
+	}
+	
+	public void stop(BundleContext context) throws Exception {
+		reg.unregister();
+		
+		System.out.println("Goodbye World!!");
+	}
+}

Added: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/MyWeavingHook.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/MyWeavingHook.java?rev=1030993&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/MyWeavingHook.java
(added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/MyWeavingHook.java
Thu Nov  4 13:56:04 2010
@@ -0,0 +1,52 @@
+/**
+ * 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 testweavinghook;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import org.osgi.framework.hooks.weaving.WeavingHook;
+import org.osgi.framework.hooks.weaving.WovenClass;
+import org.osgi.framework.wiring.BundleWiring;
+
+public class MyWeavingHook implements WeavingHook {
+
+	@Override
+	public void weave(WovenClass wovenClass) {
+	    System.out.println("*** WovenClass: " + wovenClass.getClassName());
+		if (wovenClass.getClassName().startsWith("mytestbundle")) {
+			BundleWiring bw = wovenClass.getBundleWiring();
+			String fileName = wovenClass.getClassName().replace('.', '/') + ".class";
+			URL res = bw.getBundle().getResource("/altclasses/" + fileName);
+			if (res != null) {
+				System.out.println("*** Found an alternative class: " + res);
+				try {
+					wovenClass.setBytes(Streams.suck(res.openStream()));
+					List<String> imports = wovenClass.getDynamicImports();
+					imports.add("org.apache.aries.spifly.util");
+					imports.add("org.osgi.util.tracker");
+					imports.add("org.osgi.framework.wiring");
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}				
+		}			
+	}
+}

Added: incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Streams.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Streams.java?rev=1030993&view=auto
==============================================================================
--- incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Streams.java
(added)
+++ incubator/aries/trunk/spi-fly/contrib/pilot_using_weavinghook/TestWeavingHook/src/testweavinghook/Streams.java
Thu Nov  4 13:56:04 2010
@@ -0,0 +1,57 @@
+/**
+ * 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 testweavinghook;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class Streams {
+    private Streams() {}
+    
+    public static void pump(InputStream is, OutputStream os) throws IOException {       

+        byte[] bytes = new byte[8192];
+
+        int length = 0;
+        int offset = 0;
+
+        while ((length = is.read(bytes, offset, bytes.length - offset)) != -1) {
+            offset += length;
+
+            if (offset == bytes.length) {
+                os.write(bytes, 0, bytes.length);
+                offset = 0;
+            }
+        }
+        if (offset != 0) {
+            os.write(bytes, 0, offset);
+        }
+    }
+    
+    public static byte [] suck(InputStream is) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            pump(is, baos);
+            return baos.toByteArray();
+        } finally {
+            is.close();
+        }
+    }
+}



Mime
View raw message