Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-01-13 22:45:57 +0000
committerslewis2008-01-13 22:45:57 +0000
commitdf7345ab9fceb725518ed2305511a8efc4c98356 (patch)
tree08a4171d84ebca1d1da4e0055e830bf862a88591 /examples/bundles
parent89fc0a1124f57558d39c9758eb3d514c554a6d39 (diff)
downloadorg.eclipse.ecf-df7345ab9fceb725518ed2305511a8efc4c98356.tar.gz
org.eclipse.ecf-df7345ab9fceb725518ed2305511a8efc4c98356.tar.xz
org.eclipse.ecf-df7345ab9fceb725518ed2305511a8efc4c98356.zip
String externalization in BaseContainer. Added to functionality of BaseContainerInstantiator and added test code.
Diffstat (limited to 'examples/bundles')
-rwxr-xr-xexamples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainer.java10
-rwxr-xr-xexamples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainerInstantiator.java12
2 files changed, 18 insertions, 4 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainer.java b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainer.java
index d5a295842..8888164ca 100755
--- a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainer.java
+++ b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainer.java
@@ -11,6 +11,7 @@
package org.eclipse.ecf.internal.examples.provider.trivial.container;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.AbstractContainer;
import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.events.ContainerConnectedEvent;
@@ -51,6 +52,12 @@ public class TrivialContainer extends AbstractContainer
this.containerID = IDFactory.getDefault().createGUID();
}
+ public TrivialContainer(ID id) {
+ super();
+ Assert.isNotNull(id);
+ this.containerID = id;
+ }
+
/*
* (non-Javadoc)
*
@@ -78,7 +85,7 @@ public class TrivialContainer extends AbstractContainer
public void disconnect() {
fireContainerEvent(new ContainerDisconnectingEvent(getID(), targetID));
- ID oldID = targetID;
+ final ID oldID = targetID;
// XXX disconnect here
@@ -117,7 +124,6 @@ public class TrivialContainer extends AbstractContainer
*
* @see org.eclipse.ecf.core.AbstractContainer#getAdapter(java.lang.Class)
*/
- @Override
public Object getAdapter(Class serviceType) {
/*
* See AbstractContainer.getAdapter() implementation.
diff --git a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainerInstantiator.java b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainerInstantiator.java
index 300f5b4e0..4096dec9d 100755
--- a/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainerInstantiator.java
+++ b/examples/bundles/org.eclipse.ecf.examples.provider.trivial/src/org/eclipse/ecf/internal/examples/provider/trivial/container/TrivialContainerInstantiator.java
@@ -14,7 +14,9 @@ package org.eclipse.ecf.internal.examples.provider.trivial.container;
import org.eclipse.ecf.core.ContainerCreateException;
import org.eclipse.ecf.core.ContainerTypeDescription;
import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.provider.BaseContainerInstantiator;
/**
@@ -28,9 +30,15 @@ public class TrivialContainerInstantiator extends BaseContainerInstantiator {
@Override
public IContainer createInstance(ContainerTypeDescription description, Object[] parameters) throws ContainerCreateException {
try {
+ if (parameters != null && parameters.length > 0) {
+ if (parameters[0] instanceof ID)
+ return new TrivialContainer((ID) parameters[0]);
+ if (parameters[0] instanceof String)
+ return new TrivialContainer(IDFactory.getDefault().createStringID((String) parameters[0]));
+ }
return new TrivialContainer();
- } catch (IDCreateException e) {
- throw new ContainerCreateException("Exception creating trivial container", e);
+ } catch (final IDCreateException e) {
+ throw new ContainerCreateException("Exception creating ID for trivial container", e);
}
}

Back to the top