diff options
author | slewis | 2008-01-13 22:45:55 +0000 |
---|---|---|
committer | slewis | 2008-01-13 22:45:55 +0000 |
commit | 89fc0a1124f57558d39c9758eb3d514c554a6d39 (patch) | |
tree | b5e7de24d1fb1aa5d33da5459235dd757b7ad992 /framework/bundles/org.eclipse.ecf | |
parent | fed8723fc96ab31e153b6164b88ce91278f00f69 (diff) | |
download | org.eclipse.ecf-89fc0a1124f57558d39c9758eb3d514c554a6d39.tar.gz org.eclipse.ecf-89fc0a1124f57558d39c9758eb3d514c554a6d39.tar.xz org.eclipse.ecf-89fc0a1124f57558d39c9758eb3d514c554a6d39.zip |
String externalization in BaseContainer. Added to functionality of BaseContainerInstantiator and added test code.
Diffstat (limited to 'framework/bundles/org.eclipse.ecf')
4 files changed, 27 insertions, 3 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/BaseContainer.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/BaseContainer.java index 06afd0d62..d42a14585 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/BaseContainer.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/BaseContainer.java @@ -10,9 +10,11 @@ *****************************************************************************/ package org.eclipse.ecf.core; +import org.eclipse.core.runtime.Assert; import org.eclipse.ecf.core.identity.*; import org.eclipse.ecf.core.provider.BaseContainerInstantiator; import org.eclipse.ecf.core.security.IConnectContext; +import org.eclipse.ecf.internal.core.Messages; /** * Base implementation of IContainer. Subclasses may be created to fill out the @@ -27,6 +29,16 @@ public class BaseContainer extends AbstractContainer { private static long nextBaseContainerID = 0L; public IContainer createInstance(ContainerTypeDescription description, Object[] parameters) throws ContainerCreateException { + try { + if (parameters != null && parameters.length > 0) { + if (parameters[0] instanceof ID) + return new BaseContainer((ID) parameters[0]); + if (parameters[0] instanceof String) + return new BaseContainer(IDFactory.getDefault().createStringID((String) parameters[0])); + } + } catch (IDCreateException e) { + throw new ContainerCreateException(Messages.BaseContainer_EXCEPTION_COULD_NOT_CREATE_ID); + } return new BaseContainer(nextBaseContainerID++); } @@ -46,10 +58,15 @@ public class BaseContainer extends AbstractContainer { try { this.id = IDFactory.getDefault().createLongID(idl); } catch (IDCreateException e) { - throw new ContainerCreateException(e); + throw new ContainerCreateException(Messages.BaseContainer_EXCEPTION_COULD_NOT_CREATE_ID, e); } } + protected BaseContainer(ID id) { + Assert.isNotNull(id); + this.id = id; + } + /* * (non-Javadoc) * @@ -57,7 +74,7 @@ public class BaseContainer extends AbstractContainer { * org.eclipse.ecf.core.security.IConnectContext) */ public void connect(ID targetID, IConnectContext connectContext) throws ContainerConnectException { - throw new ContainerConnectException("connect not supported"); //$NON-NLS-1$ + throw new ContainerConnectException(Messages.BaseContainer_EXCEPTION_CONNECT_NOT_SUPPORT); } /* diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/BaseContainerInstantiator.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/BaseContainerInstantiator.java index c526ad096..7404fb0cb 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/BaseContainerInstantiator.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/provider/BaseContainerInstantiator.java @@ -15,6 +15,7 @@ import java.util.*; import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.ecf.core.*; import org.eclipse.ecf.internal.core.ECFPlugin; +import org.eclipse.ecf.internal.core.Messages; /** * @@ -59,7 +60,7 @@ public class BaseContainerInstantiator implements IContainerInstantiator { * @see org.eclipse.ecf.core.provider.IContainerInstantiator#createInstance(org.eclipse.ecf.core.ContainerTypeDescription, java.lang.Object[]) */ public IContainer createInstance(ContainerTypeDescription description, Object[] parameters) throws ContainerCreateException { - throw new ContainerCreateException(); + throw new ContainerCreateException(Messages.BaseContainerInstantiator_EXCEPTION_CREATEINSTANCE_NOT_SUPPORTED); } /* (non-Javadoc) diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/Messages.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/Messages.java index 8f1a9f7f9..e695c9fe8 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/Messages.java +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/Messages.java @@ -16,6 +16,9 @@ import org.eclipse.osgi.util.NLS; public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.core.messages"; //$NON-NLS-1$ public static String AbstractContainer_Exception_Callback_Handler; + public static String BaseContainer_EXCEPTION_CONNECT_NOT_SUPPORT; + public static String BaseContainer_EXCEPTION_COULD_NOT_CREATE_ID; + public static String BaseContainerInstantiator_EXCEPTION_CREATEINSTANCE_NOT_SUPPORTED; public static String BooleanCallback_EXCEPTION_INVALID_BOOLEAN_ARGUMENT; public static String ContainerFactory_Base_Container_Name; public static String ContainerFactory_Exception_Adapter_Not_Null; diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/messages.properties b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/messages.properties index 735fb543f..1cb7daed2 100644 --- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/messages.properties +++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/messages.properties @@ -20,4 +20,7 @@ ContainerTypeDescription_Instantiator_Class_Not_Null = ContainerTypeDescription< ContainerTypeDescription_Instantiator_Instance_Not_Null = ContainerTypeDescription<init> instantiator instance cannot be null AbstractContainer_Exception_Callback_Handler = Exception in CallbackHandler.handle(<callbacks>) ECFPlugin_Container_Name_Collision_Prefix = ECF container factory with name {0} already found. Ignoring registration for containerFactory extension point {1}. +BaseContainer_EXCEPTION_CONNECT_NOT_SUPPORT=Connect not supported +BaseContainer_EXCEPTION_COULD_NOT_CREATE_ID=Could not create ID for basecontainer +BaseContainerInstantiator_EXCEPTION_CREATEINSTANCE_NOT_SUPPORTED=createInstance not supported BooleanCallback_EXCEPTION_INVALID_BOOLEAN_ARGUMENT=Prompt cannot be null. |