Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsuen2007-09-11 11:13:43 -0400
committerrsuen2007-09-11 11:13:43 -0400
commit86324f0a305f50ee843db2e01960057680f94449 (patch)
tree4ea39c4658bcf60704b08118bae56097aab48657
parent24c5858147e4b17fb592b0ee0e3975c7a41d10da (diff)
downloadorg.eclipse.ecf-86324f0a305f50ee843db2e01960057680f94449.tar.gz
org.eclipse.ecf-86324f0a305f50ee843db2e01960057680f94449.tar.xz
org.eclipse.ecf-86324f0a305f50ee843db2e01960057680f94449.zip
Use valueOf(String) instead of getBoolean(String) because these strings are not system properties.v20070911-1136
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java190
1 files changed, 124 insertions, 66 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
index f57ad9ca2..81299debb 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
@@ -50,13 +50,15 @@ public class ECFPlugin implements BundleActivator {
private static final String CONTAINER_FACTORY_NAME = "containerFactory"; //$NON-NLS-1$
- private static final String CONTAINER_FACTORY_EPOINT = ECFNAMESPACE + "." + CONTAINER_FACTORY_NAME; //$NON-NLS-1$
+ private static final String CONTAINER_FACTORY_EPOINT = ECFNAMESPACE
+ + "." + CONTAINER_FACTORY_NAME; //$NON-NLS-1$
private static final String STARTUP_NAME = "startup"; //$NON-NLS-1$
public static final String START_EPOINT = ECFNAMESPACE + "." + STARTUP_NAME; //$NON-NLS-1$
- public static final String PLUGIN_RESOURCE_BUNDLE = ECFNAMESPACE + ".ECFPluginResources"; //$NON-NLS-1$
+ public static final String PLUGIN_RESOURCE_BUNDLE = ECFNAMESPACE
+ + ".ECFPluginResources"; //$NON-NLS-1$
public static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
@@ -94,16 +96,20 @@ public class ECFPlugin implements BundleActivator {
public IAdapterManager getAdapterManager() {
// First, try to get the adapter manager via
if (adapterManagerTracker == null) {
- adapterManagerTracker = new ServiceTracker(this.context, IAdapterManager.class.getName(), null);
+ adapterManagerTracker = new ServiceTracker(this.context,
+ IAdapterManager.class.getName(), null);
adapterManagerTracker.open();
}
- IAdapterManager adapterManager = (IAdapterManager) adapterManagerTracker.getService();
+ IAdapterManager adapterManager = (IAdapterManager) adapterManagerTracker
+ .getService();
// Then, if the service isn't there, try to get from Platform class via
// PlatformHelper class
if (adapterManager == null)
adapterManager = PlatformHelper.getPlatformAdapterManager();
if (adapterManager == null)
- getDefault().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Cannot get adapter manager", null)); //$NON-NLS-1$
+ getDefault().log(
+ new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR,
+ "Cannot get adapter manager", null)); //$NON-NLS-1$
return adapterManager;
}
@@ -119,8 +125,8 @@ public class ECFPlugin implements BundleActivator {
}
protected void fireDisposables() {
- for (Iterator i = disposables.keySet().iterator(); i.hasNext();) {
- IDisposable d = (IDisposable) i.next();
+ for (final Iterator i = disposables.keySet().iterator(); i.hasNext();) {
+ final IDisposable d = (IDisposable) i.next();
if (d != null)
d.dispose();
}
@@ -134,22 +140,27 @@ public class ECFPlugin implements BundleActivator {
protected LogService getLogService() {
if (logServiceTracker == null) {
- logServiceTracker = new ServiceTracker(this.context, LogService.class.getName(), null);
+ logServiceTracker = new ServiceTracker(this.context,
+ LogService.class.getName(), null);
logServiceTracker.open();
}
return (LogService) logServiceTracker.getService();
}
public void log(IStatus status) {
- LogService logService = getLogService();
+ final LogService 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());
}
}
- protected void logException(IStatus status, String method, Throwable exception) {
+ protected void logException(IStatus status, String method,
+ Throwable exception) {
log(status);
- Trace.catching(ECFPlugin.PLUGIN_ID, ECFDebugOptions.EXCEPTIONS_CATCHING, ECFPlugin.class, method, exception);
+ Trace.catching(ECFPlugin.PLUGIN_ID,
+ ECFDebugOptions.EXCEPTIONS_CATCHING, ECFPlugin.class, method,
+ exception);
}
/**
@@ -158,14 +169,16 @@ public class ECFPlugin implements BundleActivator {
* @param members
* the members to remove
*/
- protected void removeContainerFactoryExtensions(IConfigurationElement[] members) {
- String method = "removeContainerFactoryExtensions"; //$NON-NLS-1$
- Trace.entering(ECFPlugin.PLUGIN_ID, ECFDebugOptions.METHODS_ENTERING, ECFPlugin.class, method, members);
+ protected void removeContainerFactoryExtensions(
+ IConfigurationElement[] members) {
+ final String method = "removeContainerFactoryExtensions"; //$NON-NLS-1$
+ Trace.entering(ECFPlugin.PLUGIN_ID, ECFDebugOptions.METHODS_ENTERING,
+ ECFPlugin.class, method, members);
// For each configuration element
for (int m = 0; m < members.length; m++) {
- IConfigurationElement member = members[m];
+ final IConfigurationElement member = members[m];
// Get the label of the extender plugin and the ID of the extension.
- IExtension extension = member.getDeclaringExtension();
+ final IExtension extension = member.getDeclaringExtension();
String name = null;
try {
// Get name and get version, if available
@@ -173,16 +186,22 @@ public class ECFPlugin implements BundleActivator {
if (name == null) {
name = member.getAttribute(CLASS_ATTRIBUTE);
}
- IContainerFactory factory = ContainerFactory.getDefault();
- ContainerTypeDescription cd = factory.getDescriptionByName(name);
+ final IContainerFactory factory = ContainerFactory.getDefault();
+ final ContainerTypeDescription cd = factory
+ .getDescriptionByName(name);
if (cd == null || !factory.containsDescription(cd)) {
continue;
}
// remove
factory.removeDescription(cd);
- Trace.trace(ECFPlugin.PLUGIN_ID, ECFDebugOptions.DEBUG, method + ".removed " + cd + " from factory"); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (Exception e) {
- logException(new Status(Status.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, NLS.bind(Messages.ECFPlugin_Container_Name_Collision_Prefix, name, extension.getExtensionPointUniqueIdentifier()), null), method, e);
+ Trace.trace(ECFPlugin.PLUGIN_ID, ECFDebugOptions.DEBUG, method
+ + ".removed " + cd + " from factory"); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (final Exception e) {
+ logException(new Status(Status.ERROR, getDefault().getBundle()
+ .getSymbolicName(), IStatus.ERROR, NLS.bind(
+ Messages.ECFPlugin_Container_Name_Collision_Prefix,
+ name, extension.getExtensionPointUniqueIdentifier()),
+ null), method, e);
}
}
}
@@ -194,19 +213,20 @@ public class ECFPlugin implements BundleActivator {
* to add
*/
protected void addContainerFactoryExtensions(IConfigurationElement[] members) {
- String method = "addContainerFactoryExtensions"; //$NON-NLS-1$
- Trace.entering(ECFPlugin.PLUGIN_ID, ECFDebugOptions.METHODS_ENTERING, ECFPlugin.class, method, members);
+ final String method = "addContainerFactoryExtensions"; //$NON-NLS-1$
+ Trace.entering(ECFPlugin.PLUGIN_ID, ECFDebugOptions.METHODS_ENTERING,
+ ECFPlugin.class, method, members);
// For each configuration element
for (int m = 0; m < members.length; m++) {
- IConfigurationElement member = members[m];
+ final IConfigurationElement member = members[m];
// Get the label of the extender plugin and the ID of the extension.
- IExtension extension = member.getDeclaringExtension();
+ final IExtension extension = member.getDeclaringExtension();
Object exten = null;
String name = null;
try {
// The only required attribute is "class"
exten = member.createExecutableExtension(CLASS_ATTRIBUTE);
- String clazz = exten.getClass().getName();
+ final String clazz = exten.getClass().getName();
// Get name and get version, if available
name = member.getAttribute(NAME_ATTRIBUTE);
if (name == null) {
@@ -219,25 +239,45 @@ public class ECFPlugin implements BundleActivator {
}
String s = member.getAttribute(SERVER_ATTRIBUTE);
- boolean server = (s == null) ? false : Boolean.getBoolean(s);
+ final boolean server = (s == null) ? false : Boolean.valueOf(s)
+ .booleanValue();
s = member.getAttribute(HIDDEN_ATTRIBUTE);
- boolean hidden = (s == null) ? false : Boolean.getBoolean(s);
+ final boolean hidden = (s == null) ? false : Boolean.valueOf(s)
+ .booleanValue();
// Now make description instance
- ContainerTypeDescription scd = new ContainerTypeDescription(name, (IContainerInstantiator) exten, description, server, hidden);
+ final ContainerTypeDescription scd = new ContainerTypeDescription(
+ name, (IContainerInstantiator) exten, description,
+ server, hidden);
- IContainerFactory factory = ContainerFactory.getDefault();
+ final IContainerFactory factory = ContainerFactory.getDefault();
if (factory.containsDescription(scd)) {
- throw new CoreException(new Status(Status.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, NLS.bind(Messages.ECFPlugin_Container_Name_Collision_Prefix, name, extension.getExtensionPointUniqueIdentifier()), null));
+ throw new CoreException(
+ new Status(
+ Status.ERROR,
+ getDefault().getBundle().getSymbolicName(),
+ IStatus.ERROR,
+ NLS
+ .bind(
+ Messages.ECFPlugin_Container_Name_Collision_Prefix,
+ name,
+ extension
+ .getExtensionPointUniqueIdentifier()),
+ null));
}
// Now add the description and we're ready to go.
factory.addDescription(scd);
- Trace.trace(ECFPlugin.PLUGIN_ID, ECFDebugOptions.DEBUG, method + ".added " + scd + " to factory " + factory); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (CoreException e) {
+ Trace.trace(ECFPlugin.PLUGIN_ID, ECFDebugOptions.DEBUG, method
+ + ".added " + scd + " to factory " + factory); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (final CoreException e) {
logException(e.getStatus(), method, e);
- } catch (Exception e) {
- logException(new Status(Status.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, NLS.bind(Messages.ECFPlugin_Container_Name_Collision_Prefix, name, extension.getExtensionPointUniqueIdentifier()), null), method, e);
+ } catch (final Exception e) {
+ logException(new Status(Status.ERROR, getDefault().getBundle()
+ .getSymbolicName(), IStatus.ERROR, NLS.bind(
+ Messages.ECFPlugin_Container_Name_Collision_Prefix,
+ name, extension.getExtensionPointUniqueIdentifier()),
+ null), method, e);
}
}
}
@@ -249,13 +289,15 @@ public class ECFPlugin implements BundleActivator {
* the BundleContext for this bundle
*/
protected void setupContainerFactoryExtensionPoint(BundleContext bc) {
- IExtensionRegistry reg = getExtensionRegistry();
+ final IExtensionRegistry reg = getExtensionRegistry();
if (reg != null) {
- IExtensionPoint extensionPoint = reg.getExtensionPoint(CONTAINER_FACTORY_EPOINT);
+ final IExtensionPoint extensionPoint = reg
+ .getExtensionPoint(CONTAINER_FACTORY_EPOINT);
if (extensionPoint == null) {
return;
}
- addContainerFactoryExtensions(extensionPoint.getConfigurationElements());
+ addContainerFactoryExtensions(extensionPoint
+ .getConfigurationElements());
}
}
@@ -270,9 +312,10 @@ public class ECFPlugin implements BundleActivator {
* the BundleContext fro this bundle
*/
protected void setupStartExtensionPoint(BundleContext bc) {
- IExtensionRegistry reg = getExtensionRegistry();
+ final IExtensionRegistry reg = getExtensionRegistry();
if (reg != null) {
- IExtensionPoint extensionPoint = reg.getExtensionPoint(START_EPOINT);
+ final IExtensionPoint extensionPoint = reg
+ .getExtensionPoint(START_EPOINT);
if (extensionPoint == null) {
return;
}
@@ -280,44 +323,51 @@ public class ECFPlugin implements BundleActivator {
}
}
- protected void runStartExtensions(IConfigurationElement[] configurationElements) {
- String method = "runStartExtensions"; //$NON-NLS-1$
+ protected void runStartExtensions(
+ IConfigurationElement[] configurationElements) {
+ final String method = "runStartExtensions"; //$NON-NLS-1$
// For each configuration element
for (int m = 0; m < configurationElements.length; m++) {
- IConfigurationElement member = configurationElements[m];
+ final IConfigurationElement member = configurationElements[m];
IECFStart exten = null;
String name = null;
try {
// The only required attribute is "class"
- exten = (IECFStart) member.createExecutableExtension(CLASS_ATTRIBUTE);
+ exten = (IECFStart) member
+ .createExecutableExtension(CLASS_ATTRIBUTE);
// Get name and get version, if available
name = member.getAttribute(NAME_ATTRIBUTE);
if (name == null)
name = exten.getClass().getName();
- startExtension(name, exten, Boolean.getBoolean(member.getAttribute(SYNCH_ATTRIBUTE)));
+ startExtension(name, exten, Boolean.valueOf(
+ member.getAttribute(SYNCH_ATTRIBUTE)).booleanValue());
- } catch (CoreException e) {
+ } catch (final CoreException e) {
logException(e.getStatus(), method, e);
- } catch (Exception e) {
- logException(new Status(Status.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, "Unknown start exception", e), method, e); //$NON-NLS-1$
+ } catch (final Exception e) {
+ logException(new Status(Status.ERROR, getDefault().getBundle()
+ .getSymbolicName(), IStatus.ERROR,
+ "Unknown start exception", e), method, e); //$NON-NLS-1$
}
}
}
- private void startExtension(String name, IECFStart exten, boolean synchronous) {
+ private void startExtension(String name, IECFStart exten,
+ boolean synchronous) {
// Create job to do start, and schedule
if (synchronous) {
IStatus result = null;
try {
result = exten.startup(new NullProgressMonitor());
- } catch (Exception e) {
- String message = "startup extension error"; //$NON-NLS-1$
- logException(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e), message, e);
+ } catch (final Exception e) {
+ final String message = "startup extension error"; //$NON-NLS-1$
+ logException(new Status(IStatus.ERROR, PLUGIN_ID,
+ IStatus.ERROR, message, e), message, e);
}
if (result != null && !result.isOK())
logException(result, result.getMessage(), result.getException());
} else {
- ECFStartJob job = new ECFStartJob(name, exten);
+ final ECFStartJob job = new ECFStartJob(name, exten);
job.schedule();
}
}
@@ -328,30 +378,38 @@ public class ECFPlugin implements BundleActivator {
public void start(BundleContext context) throws Exception {
plugin = this;
this.context = context;
- this.extensionRegistryTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), null);
+ this.extensionRegistryTracker = new ServiceTracker(context,
+ IExtensionRegistry.class.getName(), null);
this.extensionRegistryTracker.open();
- IExtensionRegistry registry = getExtensionRegistry();
+ final IExtensionRegistry registry = getExtensionRegistry();
if (registry != null) {
this.registryManager = new ECFRegistryManager();
registry.addRegistryChangeListener(registryManager);
}
- containerFactoryServiceRegistration = context.registerService(IContainerFactory.class.getName(), ContainerFactory.getDefault(), null);
- containerManagerServiceRegistration = context.registerService(IContainerManager.class.getName(), ContainerFactory.getDefault(), null);
+ containerFactoryServiceRegistration = context.registerService(
+ IContainerFactory.class.getName(), ContainerFactory
+ .getDefault(), null);
+ containerManagerServiceRegistration = context.registerService(
+ IContainerManager.class.getName(), ContainerFactory
+ .getDefault(), null);
setupContainerFactoryExtensionPoint(context);
setupStartExtensionPoint(context);
}
protected class ECFRegistryManager implements IRegistryChangeListener {
public void registryChanged(IRegistryChangeEvent event) {
- IExtensionDelta delta[] = event.getExtensionDeltas(ECFNAMESPACE, CONTAINER_FACTORY_NAME);
+ final IExtensionDelta delta[] = event.getExtensionDeltas(
+ ECFNAMESPACE, CONTAINER_FACTORY_NAME);
for (int i = 0; i < delta.length; i++) {
switch (delta[i].getKind()) {
- case IExtensionDelta.ADDED :
- addContainerFactoryExtensions(delta[i].getExtension().getConfigurationElements());
- break;
- case IExtensionDelta.REMOVED :
- removeContainerFactoryExtensions(delta[i].getExtension().getConfigurationElements());
- break;
+ case IExtensionDelta.ADDED:
+ addContainerFactoryExtensions(delta[i].getExtension()
+ .getConfigurationElements());
+ break;
+ case IExtensionDelta.REMOVED:
+ removeContainerFactoryExtensions(delta[i].getExtension()
+ .getConfigurationElements());
+ break;
}
}
}
@@ -363,7 +421,7 @@ public class ECFPlugin implements BundleActivator {
public void stop(BundleContext context) throws Exception {
fireDisposables();
this.disposables = null;
- IExtensionRegistry reg = getExtensionRegistry();
+ final IExtensionRegistry reg = getExtensionRegistry();
if (reg != null)
reg.removeRegistryChangeListener(registryManager);
this.registryManager = null;

Back to the top