diff options
author | slewis | 2009-03-22 20:09:52 +0000 |
---|---|---|
committer | slewis | 2009-03-22 20:09:52 +0000 |
commit | 450eb9c31e76459f9f6259ade247a058558073ce (patch) | |
tree | 906c5450a90dd2edfaa849ff7b116dbe40f6ea02 /doc | |
parent | 47c65109a7b768c04508c95622932620e06d22b5 (diff) | |
download | org.eclipse.ecf-450eb9c31e76459f9f6259ade247a058558073ce.tar.gz org.eclipse.ecf-450eb9c31e76459f9f6259ade247a058558073ce.tar.xz org.eclipse.ecf-450eb9c31e76459f9f6259ade247a058558073ce.zip |
lab1 additions/fixes
Diffstat (limited to 'doc')
-rw-r--r-- | doc/tutorials/EclipseCON 2009/bundles/org.eclipse.ecf.tutorial.lab1/src/org/eclipse/ecf/tutorial/lab1/actions/Lab1Action.java | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/doc/tutorials/EclipseCON 2009/bundles/org.eclipse.ecf.tutorial.lab1/src/org/eclipse/ecf/tutorial/lab1/actions/Lab1Action.java b/doc/tutorials/EclipseCON 2009/bundles/org.eclipse.ecf.tutorial.lab1/src/org/eclipse/ecf/tutorial/lab1/actions/Lab1Action.java index 5feddf16e..b5b2cc892 100644 --- a/doc/tutorials/EclipseCON 2009/bundles/org.eclipse.ecf.tutorial.lab1/src/org/eclipse/ecf/tutorial/lab1/actions/Lab1Action.java +++ b/doc/tutorials/EclipseCON 2009/bundles/org.eclipse.ecf.tutorial.lab1/src/org/eclipse/ecf/tutorial/lab1/actions/Lab1Action.java @@ -1,13 +1,9 @@ package org.eclipse.ecf.tutorial.lab1.actions; -import org.eclipse.ecf.core.ContainerConnectException; import org.eclipse.ecf.core.ContainerCreateException; import org.eclipse.ecf.core.IContainer; -import org.eclipse.ecf.core.IContainerFactory; 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.util.ECFException; import org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo; import org.eclipse.ecf.remoteservice.IRemoteService; import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter; @@ -18,7 +14,6 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.osgi.framework.InvalidSyntaxException; /** * Our sample action implements workbench action delegate. @@ -31,8 +26,11 @@ import org.osgi.framework.InvalidSyntaxException; public class Lab1Action implements IWorkbenchWindowActionDelegate { private IWorkbenchWindow window; - public static final String R_OSGI_TYPE = "ecf.r_osgi.peer"; - public static final String GENERIC_TYPE = "ecf.generic.client"; + private static final String CONTAINER_TYPE = System.getProperty("ecf.type","ecf.r_osgi.peer"); + private static final String TARGET = System.getProperty("ecf.target","r-osgi://localhost:9278"); + + private IContainer container; + private IRemoteServiceContainerAdapter adapter; /** * The constructor. @@ -40,17 +38,25 @@ public class Lab1Action implements IWorkbenchWindowActionDelegate { public Lab1Action() { } - protected IContainer createContainer(String type) throws ContainerCreateException { - return Activator.getDefault().getContainerFactory().createContainer(type); + protected ID createTargetID(IContainer container, String target) { + return IDFactory.getDefault().createID(container.getConnectNamespace(),target); } - protected IRemoteServiceContainerAdapter getRemoteServiceContainerAdapter(IContainer container) { - return (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class); + private IContainer getContainer() throws ContainerCreateException { + if (container == null) { + container = Activator.getDefault().getContainerFactory().createContainer(CONTAINER_TYPE); + } + return container; } - - protected ID createTargetID(IContainer container, String target) { - return IDFactory.getDefault().createID(container.getConnectNamespace(),target); + + private IRemoteServiceContainerAdapter getContainerAdapter() throws ContainerCreateException { + if (adapter == null) { + IContainer c = getContainer(); + adapter = (IRemoteServiceContainerAdapter) c.getAdapter(IRemoteServiceContainerAdapter.class); + } + return adapter; } + /** * The action has been activated. The argument of the * method represents the 'real' action sitting @@ -59,11 +65,9 @@ public class Lab1Action implements IWorkbenchWindowActionDelegate { */ public void run(IAction action) { try { - - IContainer container = createContainer(R_OSGI_TYPE); - IRemoteServiceContainerAdapter adapter = getRemoteServiceContainerAdapter(container); + IRemoteServiceContainerAdapter adapter = getContainerAdapter(); // Create target ID - String target = "r-osgi://localhost:9278"; + String target = TARGET; ID targetID = createTargetID(container,target); // Get and resolve remote service reference IRemoteServiceReference[] ref = adapter.getRemoteServiceReferences(targetID, org.eclipse.ecf.examples.remoteservices.common.IRemoteEnvironmentInfo.class.getName(), null); |