Bug 406518 - migrate OT/Equinox to the standard OSGi WeavingHook
- avoid bogus imports from old transformer.hook fragment
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBindingRegistry.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBindingRegistry.java
index b127d8d..942aa12 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBindingRegistry.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/AspectBindingRegistry.java
@@ -36,6 +36,7 @@
 import java.util.Set;
 
 import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.RegistryFactory;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -43,7 +44,6 @@
 import org.eclipse.objectteams.internal.osgi.weaving.AspectBinding.BaseBundle;
 import org.eclipse.objectteams.internal.osgi.weaving.AspectBinding.TeamBinding;
 import org.eclipse.objectteams.otequinox.Constants;
-import org.eclipse.objectteams.otequinox.hook.ILogger;
 import org.osgi.framework.Bundle;
 
 /**
@@ -97,7 +97,7 @@
 				@SuppressWarnings("deprecation")
 				Bundle[] aspectBundles = packageAdmin.getBundles(aspectBundleId, null);
 				if (aspectBundles == null || aspectBundles.length == 0 || (aspectBundles[0].getState() < Bundle.RESOLVED)) {
-					log(ILogger.ERROR, "aspect bundle "+aspectBundleId+" is not resolved - not loading aspectBindings.");
+					log(IStatus.ERROR, "aspect bundle "+aspectBundleId+" is not resolved - not loading aspectBindings.");
 					continue;
 				}
 				aspectBundle = aspectBundles[0];
@@ -106,12 +106,12 @@
 			//base:
 			IConfigurationElement[] basePlugins = currentBindingConfig.getChildren(BASE_PLUGIN);
 			if (basePlugins.length != 1) {
-				log(ILogger.ERROR, "aspectBinding of "+aspectBundleId+" must declare exactly one basePlugin");
+				log(IStatus.ERROR, "aspectBinding of "+aspectBundleId+" must declare exactly one basePlugin");
 				continue;
 			}
 			String baseBundleId = basePlugins[0].getAttribute(ID);
 			if (baseBundleId == null) {
-				log(ILogger.ERROR, "aspectBinding of "+aspectBundleId+" must specify the id of a basePlugin");
+				log(IStatus.ERROR, "aspectBinding of "+aspectBundleId+" must specify the id of a basePlugin");
 				continue;
 			}
 			BaseBundle baseBundle = baseBundleLookup.get(baseBundleId); 
@@ -152,7 +152,7 @@
 				addBindingForAspectBundle(aspectBundleId, binding);
 				hook.setBaseTripWire(packageAdmin, realBaseBundleId);
 
-				log(ILogger.INFO, "registered:\n"+binding);
+				log(IStatus.INFO, "registered:\n"+binding);
 			} catch (Throwable t) {
 				log(t, "Invalid aspectBinding extension");
 			}
@@ -172,41 +172,41 @@
 		for (IConfigurationElement fragment : fragments) {
 			String fragId = fragment.getAttribute(ID);
 			if (fragId == null) {
-				log(ILogger.ERROR, "Mandatory attribute \"id\" missing from element \"requiredFragment\" of aspect binding in "+aspectBundleId);
+				log(IStatus.ERROR, "Mandatory attribute \"id\" missing from element \"requiredFragment\" of aspect binding in "+aspectBundleId);
 				return false;
 			} 
 			if (packageAdmin == null) {
-				log(ILogger.ERROR, "Not checking required fragment "+fragId+" in aspect binding of "+aspectBundleId+", package admin service not present");
+				log(IStatus.ERROR, "Not checking required fragment "+fragId+" in aspect binding of "+aspectBundleId+", package admin service not present");
 				return false; // report only once.
 			}
 			
 			Bundle[] fragmentBundles = packageAdmin.getBundles(fragId, null);
 			if (fragmentBundles == null || fragmentBundles.length == 0) {
-				log(ILogger.ERROR, "Required fragment "+fragId+" not found in aspect binding of "+aspectBundleId);
+				log(IStatus.ERROR, "Required fragment "+fragId+" not found in aspect binding of "+aspectBundleId);
 				hasError = true;
 				continue;
 			}
 			Bundle fragmentBundle = fragmentBundles[0];
 			String aspectBindingHint = " (aspect binding of "+aspectBundleId+")";
 			if (packageAdmin.getBundleType(fragmentBundle) != org.osgi.service.packageadmin.PackageAdmin.BUNDLE_TYPE_FRAGMENT) {
-				log(ILogger.ERROR, "Required fragment " + fragId + " is not a fragment" + aspectBindingHint);
+				log(IStatus.ERROR, "Required fragment " + fragId + " is not a fragment" + aspectBindingHint);
 				hasError = true;
 				continue;
 			}
 			Bundle[] hosts = packageAdmin.getHosts(fragmentBundle);
 			if (hosts == null || hosts.length == 0) {
 				if (fragmentBundle.getState() < Bundle.RESOLVED) {
-					log(ILogger.ERROR, "Required fragment " + fragId + " is not resolved" + aspectBindingHint);
+					log(IStatus.ERROR, "Required fragment " + fragId + " is not resolved" + aspectBindingHint);
 					hasError = true;
 					continue;
 				}
-				log(ILogger.ERROR, "Required fragment "+fragId+" has no host bundle"+aspectBindingHint);
+				log(IStatus.ERROR, "Required fragment "+fragId+" has no host bundle"+aspectBindingHint);
 				hasError = true;					
 				continue;
 			}
 			Bundle host = hosts[0];
 			if (!host.getSymbolicName().equals(baseBundleId)) {
-				log(ILogger.ERROR, "Required fragment "+fragId+" has wrong host "+host.getSymbolicName()+aspectBindingHint);
+				log(IStatus.ERROR, "Required fragment "+fragId+" has wrong host "+host.getSymbolicName()+aspectBindingHint);
 				hasError = true;
 			}
 		}
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/ClassScanner.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/ClassScanner.java
index 0d48c5e..61ef558 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/ClassScanner.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/ClassScanner.java
@@ -26,10 +26,10 @@
 import java.util.HashMap;
 import java.util.List;
 
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.objectteams.otequinox.hook.ILogger;
 import org.eclipse.objectteams.otre.jplis.ObjectTeamsTransformer;
 import org.eclipse.objectteams.otre.util.CallinBindingManager;
 import org.osgi.framework.Bundle;
@@ -137,7 +137,7 @@
 		List<String> roles = CallinBindingManager.getRolePerTeam(className);
 		if (roles != null) {
 			for (@SuppressWarnings("null")@NonNull String roleName: roles) {
-				log(ILogger.OK, "scanning role "+roleName);
+				log(IStatus.OK, "scanning role "+roleName);
 				try {
 					this.roleClassNames.add(roleName);
 					readOTAttributes(bundle, roleName);					
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/Logger.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/Logger.java
index 7ee6979..7f548d4 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/Logger.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/Logger.java
@@ -19,8 +19,8 @@
  **********************************************************************/
 package org.eclipse.objectteams.internal.osgi.weaving;
 
