diff options
Diffstat (limited to 'framework')
11 files changed, 188 insertions, 187 deletions
diff --git a/framework/bundles/org.eclipse.ecf.identity/.settings/.api_filters b/framework/bundles/org.eclipse.ecf.identity/.settings/.api_filters deleted file mode 100644 index 3a63a0c37..000000000 --- a/framework/bundles/org.eclipse.ecf.identity/.settings/.api_filters +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<component id="org.eclipse.ecf.identity" version="2"> - <resource path="src/org/eclipse/ecf/core/util/SystemLogService.java" type="org.eclipse.ecf.core.util.SystemLogService"> - <filter id="574619656"> - <message_arguments> - <message_argument value="LogService"/> - <message_argument value="SystemLogService"/> - </message_arguments> - </filter> - </resource> -</component> diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java index c86517199..aa5e1cb25 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/BaseID.java @@ -41,8 +41,7 @@ public abstract class BaseID implements ID { * @see java.lang.Comparable#compareTo(T) */ public int compareTo(Object o) { - Assert.isTrue(o != null && o instanceof BaseID, - "incompatible types for compare"); //$NON-NLS-1$ + Assert.isTrue(o != null && o instanceof BaseID, "incompatible types for compare"); //$NON-NLS-1$ return namespace.getCompareToForObject(this, (BaseID) o); } @@ -139,11 +138,10 @@ public abstract class BaseID implements ID { * * <pre> * namespace.getScheme() + Namespace.SCHEME_SEPARATOR + namespaceGetName(); - * </pre> + * </pre> */ protected String namespaceToExternalForm() { - return namespace.getScheme() + Namespace.SCHEME_SEPARATOR - + namespaceGetName(); + return namespace.getScheme() + Namespace.SCHEME_SEPARATOR + namespaceGetName(); } /* @@ -151,9 +149,9 @@ public abstract class BaseID implements ID { * * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ + @SuppressWarnings("unchecked") public Object getAdapter(@SuppressWarnings("rawtypes") Class clazz) { - IAdapterManager adapterManager = Activator.getDefault() - .getAdapterManager(); + IAdapterManager adapterManager = Activator.getDefault().getAdapterManager(); if (adapterManager == null) return null; return adapterManager.getAdapter(this, clazz.getName()); diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java index 46663b789..ad3c8ce99 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/identity/Namespace.java @@ -214,8 +214,7 @@ public abstract class Namespace implements Serializable, IAdaptable { * @throws IDCreateException * if construction fails */ - public abstract ID createInstance(Object[] parameters) - throws IDCreateException; + public abstract ID createInstance(Object[] parameters) throws IDCreateException; /** * Get the primary scheme associated with this namespace. Subclasses must @@ -291,6 +290,7 @@ public abstract class Namespace implements Serializable, IAdaptable { * * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ + @SuppressWarnings("unchecked") public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (adapter.isInstance(this)) { return this; diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AbstractFactory.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AbstractFactory.java index 212b4f30d..4f3f1756c 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AbstractFactory.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AbstractFactory.java @@ -9,7 +9,9 @@ package org.eclipse.ecf.core.util; public class AbstractFactory { - public static Class[] getClassesForTypes(String[] argTypes, Object[] args, ClassLoader cl) throws ClassNotFoundException { + @SuppressWarnings("rawtypes") + public static Class[] getClassesForTypes(String[] argTypes, Object[] args, ClassLoader cl) + throws ClassNotFoundException { Class clazzes[] = null; if (args == null || args.length == 0) clazzes = new Class[0]; diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AdapterManagerTracker.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AdapterManagerTracker.java index 53ddd5f0f..d9148e5b1 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AdapterManagerTracker.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/AdapterManagerTracker.java @@ -16,10 +16,11 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; /** * @since 3.4 */ +@SuppressWarnings("rawtypes") public class AdapterManagerTracker extends ServiceTracker { - public AdapterManagerTracker(BundleContext context, - ServiceTrackerCustomizer customizer) { + @SuppressWarnings("unchecked") + public AdapterManagerTracker(BundleContext context, ServiceTrackerCustomizer customizer) { super(context, IAdapterManager.class.getName(), customizer); } diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ExtensionRegistryRunnable.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ExtensionRegistryRunnable.java index 1264147d5..9ac8ef254 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ExtensionRegistryRunnable.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/ExtensionRegistryRunnable.java @@ -28,16 +28,15 @@ public class ExtensionRegistryRunnable implements ISafeRunnable { // by default do nothing } - protected void runWithRegistry(IExtensionRegistry registry) - throws Exception { + protected void runWithRegistry(IExtensionRegistry registry) throws Exception { // by default do nothing } protected void logWarning(Throwable exception) { Activator a = Activator.getDefault(); if (a != null) - a.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, - IStatus.WARNING, "Warning: code cannot be run", exception)); //$NON-NLS-1$ + a.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, IStatus.WARNING, "Warning: code cannot be run", //$NON-NLS-1$ + exception)); } public void run() throws Exception { @@ -51,11 +50,10 @@ public class ExtensionRegistryRunnable implements ISafeRunnable { private IExtensionRegistry getExtensionRegistry() { if (context == null) return null; - ServiceTracker extensionRegistryTracker = new ServiceTracker(context, - IExtensionRegistry.class.getName(), null); + @SuppressWarnings({ "rawtypes", "unchecked" }) + ServiceTracker extensionRegistryTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), null); extensionRegistryTracker.open(); - IExtensionRegistry result = (IExtensionRegistry) extensionRegistryTracker - .getService(); + IExtensionRegistry result = (IExtensionRegistry) extensionRegistryTracker.getService(); extensionRegistryTracker.close(); return result; } diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/IDFactoryTracker.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/IDFactoryTracker.java index 9cbd45e3a..dd329f369 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/IDFactoryTracker.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/IDFactoryTracker.java @@ -20,8 +20,10 @@ import org.osgi.util.tracker.ServiceTracker; * @since 3.1 * */ +@SuppressWarnings("rawtypes") public class IDFactoryTracker extends ServiceTracker { + @SuppressWarnings("unchecked") public IDFactoryTracker(BundleContext context) { super(context, IIDFactory.class.getName(), null); } diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java index ce089ce02..1e0e4dcee 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java @@ -26,6 +26,7 @@ import org.osgi.framework.BundleContext; */ public class PlatformHelper { + @SuppressWarnings("rawtypes") private static Class platformClass = null; private static IAdapterManager adapterManagerCache = null; @@ -41,11 +42,9 @@ public class PlatformHelper { Bundle[] bundles = c.getBundles(); Bundle coreRuntime = null; for (int i = 0; i < bundles.length; i++) - if (bundles[i].getSymbolicName().equals( - "org.eclipse.core.runtime")) { //$NON-NLS-1$ + if (bundles[i].getSymbolicName().equals("org.eclipse.core.runtime")) { //$NON-NLS-1$ coreRuntime = bundles[i]; - platformClass = coreRuntime - .loadClass("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$ + platformClass = coreRuntime.loadClass("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$ break; } } @@ -54,8 +53,8 @@ public class PlatformHelper { // log // as error try { - a.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, - IStatus.WARNING, "Cannot load Platform class", //$NON-NLS-1$ + a.log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, IStatus.WARNING, + "Cannot load Platform class", //$NON-NLS-1$ e)); } catch (Throwable t) { // Should never happen, if does irrecoverable @@ -73,16 +72,13 @@ public class PlatformHelper { return adapterManagerCache; if (isPlatformAvailable()) { try { - Method m = platformClass.getMethod( - "getAdapterManager", (Class[]) null); //$NON-NLS-1$ - adapterManagerCache = (IAdapterManager) m.invoke(null, - (Object[]) null); + @SuppressWarnings("unchecked") + Method m = platformClass.getMethod("getAdapterManager", (Class[]) null); //$NON-NLS-1$ + adapterManagerCache = (IAdapterManager) m.invoke(null, (Object[]) null); return adapterManagerCache; } catch (Exception e) { - Activator.getDefault().log( - new Status(IStatus.WARNING, Activator.PLUGIN_ID, - IStatus.WARNING, - "Cannot get PlatformAdapterManager()", e)); //$NON-NLS-1$ + Activator.getDefault().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, IStatus.WARNING, + "Cannot get PlatformAdapterManager()", e)); //$NON-NLS-1$ return null; } } @@ -94,16 +90,13 @@ public class PlatformHelper { return extensionRegistryCache; if (isPlatformAvailable()) { try { - Method m = platformClass.getMethod( - "getExtensionRegistry", (Class[]) null); //$NON-NLS-1$ - extensionRegistryCache = (IExtensionRegistry) m.invoke(null, - (Object[]) null); + @SuppressWarnings("unchecked") + Method m = platformClass.getMethod("getExtensionRegistry", (Class[]) null); //$NON-NLS-1$ + extensionRegistryCache = (IExtensionRegistry) m.invoke(null, (Object[]) null); return extensionRegistryCache; } catch (Exception e) { - Activator.getDefault().log( - new Status(IStatus.WARNING, Activator.PLUGIN_ID, - IStatus.WARNING, - "Cannot get PlatformExtensionRegistry()", e)); //$NON-NLS-1$ + Activator.getDefault().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, IStatus.WARNING, + "Cannot get PlatformExtensionRegistry()", e)); //$NON-NLS-1$ return null; } diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java index bb5685c33..d8f4a5ff2 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/StringUtils.java @@ -27,10 +27,11 @@ import java.util.ArrayList; */ public final class StringUtils { + @SuppressWarnings({ "unchecked", "rawtypes" }) public static final String[] splitOnSpace(String string) { int index = string.indexOf(' '); if (index == -1) { - return new String[] {string}; + return new String[] { string }; } ArrayList split = new ArrayList(); @@ -47,10 +48,11 @@ public final class StringUtils { return (String[]) split.toArray(new String[split.size()]); } + @SuppressWarnings({ "unchecked", "rawtypes" }) public static final String[] split(String string, char character) { int index = string.indexOf(character); if (index == -1) { - return new String[] {string}; + return new String[] { string }; } ArrayList split = new ArrayList(); @@ -67,10 +69,11 @@ public final class StringUtils { return (String[]) split.toArray(new String[split.size()]); } + @SuppressWarnings({ "unchecked", "rawtypes" }) public static final String[] split(String string, String delimiter) { int index = string.indexOf(delimiter); if (index == -1) { - return new String[] {string}; + return new String[] { string }; } int length = delimiter.length(); @@ -88,10 +91,11 @@ public final class StringUtils { return (String[]) split.toArray(new String[split.size()]); } + @SuppressWarnings({ "unchecked", "rawtypes" }) public static final String[] split(String string, String delimiter, int limit) { int index = string.indexOf(delimiter); if (index == -1) { - return new String[] {string}; + return new String[] { string }; } int count = 0; @@ -209,40 +213,60 @@ public final class StringUtils { /** * Returns whether the first parameter contains the second parameter. - * @param string must not be <code>. - * @param target must not be <code> null. - * @return true if the target is contained within the string. + * + * @param string + * must not be <code>. + * @param target + * must not be <code> null. + * @return true if the target is contained within the string. */ public static boolean contains(String string, String target) { return (string.indexOf(target) != -1); } /** - * Returns the string resulting from replacing all occurrences of the target with the replace - * string. Note that the target matches literally, and this is not the same behavior as the - * String.replaceAll, which uses regular expressions for doing the matching. - * @param string the start string. Must not be <code>null</code>. - * @param target the target to search for in the start string. Must not be <code>null</code>. - * @param replace the replacement string to substitute when the target is found. Must not be <code>null</code>. - * @return String result. Will not be <code>null</code>. If target is not found in the given string, - * then the result will be the entire input string. + * Returns the string resulting from replacing all occurrences of the target + * with the replace string. Note that the target matches literally, and this + * is not the same behavior as the String.replaceAll, which uses regular + * expressions for doing the matching. + * + * @param string + * the start string. Must not be <code>null</code>. + * @param target + * the target to search for in the start string. Must not be + * <code>null</code>. + * @param replace + * the replacement string to substitute when the target is found. + * Must not be <code>null</code>. + * @return String result. Will not be <code>null</code>. If target is not + * found in the given string, then the result will be the entire + * input string. */ public static String replaceAll(String string, String target, String replace) { final int index = string.indexOf(target); if (index == -1) return string; - return string.substring(0, index) + replace + replaceAll(string.substring(index + target.length()), target, replace); + return string.substring(0, index) + replace + + replaceAll(string.substring(index + target.length()), target, replace); } /** - * Returns the string resulting from replacing all occurrences of the target with the replace - * string. Note that the target matches literally but ignoring the case, and this is not the same behavior as the - * String.replaceAll, which uses regular expressions for doing the matching. - * @param string the start string. Must not be <code>null</code>. - * @param target the target to search for in the start string. Must not be <code>null</code>. - * @param replace the replacement string to substitute when the target is found. Must not be <code>null</code>. - * @return String result. Will not be <code>null</code>. If target is not found in the given string, - * then the result will be the entire input string. + * Returns the string resulting from replacing all occurrences of the target + * with the replace string. Note that the target matches literally but + * ignoring the case, and this is not the same behavior as the + * String.replaceAll, which uses regular expressions for doing the matching. + * + * @param string + * the start string. Must not be <code>null</code>. + * @param target + * the target to search for in the start string. Must not be + * <code>null</code>. + * @param replace + * the replacement string to substitute when the target is found. + * Must not be <code>null</code>. + * @return String result. Will not be <code>null</code>. If target is not + * found in the given string, then the result will be the entire + * input string. * * @see StringUtils#replaceAll(String, String, String) but case insensitive * @since 2.1 @@ -251,18 +275,27 @@ public final class StringUtils { final int index = string.toLowerCase().indexOf(target.toLowerCase()); if (index == -1) return string; - return string.substring(0, index) + replace + replaceAllIgnoreCase(string.substring(index + target.length()), target, replace); + return string.substring(0, index) + replace + + replaceAllIgnoreCase(string.substring(index + target.length()), target, replace); } - + /** - * Returns the string resulting from replacing the first occurrences of the target with the replace - * string. Note that the target matches literally, and this is not the same behavior as the - * String.replaceAll, which uses regular expressions for doing the matching. - * @param string the start string. Must not be <code>null</code>. - * @param target the target to search for in the start string. Must not be <code>null</code>. - * @param replace the replacement string to substitute when the target is found. Must not be <code>null</code>. - * @return String result. Will not be <code>null</code>. If target is not found in the given string, - * then the result will be the entire input string. + * Returns the string resulting from replacing the first occurrences of the + * target with the replace string. Note that the target matches literally, + * and this is not the same behavior as the String.replaceAll, which uses + * regular expressions for doing the matching. + * + * @param string + * the start string. Must not be <code>null</code>. + * @param target + * the target to search for in the start string. Must not be + * <code>null</code>. + * @param replace + * the replacement string to substitute when the target is found. + * Must not be <code>null</code>. + * @return String result. Will not be <code>null</code>. If target is not + * found in the given string, then the result will be the entire + * input string. * * @since 3.0 */ diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/SystemLogService.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/SystemLogService.java index de55d1726..48159f07d 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/SystemLogService.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/SystemLogService.java @@ -13,7 +13,6 @@ package org.eclipse.ecf.core.util; import java.text.SimpleDateFormat; import java.util.Date; - import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; @@ -32,20 +31,21 @@ public class SystemLogService implements LogService { private static final String getLogCode(int level) { switch (level) { - case LogService.LOG_INFO : - return "INFO"; //$NON-NLS-1$ - case LogService.LOG_ERROR : - return "ERROR"; //$NON-NLS-1$ - case LogService.LOG_DEBUG : - return "DEBUG"; //$NON-NLS-1$ - case LogService.LOG_WARNING : - return "WARNING"; //$NON-NLS-1$ - default : - return "UNKNOWN"; //$NON-NLS-1$ + case LogService.LOG_INFO: + return "INFO"; //$NON-NLS-1$ + case LogService.LOG_ERROR: + return "ERROR"; //$NON-NLS-1$ + case LogService.LOG_DEBUG: + return "DEBUG"; //$NON-NLS-1$ + case LogService.LOG_WARNING: + return "WARNING"; //$NON-NLS-1$ + default: + return "UNKNOWN"; //$NON-NLS-1$ } } - private final void doLog(ServiceReference sr, int level, String message, Throwable t) { + private final void doLog(@SuppressWarnings("rawtypes") ServiceReference sr, int level, String message, + Throwable t) { final StringBuffer buf = new StringBuffer("[log;"); //$NON-NLS-1$ buf.append(dateFormat.format(new Date())).append(";"); //$NON-NLS-1$ buf.append(getLogCode(level)).append(";"); //$NON-NLS-1$ @@ -61,31 +61,44 @@ public class SystemLogService implements LogService { System.out.println(buf.toString()); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.osgi.service.log.LogService#log(int, java.lang.String) */ public void log(int level, String message) { log(null, level, message, null); } - /* (non-Javadoc) - * @see org.osgi.service.log.LogService#log(int, java.lang.String, java.lang.Throwable) + /* + * (non-Javadoc) + * + * @see org.osgi.service.log.LogService#log(int, java.lang.String, + * java.lang.Throwable) */ public void log(int level, String message, Throwable exception) { doLog(null, level, message, exception); } - /* (non-Javadoc) - * @see org.osgi.service.log.LogService#log(org.osgi.framework.ServiceReference, int, java.lang.String) + /* + * (non-Javadoc) + * + * @see + * org.osgi.service.log.LogService#log(org.osgi.framework.ServiceReference, + * int, java.lang.String) */ - public void log(ServiceReference sr, int level, String message) { + public void log(@SuppressWarnings("rawtypes") ServiceReference sr, int level, String message) { log(sr, level, message, null); } - /* (non-Javadoc) - * @see org.osgi.service.log.LogService#log(org.osgi.framework.ServiceReference, int, java.lang.String, java.lang.Throwable) + /* + * (non-Javadoc) + * + * @see + * org.osgi.service.log.LogService#log(org.osgi.framework.ServiceReference, + * int, java.lang.String, java.lang.Throwable) */ - public void log(ServiceReference sr, int level, String message, Throwable exception) { + public void log(@SuppressWarnings("rawtypes") ServiceReference sr, int level, String message, Throwable exception) { doLog(sr, level, message, exception); } diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java index 08ccc7ce8..363d01f03 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java @@ -43,16 +43,20 @@ public class Activator implements BundleActivator { private BundleContext context; + @SuppressWarnings("rawtypes") private ServiceRegistration idFactoryServiceRegistration; + @SuppressWarnings("rawtypes") private ServiceTracker debugOptionsTracker; + @SuppressWarnings("rawtypes") private ServiceTracker logServiceTracker; private LogService logService; private AdapterManagerTracker adapterManagerTracker; + @SuppressWarnings("rawtypes") private ServiceTracker namespacesTracker; // This is object rather than typed to avoid referencing the @@ -77,12 +81,12 @@ public class Activator implements BundleActivator { // public null constructor } + @SuppressWarnings({ "unchecked", "rawtypes" }) public synchronized DebugOptions getDebugOptions() { if (context == null) return null; if (debugOptionsTracker == null) { - debugOptionsTracker = new ServiceTracker(context, - DebugOptions.class.getName(), null); + debugOptionsTracker = new ServiceTracker(context, DebugOptions.class.getName(), null); debugOptionsTracker.open(); } return (DebugOptions) debugOptionsTracker.getService(); @@ -94,85 +98,66 @@ public class Activator implements BundleActivator { * @see * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ + @SuppressWarnings({ "unchecked", "rawtypes" }) public void start(BundleContext ctxt) throws Exception { plugin = this; this.context = ctxt; // Register IIDFactory service - idFactoryServiceRegistration = context.registerService( - IIDFactory.class.getName(), IDFactory.getDefault(), null); - - namespacesTracker = new ServiceTracker(context, - Namespace.class.getName(), new ServiceTrackerCustomizer() { - - public Object addingService(ServiceReference reference) { - Namespace ns = (Namespace) context - .getService(reference); - if (ns != null && ns.getName() != null) - IDFactory.addNamespace0(ns); - return ns; - } - - public void modifiedService(ServiceReference reference, - Object service) { - } - - public void removedService(ServiceReference reference, - Object service) { - IDFactory.removeNamespace0((Namespace) service); - } - }); + idFactoryServiceRegistration = context.registerService(IIDFactory.class.getName(), IDFactory.getDefault(), + null); + + namespacesTracker = new ServiceTracker(context, Namespace.class.getName(), new ServiceTrackerCustomizer() { + + public Object addingService(ServiceReference reference) { + Namespace ns = (Namespace) context.getService(reference); + if (ns != null && ns.getName() != null) + IDFactory.addNamespace0(ns); + return ns; + } + + public void modifiedService(ServiceReference reference, Object service) { + } + + public void removedService(ServiceReference reference, Object service) { + IDFactory.removeNamespace0((Namespace) service); + } + }); namespacesTracker.open(); SafeRunner.run(new ExtensionRegistryRunnable(ctxt) { - protected void runWithRegistry(IExtensionRegistry registry) - throws Exception { + protected void runWithRegistry(IExtensionRegistry registry) throws Exception { if (registry != null) { registryManager = new IRegistryChangeListener() { public void registryChanged(IRegistryChangeEvent event) { - final IExtensionDelta delta[] = event - .getExtensionDeltas(PLUGIN_ID, - NAMESPACE_NAME); + final IExtensionDelta delta[] = event.getExtensionDeltas(PLUGIN_ID, NAMESPACE_NAME); for (int i = 0; i < delta.length; i++) { switch (delta[i].getKind()) { case IExtensionDelta.ADDED: - addNamespaceExtensions(delta[i] - .getExtension() - .getConfigurationElements()); + addNamespaceExtensions(delta[i].getExtension().getConfigurationElements()); break; case IExtensionDelta.REMOVED: - IConfigurationElement[] members = delta[i] - .getExtension() + IConfigurationElement[] members = delta[i].getExtension() .getConfigurationElements(); for (int m = 0; m < members.length; m++) { final IConfigurationElement member = members[m]; String name = null; try { - name = member - .getAttribute(NAME_ATTRIBUTE); + name = member.getAttribute(NAME_ATTRIBUTE); if (name == null) { - name = member - .getAttribute(CLASS_ATTRIBUTE); + name = member.getAttribute(CLASS_ATTRIBUTE); } if (name == null) continue; - final IIDFactory factory = IDFactory - .getDefault(); - final Namespace n = factory - .getNamespaceByName(name); - if (n == null - || !factory - .containsNamespace(n)) { + final IIDFactory factory = IDFactory.getDefault(); + final Namespace n = factory.getNamespaceByName(name); + if (n == null || !factory.containsNamespace(n)) { continue; } // remove factory.removeNamespace(n); } catch (final Exception e) { - getDefault() - .log(new Status( - IStatus.ERROR, - Activator.PLUGIN_ID, - IStatus.ERROR, - "Exception removing namespace", e)); //$NON-NLS-1$ + getDefault().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, + IStatus.ERROR, "Exception removing namespace", e)); //$NON-NLS-1$ } } break; @@ -196,6 +181,7 @@ public class Activator implements BundleActivator { return context.getBundle(); } + @SuppressWarnings({ "rawtypes", "unchecked" }) synchronized LogService getLogService() { if (context == null) { if (logService == null) @@ -203,8 +189,7 @@ public class Activator implements BundleActivator { return logService; } if (logServiceTracker == null) { - logServiceTracker = new ServiceTracker(this.context, - LogService.class.getName(), null); + logServiceTracker = new ServiceTracker(this.context, LogService.class.getName(), null); logServiceTracker.open(); } logService = (LogService) logServiceTracker.getService(); @@ -218,8 +203,7 @@ public class Activator implements BundleActivator { logService = getLogService(); if (logService != null) - logService.log(LogHelper.getLogCode(status), - LogHelper.getLogMessage(status), status.getException()); + logService.log(LogHelper.getLogCode(status), LogHelper.getLogMessage(status), status.getException()); } /** @@ -237,15 +221,13 @@ public class Activator implements BundleActivator { final IExtension extension = member.getDeclaringExtension(); String nsName = null; try { - final Namespace ns = (Namespace) member - .createExecutableExtension(CLASS_ATTRIBUTE); + final Namespace ns = (Namespace) member.createExecutableExtension(CLASS_ATTRIBUTE); final String clazz = ns.getClass().getName(); nsName = member.getAttribute(NAME_ATTRIBUTE); if (nsName == null) { nsName = clazz; } - final String nsDescription = member - .getAttribute(DESCRIPTION_ATTRIBUTE); + final String nsDescription = member.getAttribute(DESCRIPTION_ATTRIBUTE); ns.initialize(nsName, nsDescription); // Check to see if we have a namespace name collision if (!IDFactory.containsNamespace0(ns)) { @@ -255,17 +237,11 @@ public class Activator implements BundleActivator { } catch (final CoreException e) { getDefault().log(e.getStatus()); } catch (final Exception e) { - getDefault() - .log(new Status( - IStatus.ERROR, - bundleName, - FACTORY_NAME_COLLISION_ERRORCODE, - "name=" //$NON-NLS-1$ - + nsName - + ";extension point id=" //$NON-NLS-1$ - + extension - .getExtensionPointUniqueIdentifier(), - null)); + getDefault().log(new Status(IStatus.ERROR, bundleName, FACTORY_NAME_COLLISION_ERRORCODE, + "name=" //$NON-NLS-1$ + + nsName + ";extension point id=" //$NON-NLS-1$ + + extension.getExtensionPointUniqueIdentifier(), + null)); } } } @@ -276,15 +252,12 @@ public class Activator implements BundleActivator { */ public void setupNamespaceExtensionPoint() { SafeRunner.run(new ExtensionRegistryRunnable(context) { - protected void runWithRegistry(IExtensionRegistry registry) - throws Exception { + protected void runWithRegistry(IExtensionRegistry registry) throws Exception { if (registry != null) { - final IExtensionPoint extensionPoint = registry - .getExtensionPoint(NAMESPACE_EPOINT); + final IExtensionPoint extensionPoint = registry.getExtensionPoint(NAMESPACE_EPOINT); if (extensionPoint == null) return; - addNamespaceExtensions(extensionPoint - .getConfigurationElements()); + addNamespaceExtensions(extensionPoint.getConfigurationElements()); } } }); @@ -298,8 +271,7 @@ public class Activator implements BundleActivator { */ public void stop(BundleContext ctxt) throws Exception { SafeRunner.run(new ExtensionRegistryRunnable(ctxt) { - protected void runWithRegistry(IExtensionRegistry registry) - throws Exception { + protected void runWithRegistry(IExtensionRegistry registry) throws Exception { if (registry != null) registry.removeRegistryChangeListener((IRegistryChangeListener) registryManager); } |