Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.objectteams.osgi.weaving/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.objectteams.osgi.weaving/OSGI-INF/weavinghook.xml7
-rw-r--r--plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java5
-rw-r--r--plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/osgi/weaving/Activator.java45
4 files changed, 31 insertions, 30 deletions
diff --git a/plugins/org.eclipse.objectteams.osgi.weaving/META-INF/MANIFEST.MF b/plugins/org.eclipse.objectteams.osgi.weaving/META-INF/MANIFEST.MF
index 9abb55569..46c0025ea 100644
--- a/plugins/org.eclipse.objectteams.osgi.weaving/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.objectteams.osgi.weaving/META-INF/MANIFEST.MF
@@ -7,6 +7,8 @@ Bundle-Activator: org.eclipse.objectteams.osgi.weaving.Activator
Bundle-Vendor: Eclipse.org - Object Teams
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.objectteams.runtime;bundle-version="2.1.0",
- org.eclipse.osgi
+ org.eclipse.osgi,
+ org.eclipse.equinox.ds;bundle-version="1.4.100"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
+Service-Component: OSGI-INF/weavinghook.xml
diff --git a/plugins/org.eclipse.objectteams.osgi.weaving/OSGI-INF/weavinghook.xml b/plugins/org.eclipse.objectteams.osgi.weaving/OSGI-INF/weavinghook.xml
new file mode 100644
index 000000000..31f3c9de4
--- /dev/null
+++ b/plugins/org.eclipse.objectteams.osgi.weaving/OSGI-INF/weavinghook.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<component name="weavinghook">
+ <implementation class="org.eclipse.objectteams.internal.osgi.weaving.OTWeavingHook"/>
+ <service>
+ <provide interface="org.osgi.framework.hooks.weaving.WeavingHook"/>
+ </service>
+</component> \ No newline at end of file
diff --git a/plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java b/plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
index 8eeb123dc..3c51b4fb8 100644
--- a/plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
+++ b/plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
@@ -7,6 +7,7 @@ import java.security.ProtectionDomain;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.objectteams.osgi.weaving.Activator;
import org.eclipse.objectteams.otre.jplis.ObjectTeamsTransformer;
import org.osgi.framework.Bundle;
import org.osgi.framework.hooks.weaving.WeavingHook;
@@ -18,8 +19,8 @@ public class OTWeavingHook implements WeavingHook {
private AspectBindingRegistry aspectBindingRegistry;
private ObjectTeamsTransformer objectTeamsTransformer;
- public OTWeavingHook(AspectBindingRegistry aspectBindingRegistry) {
- this.aspectBindingRegistry = aspectBindingRegistry;
+ public OTWeavingHook() {
+ this.aspectBindingRegistry = Activator.loadAspectBindingRegistry();
this.objectTeamsTransformer = new ObjectTeamsTransformer();
}
diff --git a/plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/osgi/weaving/Activator.java b/plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/osgi/weaving/Activator.java
index ac7605fa4..bd2224623 100644
--- a/plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/osgi/weaving/Activator.java
+++ b/plugins/org.eclipse.objectteams.osgi.weaving/src/org/eclipse/objectteams/osgi/weaving/Activator.java
@@ -2,21 +2,16 @@ package org.eclipse.objectteams.osgi.weaving;
import static org.eclipse.objectteams.osgi.weaving.Constants.TRANSFORMER_PLUGIN_ID;
-import java.util.Hashtable;
-
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.objectteams.internal.osgi.weaving.AspectBindingRegistry;
-import org.eclipse.objectteams.internal.osgi.weaving.OTWeavingHook;
import org.eclipse.objectteams.otequinox.hook.ILogger;
import org.eclipse.objectteams.otre.ClassLoaderAccess;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.hooks.weaving.WeavingHook;
public class Activator implements BundleActivator {
@@ -26,12 +21,6 @@ public class Activator implements BundleActivator {
return context;
}
- private ServiceRegistration<WeavingHook> serviceRegistration;
- private AspectBindingRegistry aspectBindingRegistry;
-
- @SuppressWarnings("deprecation")
- private org.osgi.service.packageadmin.PackageAdmin packageAdmin;
-
private static ILog log;
/*
@@ -41,30 +30,33 @@ public class Activator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
- frameworkInit(bundleContext);
-
- this.aspectBindingRegistry = new AspectBindingRegistry();
- this.aspectBindingRegistry.loadAspectBindings(this.packageAdmin);
+ acquireLog(bundleContext);
+
+ OTREInit();
+ }
- OTWeavingHook otWeavingHook = new OTWeavingHook(this.aspectBindingRegistry);
- this.serviceRegistration = context.registerService(WeavingHook.class, otWeavingHook, new Hashtable<String, Object>());
+ @SuppressWarnings("deprecation")
+ public static AspectBindingRegistry loadAspectBindingRegistry() {
+ org.osgi.service.packageadmin.PackageAdmin packageAdmin = null;;
- OTREInit();
+ ServiceReference<?> ref= context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class.getName());
+ if (ref!=null)
+ packageAdmin = (org.osgi.service.packageadmin.PackageAdmin)context.getService(ref);
+ else
+ log(ILogger.ERROR, "Failed to load PackageAdmin service. Will not be able to handle fragments.");
+
+ AspectBindingRegistry aspectBindingRegistry = new AspectBindingRegistry();
+ aspectBindingRegistry.loadAspectBindings(packageAdmin);
+ return aspectBindingRegistry;
}
- @SuppressWarnings({ "restriction", "deprecation" })
- private void frameworkInit(BundleContext bundleContext) {
+ @SuppressWarnings("restriction")
+ private void acquireLog(BundleContext bundleContext) {
try {
Activator.log = org.eclipse.core.internal.runtime.InternalPlatform.getDefault().getLog(bundleContext.getBundle());
} catch (NullPointerException npe) {
// WTF?
}
-
- ServiceReference<?> ref= context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class.getName());
- if (ref!=null)
- this.packageAdmin = (org.osgi.service.packageadmin.PackageAdmin)context.getService(ref);
- else
- log(ILogger.ERROR, "Failed to load PackageAdmin service. Will not be able to handle fragments.");
}
private void OTREInit() {
@@ -82,7 +74,6 @@ public class Activator implements BundleActivator {
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
- this.serviceRegistration.unregister();
}
// configure OT/Equinox debugging:

Back to the top