-import org.eclipse.objectteams.otequinox.hook.HookConfigurator;
-import org.eclipse.objectteams.otequinox.hook.ILogger;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.objectteams.otequinox.Constants;
 import org.eclipse.osgi.framework.log.FrameworkLog;
 import org.eclipse.osgi.framework.log.FrameworkLogEntry;
 
@@ -31,8 +31,7 @@
  * @author stephan
  * @since OTDT 1.1.4
  */
-public class Logger implements ILogger
-{
+public class Logger {
 	private FrameworkLog fwLog;
 	
 	public Logger(FrameworkLog fwLog) {
@@ -40,7 +39,7 @@
 	}
 
 	public void log(Throwable t, String msg) {
-		log(HookConfigurator.class.getPackage().getName(), t, msg);
+		log(Constants.TRANSFORMER_PLUGIN_ID, t, msg);
 	}
 	public void log(String pluginID, Throwable t, String msg) {
 		if (this.fwLog != null) {
@@ -55,7 +54,7 @@
 	
 	public void log(int status, String msg) {
 		if (status >= Util.WARN_LEVEL)		
-			doLog(HookConfigurator.class.getPackage().getName(), status, msg);
+			doLog(Constants.TRANSFORMER_PLUGIN_ID, status, msg);
 	}
 	public void log(String pluginID, int status, String msg) {
 		if (status >= Util.WARN_LEVEL)
@@ -63,7 +62,7 @@
 	}
 	
 	public void doLog(int status, String msg) {
-		doLog(HookConfigurator.class.getPackage().getName(), status, msg);
+		doLog(Constants.TRANSFORMER_PLUGIN_ID, status, msg);
 	}
 	public void doLog(String pluginID, int status, String msg) {
 		if (this.fwLog != null) {
@@ -71,7 +70,7 @@
 		} else {
 			// no success logging, print to console instead:
 			msg = "OT/Equinox: "+msg; //$NON-NLS-1$
-			if ((status & ERROR) != 0)
+			if ((status & IStatus.ERROR) != 0)
 				System.err.println(msg);
 			else
 				System.out.println(msg);
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
index 05cc17e..488282d 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/OTWeavingHook.java
@@ -30,7 +30,6 @@
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.objectteams.otequinox.TransformerPlugin;
-import org.eclipse.objectteams.otequinox.hook.ILogger;
 import org.eclipse.objectteams.otre.jplis.ObjectTeamsTransformer;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -88,7 +87,7 @@
 		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.");
+			log(IStatus.ERROR, "Failed to load PackageAdmin service. Will not be able to handle fragments.");
 
 		aspectBindingRegistry.loadAspectBindings(packageAdmin, this);
 	}
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/TeamLoader.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/TeamLoader.java
index 7024f8a..40894e9 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/TeamLoader.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/internal/osgi/weaving/TeamLoader.java
@@ -30,7 +30,6 @@
 import org.eclipse.objectteams.internal.osgi.weaving.AspectBinding.TeamBinding;
 import org.eclipse.objectteams.otequinox.ActivationKind;
 import org.eclipse.objectteams.otequinox.TransformerPlugin;
-import org.eclipse.objectteams.otequinox.hook.ILogger;
 import org.objectteams.Team;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.hooks.weaving.WovenClass;
@@ -162,7 +161,7 @@
 		try {
 			@SuppressWarnings("null")@NonNull Team instance = team.teamClass.newInstance();
 			TransformerPlugin.registerTeamInstance(instance);
-			log(ILogger.INFO, "Instantiated team "+teamName);
+			log(IStatus.INFO, "Instantiated team "+teamName);
 			
 			try {
 				switch (activationKind) {
diff --git a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/otequinox/TransformerPlugin.java b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/otequinox/TransformerPlugin.java
index e2e112c..d2739ec 100644
--- a/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/otequinox/TransformerPlugin.java
+++ b/plugins/org.eclipse.objectteams.otequinox/src/org/eclipse/objectteams/otequinox/TransformerPlugin.java
@@ -11,7 +11,6 @@
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.objectteams.internal.osgi.weaving.AspectBinding;
 import org.eclipse.objectteams.internal.osgi.weaving.AspectBindingRegistry;
-import org.eclipse.objectteams.otequinox.hook.ILogger;
 import org.eclipse.objectteams.otre.ClassLoaderAccess;
 import org.objectteams.Team;
 import org.osgi.framework.Bundle;
@@ -72,21 +71,21 @@
 	}
 
 	// configure OT/Equinox debugging:
-	public static int WARN_LEVEL = ILogger.ERROR;
+	public static int WARN_LEVEL = IStatus.ERROR;
 	static {
 		String level = System.getProperty("otequinox.debug");
 		if (level != null) {
 			level = level.toUpperCase();
 			if (level.equals("OK"))
-				WARN_LEVEL = ILogger.OK;
+				WARN_LEVEL = IStatus.OK;
 			else if (level.equals("INFO"))
-				WARN_LEVEL = ILogger.INFO;
+				WARN_LEVEL = IStatus.INFO;
 			else if (level.startsWith("WARN"))
-				WARN_LEVEL = ILogger.WARNING;
+				WARN_LEVEL = IStatus.WARNING;
 			else if (level.startsWith("ERR"))
-				WARN_LEVEL = ILogger.ERROR;
+				WARN_LEVEL = IStatus.ERROR;
 			else
-				WARN_LEVEL = ILogger.OK;
+				WARN_LEVEL = IStatus.OK;
 		}
 	}