diff options
author | slewis | 2010-02-16 06:21:37 +0000 |
---|---|---|
committer | slewis | 2010-02-16 06:21:37 +0000 |
commit | 1f5695107fa74292014b00e36488b3400ea4454c (patch) | |
tree | 5038c1a8f6015e3fac7f05c34d1aacd14385208a /server-side | |
parent | 3879b15d7e5e5ace46ff15a3ed15cb992d83ce05 (diff) | |
download | org.eclipse.ecf-1f5695107fa74292014b00e36488b3400ea4454c.tar.gz org.eclipse.ecf-1f5695107fa74292014b00e36488b3400ea4454c.tar.xz org.eclipse.ecf-1f5695107fa74292014b00e36488b3400ea4454c.zip |
Modified launch configs and generic server/client applications.
Diffstat (limited to 'server-side')
15 files changed, 553 insertions, 132 deletions
diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF b/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF index e6d88643b..1a047aceb 100644 --- a/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF +++ b/server-side/bundles/org.eclipse.ecf.server.generic/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %plugin.name Bundle-SymbolicName: org.eclipse.ecf.server.generic;singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 3.0.0.qualifier Bundle-Activator: org.eclipse.ecf.internal.server.generic.Activator Bundle-Vendor: %plugin.provider Bundle-Localization: plugin diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/build.properties b/server-side/bundles/org.eclipse.ecf.server.generic/build.properties index fff4c9ebe..8eb501a11 100644 --- a/server-side/bundles/org.eclipse.ecf.server.generic/build.properties +++ b/server-side/bundles/org.eclipse.ecf.server.generic/build.properties @@ -7,8 +7,10 @@ bin.includes = META-INF/,\ plugin.properties,\ schema/,\ server.xml,\ - launchconfigs/ + launchconfigs/,\ + products/ src.includes = about.html,\ schema/,\ server.xml,\ - launchconfigs/ + launchconfigs/,\ + products/ diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/ECF Server Application.launch b/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/ECF Server Application.launch deleted file mode 100644 index 0ad323d54..000000000 --- a/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/ECF Server Application.launch +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/ServerApplication.java"/> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="1"/> -</listAttribute> -<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ecf.server.generic.app.ServerApplication"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-c server.xml"/> -<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ecf.server.generic"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.ecf.core.internal.Trace=true -Dorg.eclipse.ecf.provider.Trace=true"/> -</launchConfiguration> diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/ECF Client Application.launch b/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/Generic Client Java App.launch index d9e1cd99a..0d3899612 100644 --- a/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/ECF Client Application.launch +++ b/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/Generic Client Java App.launch @@ -1,13 +1,11 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/ClientApplication.java"/> +<listEntry value="/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericClientJavaApplication.java"/> </listAttribute> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listEntry value="1"/> </listAttribute> -<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ecf.server.generic.app.ClientApplication"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ecf.server.generic.app.GenericClientJavaApplication"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ecf.server.generic"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.ecf.core.internal.Trace=true -Dorg.eclipse.ecf.provider.Trace=true"/> </launchConfiguration> diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/Generic Server Java App.launch b/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/Generic Server Java App.launch new file mode 100644 index 000000000..19f1d47e0 --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/launchconfigs/Generic Server Java App.launch @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication"> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericServerJavaApplication.java"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ecf.server.generic.app.GenericServerJavaApplication"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ecf.server.generic"/> +</launchConfiguration> diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml b/server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml index 147b20e96..6233371ca 100644 --- a/server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml +++ b/server-side/bundles/org.eclipse.ecf.server.generic/plugin.xml @@ -12,44 +12,27 @@ </factory> </extension> -<!-- Example use of org.eclipse.ecf.server.generic.configuration extension point <extension - point="org.eclipse.ecf.server.generic.configuration"> - <connector - discovery="true" - hostname="localhost" - keepAlive="30000" - port="3283"> - <group - name="server"> - </group> - </connector> - </extension> ---> - - <!-- Eclipse 3.3.0 has a bug that doesn't allow 'any' threads to run as main apps --> -<!-- <extension - id="org.eclipse.ecf.provider.AppGenericServer" + id="Server" point="org.eclipse.core.runtime.applications"> <application cardinality="*" - thread="main" + thread="any" visible="true"> <run - class="org.eclipse.ecf.server.generic.app.GenericServer"/> + class="org.eclipse.ecf.server.generic.app.GenericServerApplication"/> </application> </extension> - --> - <!-- Eclipse 3.3.1 may have a fix to allow this to run in either main/any thread --> + <extension - id="Server" + id="Client" point="org.eclipse.core.runtime.applications"> <application cardinality="*" thread="any" visible="true"> <run - class="org.eclipse.ecf.server.generic.app.GenericServer"/> + class="org.eclipse.ecf.server.generic.app.GenericClientApplication"/> </application> </extension> diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/products/ECF Generic Server.product b/server-side/bundles/org.eclipse.ecf.server.generic/products/ECF Generic Server.product deleted file mode 100644 index 281684b2c..000000000 --- a/server-side/bundles/org.eclipse.ecf.server.generic/products/ECF Generic Server.product +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?pde version="3.5"?> - -<product name="ECF Generic Server" uid="org.eclipse.ecf.server.generic.Server" application="org.eclipse.ecf.server.generic.Server" version="1.0.0" useFeatures="false" includeLaunchers="false"> - - <configIni use="default"> - </configIni> - - <launcherArgs> - <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> - </launcherArgs> - - <launcher name="genericserver"> - <solaris/> - <win useIco="false"> - <bmp/> - </win> - </launcher> - - <vm> - </vm> - - - <plugins> - <plugin id="ch.ethz.iks.r_osgi.remote"/> - <plugin id="ch.ethz.iks.slp"/> - <plugin id="com.jcraft.jsch"/> - <plugin id="org.apache.commons.codec"/> - <plugin id="org.apache.commons.httpclient"/> - <plugin id="org.apache.commons.logging"/> - <plugin id="org.eclipse.core.contenttype"/> - <plugin id="org.eclipse.core.jobs"/> - <plugin id="org.eclipse.core.runtime"/> - <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/> - <plugin id="org.eclipse.ecf"/> - <plugin id="org.eclipse.ecf.datashare"/> - <plugin id="org.eclipse.ecf.discovery"/> - <plugin id="org.eclipse.ecf.filetransfer"/> - <plugin id="org.eclipse.ecf.identity"/> - <plugin id="org.eclipse.ecf.osgi.services"/> - <plugin id="org.eclipse.ecf.osgi.services.discovery"/> - <plugin id="org.eclipse.ecf.osgi.services.distribution"/> - <plugin id="org.eclipse.ecf.presence"/> - <plugin id="org.eclipse.ecf.presence.bot"/> - <plugin id="org.eclipse.ecf.protocol.bittorrent"/> - <plugin id="org.eclipse.ecf.protocol.msn"/> - <plugin id="org.eclipse.ecf.provider"/> - <plugin id="org.eclipse.ecf.provider.bittorrent"/> - <plugin id="org.eclipse.ecf.provider.datashare"/> - <plugin id="org.eclipse.ecf.provider.discovery"/> - <plugin id="org.eclipse.ecf.provider.filetransfer"/> - <plugin id="org.eclipse.ecf.provider.filetransfer.httpclient"/> - <plugin id="org.eclipse.ecf.provider.filetransfer.httpclient.ssl" fragment="true"/> - <plugin id="org.eclipse.ecf.provider.filetransfer.scp"/> - <plugin id="org.eclipse.ecf.provider.filetransfer.ssl" fragment="true"/> - <plugin id="org.eclipse.ecf.provider.irc"/> - <plugin id="org.eclipse.ecf.provider.irc.bot"/> - <plugin id="org.eclipse.ecf.provider.jmdns"/> - <plugin id="org.eclipse.ecf.provider.jslp"/> - <plugin id="org.eclipse.ecf.provider.msn"/> - <plugin id="org.eclipse.ecf.provider.remoteservice"/> - <plugin id="org.eclipse.ecf.remoteservice"/> - <plugin id="org.eclipse.ecf.server.generic"/> - <plugin id="org.eclipse.ecf.sharedobject"/> - <plugin id="org.eclipse.ecf.ssl" fragment="true"/> - <plugin id="org.eclipse.ecf.storage"/> - <plugin id="org.eclipse.ecf.tests.protocol.msn" fragment="true"/> - <plugin id="org.eclipse.equinox.app"/> - <plugin id="org.eclipse.equinox.common"/> - <plugin id="org.eclipse.equinox.concurrent"/> - <plugin id="org.eclipse.equinox.preferences"/> - <plugin id="org.eclipse.equinox.registry"/> - <plugin id="org.eclipse.equinox.security"/> - <plugin id="org.eclipse.osgi"/> - <plugin id="org.eclipse.osgi.services"/> - <plugin id="org.junit"/> - <plugin id="org.objectweb.asm"/> - </plugins> - - <configurations> - <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" /> - <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" /> - <plugin id="org.eclipse.osgi" autoStart="true" startLevel="-1" /> - </configurations> - -</product> diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/products/Generic Client Equinox App.product b/server-side/bundles/org.eclipse.ecf.server.generic/products/Generic Client Equinox App.product new file mode 100644 index 000000000..38aa0ce23 --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/products/Generic Client Equinox App.product @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product name="ECF Generic Client" uid="org.eclipse.ecf.server.generic.Client" application="org.eclipse.ecf.server.generic.Client" version="2.0.0" useFeatures="false" includeLaunchers="false"> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <programArgs>-console -consoleLog</programArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + + <launcher name="genericserver"> + <solaris/> + <win useIco="false"> + <bmp/> + </win> + </launcher> + + <vm> + </vm> + + <plugins> + <plugin id="org.eclipse.core.contenttype"/> + <plugin id="org.eclipse.core.jobs"/> + <plugin id="org.eclipse.core.runtime"/> + <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/> + <plugin id="org.eclipse.ecf"/> + <plugin id="org.eclipse.ecf.discovery"/> + <plugin id="org.eclipse.ecf.identity"/> + <plugin id="org.eclipse.ecf.provider"/> + <plugin id="org.eclipse.ecf.provider.remoteservice"/> + <plugin id="org.eclipse.ecf.remoteservice"/> + <plugin id="org.eclipse.ecf.server.generic"/> + <plugin id="org.eclipse.ecf.sharedobject"/> + <plugin id="org.eclipse.ecf.ssl" fragment="true"/> + <plugin id="org.eclipse.equinox.app"/> + <plugin id="org.eclipse.equinox.common"/> + <plugin id="org.eclipse.equinox.concurrent"/> + <plugin id="org.eclipse.equinox.preferences"/> + <plugin id="org.eclipse.equinox.registry"/> + <plugin id="org.eclipse.osgi"/> + <plugin id="org.eclipse.osgi.services"/> + </plugins> + + +</product> diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/products/Generic Server Equinox App.product b/server-side/bundles/org.eclipse.ecf.server.generic/products/Generic Server Equinox App.product new file mode 100644 index 000000000..55722bff5 --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/products/Generic Server Equinox App.product @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product name="Generic Server" uid="org.eclipse.ecf.server.generic.Server" application="org.eclipse.ecf.server.generic.Server" version="2.0.0" useFeatures="false" includeLaunchers="false"> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <programArgs>-console -consoleLog</programArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + + <launcher name="genericserver"> + <solaris/> + <win useIco="false"> + <bmp/> + </win> + </launcher> + + <vm> + </vm> + + <plugins> + <plugin id="org.eclipse.core.contenttype"/> + <plugin id="org.eclipse.core.jobs"/> + <plugin id="org.eclipse.core.runtime"/> + <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/> + <plugin id="org.eclipse.ecf"/> + <plugin id="org.eclipse.ecf.discovery"/> + <plugin id="org.eclipse.ecf.identity"/> + <plugin id="org.eclipse.ecf.provider"/> + <plugin id="org.eclipse.ecf.provider.remoteservice"/> + <plugin id="org.eclipse.ecf.remoteservice"/> + <plugin id="org.eclipse.ecf.server.generic"/> + <plugin id="org.eclipse.ecf.sharedobject"/> + <plugin id="org.eclipse.ecf.ssl" fragment="true"/> + <plugin id="org.eclipse.equinox.app"/> + <plugin id="org.eclipse.equinox.common"/> + <plugin id="org.eclipse.equinox.concurrent"/> + <plugin id="org.eclipse.equinox.preferences"/> + <plugin id="org.eclipse.equinox.registry"/> + <plugin id="org.eclipse.osgi"/> + <plugin id="org.eclipse.osgi.services"/> + </plugins> + + +</product> diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractGenericClientApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractGenericClientApplication.java new file mode 100644 index 000000000..9bb89ecf9 --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractGenericClientApplication.java @@ -0,0 +1,57 @@ +/******************************************************************************* +* Copyright (c) 2009 Composent, Inc. and others. All rights reserved. This +* program and the accompanying materials are made available under the terms of +* the Eclipse Public License v1.0 which accompanies this distribution, and is +* available at http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Composent, Inc. - initial API and implementation +******************************************************************************/ +package org.eclipse.ecf.server.generic.app; + +import org.eclipse.ecf.core.ContainerConnectException; +import org.eclipse.ecf.core.ContainerCreateException; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer; +import org.eclipse.ecf.provider.generic.TCPServerSOContainer; + +/** + * @since 3.0 + */ +public abstract class AbstractGenericClientApplication { + + protected String connectTarget; + protected ISharedObjectContainer clientContainer; + protected int waitTime = 40000; + + protected abstract ISharedObjectContainer createContainer() throws ContainerCreateException; + + protected void processArguments(String[] args) { + connectTarget = TCPServerSOContainer.getDefaultServerURL(); + for (int i = 0; i < args.length; i++) { + if (args[i].equals("-connectTarget")) { //$NON-NLS-1$ + connectTarget = args[i + 1]; + i++; + } + if (args[i].equals("-waitTime")) { //$NON-NLS-1$ + waitTime = new Integer(args[i + 1]).intValue(); + i++; + } + } + } + + protected void initialize() throws ContainerCreateException { + clientContainer = createContainer(); + } + + protected void connect() throws ContainerConnectException { + clientContainer.connect(IDFactory.getDefault().createStringID(connectTarget), null); + } + + protected void dispose() { + if (clientContainer != null) { + clientContainer.dispose(); + clientContainer = null; + } + } +} diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractGenericServerApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractGenericServerApplication.java new file mode 100644 index 000000000..e55cdfa3d --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/AbstractGenericServerApplication.java @@ -0,0 +1,151 @@ +/******************************************************************************* +* Copyright (c) 2009 Composent, Inc. and others. All rights reserved. This +* program and the accompanying materials are made available under the terms of +* the Eclipse Public License v1.0 which accompanies this distribution, and is +* available at http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Composent, Inc. - initial API and implementation +******************************************************************************/ +package org.eclipse.ecf.server.generic.app; + +import java.io.*; +import java.net.*; +import java.security.PermissionCollection; +import java.util.Iterator; +import java.util.List; +import org.eclipse.ecf.core.IContainerListener; +import org.eclipse.ecf.core.events.*; +import org.eclipse.ecf.core.identity.*; +import org.eclipse.ecf.core.security.IConnectHandlerPolicy; +import org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager; +import org.eclipse.ecf.provider.generic.*; + +/** + * @since 3.0 + */ +public abstract class AbstractGenericServerApplication { + + protected TCPServerSOContainerGroup[] serverGroups; + + protected String configURL; + protected String serverName; + + static class SysOutConnectHandlerPolicy implements IConnectHandlerPolicy { + public PermissionCollection checkConnect(Object addr, ID fromID, ID targetID, String targetGroup, Object joinData) throws Exception { + System.out.println("Client Connect Addr=" + addr + ";ID=" + fromID + ";Group=" + targetGroup); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return null; + } + + public void refresh() { + // do nothing + } + } + + static class ContainerListener implements IContainerListener { + public void handleEvent(IContainerEvent event) { + if (event instanceof IContainerDisconnectedEvent) { + System.out.println("Client id=" + ((IContainerDisconnectedEvent) event).getTargetID() + " disconnected."); //$NON-NLS-1$ //$NON-NLS-2$ + } else if (event instanceof IContainerEjectedEvent) { + System.out.println("Client id=" + ((IContainerEjectedEvent) event).getTargetID() + " ejected."); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + } + + protected void processArguments(String[] args) { + configURL = null; + serverName = TCPServerSOContainer.getDefaultServerURL(); + for (int i = 0; i < args.length; i++) { + if (args[i].equals("-configURL")) { //$NON-NLS-1$ + configURL = args[i + 1]; + i++; + } else if (args[i].equals("-serverName")) { //$NON-NLS-1$ + serverName = args[i + 1]; + i++; + } + } + } + + protected void initialize() throws Exception { + List connectors = null; + if (configURL != null) { + InputStream ins = null; + try { + try { + ins = new URL(configURL).openStream(); + } catch (MalformedURLException e) { + // If it's not an URL, just try to load via file + ins = new FileInputStream(configURL); + } + // read connectors from input stream via ServerConfigParser + connectors = new ServerConfigParser().load(ins); + } finally { + if (ins != null) + ins.close(); + } + initializeFromConnectors(connectors); + } else + initializeSingleServer(); + } + + protected void initializeSingleServer() throws IOException, URISyntaxException { + java.net.URI anURL = new java.net.URI(serverName); + int port = anURL.getPort(); + if (port == -1) + port = TCPServerSOContainer.DEFAULT_PORT; + String name = anURL.getPath(); + if (name == null) + name = TCPServerSOContainer.DEFAULT_NAME; + serverGroups = new TCPServerSOContainerGroup[1]; + // Setup server group + serverGroups[0] = new TCPServerSOContainerGroup(anURL.getPort()); + TCPServerSOContainer server = createServerContainer(serverName, serverGroups[0], name, TCPServerSOContainer.DEFAULT_KEEPALIVE); + + setupServerContainer(server); + // Then put the new server on the air + serverGroups[0].putOnTheAir(); + } + + protected void initializeFromConnectors(List connectors) throws IOException { + if (connectors == null) + return; + serverGroups = new TCPServerSOContainerGroup[connectors.size()]; + int j = 0; + for (Iterator i = connectors.iterator(); i.hasNext();) { + Connector connector = (Connector) i.next(); + serverGroups[j] = new TCPServerSOContainerGroup(connector.getHostname(), connector.getPort()); + List groups = connector.getGroups(); + for (Iterator g = groups.iterator(); g.hasNext();) { + NamedGroup group = (NamedGroup) g.next(); + TCPServerSOContainer container = createServerContainer(group.getIDForGroup(), serverGroups[j], group.getName(), connector.getTimeout()); + setupServerContainer(container); + } + serverGroups[j].putOnTheAir(); + j++; + } + } + + protected TCPServerSOContainer createServerContainer(String id, TCPServerSOContainerGroup group, String path, int keepAlive) throws IDCreateException { + return new TCPServerSOContainer(new SOContainerConfig(IDFactory.getDefault().createStringID(id)), group, path, keepAlive); + } + + protected void setupServerContainer(TCPServerSOContainer container) { + // Setup connect policy + ((ISharedObjectContainerGroupManager) container).setConnectPolicy(new SysOutConnectHandlerPolicy()); + // Setup container listener + container.addListener(new ContainerListener()); + } + + protected void shutdown() { + if (serverGroups != null) { + for (int i = 0; i < serverGroups.length; i++) { + serverGroups[i].takeOffTheAir(); + final Iterator iter = serverGroups[i].elements(); + for (; iter.hasNext();) { + ((TCPServerSOContainer) iter.next()).dispose(); + } + } + serverGroups = null; + } + } +} diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericClientApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericClientApplication.java new file mode 100644 index 000000000..f51b6d392 --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericClientApplication.java @@ -0,0 +1,77 @@ +/******************************************************************************* +* Copyright (c) 2009 Composent, Inc. and others. All rights reserved. This +* program and the accompanying materials are made available under the terms of +* the Eclipse Public License v1.0 which accompanies this distribution, and is +* available at http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Composent, Inc. - initial API and implementation +******************************************************************************/ +package org.eclipse.ecf.server.generic.app; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.ecf.core.ContainerCreateException; +import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer; +import org.eclipse.ecf.internal.server.generic.Activator; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; + +/** + * @since 3.0 + */ +public class GenericClientApplication extends AbstractGenericClientApplication implements IApplication { + + protected final Object appLock = new Object(); + protected boolean done = false; + + public Object start(IApplicationContext context) throws Exception { + String[] args = getArguments(context); + processArguments(args); + + initialize(); + + connect(); + + waitForDone(); + + return IApplication.EXIT_OK; + } + + public void stop() { + dispose(); + synchronized (appLock) { + done = true; + appLock.notifyAll(); + } + } + + protected ISharedObjectContainer createContainer() throws ContainerCreateException { + return (ISharedObjectContainer) Activator.getDefault().getContainerManager().getContainerFactory().createContainer("ecf.generic.client"); //$NON-NLS-1$ + } + + protected void waitForDone() { + // then just wait here + synchronized (appLock) { + while (!done) { + try { + appLock.wait(); + } catch (InterruptedException e) { + // do nothing + } + } + } + } + + protected String[] getArguments(IApplicationContext context) { + String[] originalArgs = (String[]) context.getArguments().get("application.args"); //$NON-NLS-1$ + if (originalArgs == null) + return new String[0]; + final List l = new ArrayList(); + for (int i = 0; i < originalArgs.length; i++) + if (!originalArgs[i].equals("-pdelaunch")) //$NON-NLS-1$ + l.add(originalArgs[i]); + return (String[]) l.toArray(new String[] {}); + } + +} diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericClientJavaApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericClientJavaApplication.java new file mode 100644 index 000000000..9080a720c --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericClientJavaApplication.java @@ -0,0 +1,43 @@ +/******************************************************************************* +* Copyright (c) 2009 Composent, Inc. and others. All rights reserved. This +* program and the accompanying materials are made available under the terms of +* the Eclipse Public License v1.0 which accompanies this distribution, and is +* available at http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Composent, Inc. - initial API and implementation +******************************************************************************/ +package org.eclipse.ecf.server.generic.app; + +import org.eclipse.ecf.core.*; +import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer; +import org.eclipse.ecf.provider.generic.GenericContainerInstantiator; + +/** + * @since 3.0 + */ +public class GenericClientJavaApplication extends AbstractGenericClientApplication { + + protected ISharedObjectContainer createContainer() throws ContainerCreateException { + IContainerFactory containerFactory = ContainerFactory.getDefault(); + containerFactory.addDescription(new ContainerTypeDescription("ecf.generic.client", new GenericContainerInstantiator(), null)); //$NON-NLS-1$ + return (ISharedObjectContainer) containerFactory.createContainer("ecf.generic.client"); //$NON-NLS-1$ + } + + public static void main(String[] args) throws Exception { + GenericClientJavaApplication app = new GenericClientJavaApplication(); + app.processArguments(args); + app.initialize(); + app.connect(); + // wait for waitTime + try { + synchronized (app) { + app.wait(app.waitTime); + } + } catch (InterruptedException e) { + // nothing + } + app.dispose(); + } + +} diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericServerApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericServerApplication.java new file mode 100644 index 000000000..d93b6ac02 --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericServerApplication.java @@ -0,0 +1,73 @@ +/******************************************************************************* +* Copyright (c) 2009 Composent, Inc. and others. All rights reserved. This +* program and the accompanying materials are made available under the terms of +* the Eclipse Public License v1.0 which accompanies this distribution, and is +* available at http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Composent, Inc. - initial API and implementation +******************************************************************************/ +package org.eclipse.ecf.server.generic.app; + +import java.util.ArrayList; +import java.util.List; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; + +/** + * @since 3.0 + */ +public class GenericServerApplication extends AbstractGenericServerApplication implements IApplication { + + protected final Object appLock = new Object(); + protected boolean done = false; + + public Object start(IApplicationContext context) throws Exception { + String[] args = getArguments(context); + processArguments(args); + + initialize(); + + if (configURL != null) + System.out.println("Generic server started with config from " + configURL); //$NON-NLS-1$ + else + System.out.println("Generic server started with id=" + serverName); //$NON-NLS-1$ + + waitForDone(); + + return IApplication.EXIT_OK; + } + + public void stop() { + shutdown(); + synchronized (appLock) { + done = true; + appLock.notifyAll(); + } + } + + protected void waitForDone() { + // then just wait here + synchronized (appLock) { + while (!done) { + try { + appLock.wait(); + } catch (InterruptedException e) { + // do nothing + } + } + } + } + + protected String[] getArguments(IApplicationContext context) { + String[] originalArgs = (String[]) context.getArguments().get("application.args"); //$NON-NLS-1$ + if (originalArgs == null) + return new String[0]; + final List l = new ArrayList(); + for (int i = 0; i < originalArgs.length; i++) + if (!originalArgs[i].equals("-pdelaunch")) //$NON-NLS-1$ + l.add(originalArgs[i]); + return (String[]) l.toArray(new String[] {}); + } + +} diff --git a/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericServerJavaApplication.java b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericServerJavaApplication.java new file mode 100644 index 000000000..e62411521 --- /dev/null +++ b/server-side/bundles/org.eclipse.ecf.server.generic/src/org/eclipse/ecf/server/generic/app/GenericServerJavaApplication.java @@ -0,0 +1,31 @@ +/******************************************************************************* +* Copyright (c) 2009 Composent, Inc. and others. All rights reserved. This +* program and the accompanying materials are made available under the terms of +* the Eclipse Public License v1.0 which accompanies this distribution, and is +* available at http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Composent, Inc. - initial API and implementation +******************************************************************************/ +package org.eclipse.ecf.server.generic.app; + +/** + * @since 3.0 + */ +public class GenericServerJavaApplication extends AbstractGenericServerApplication { + + /** + * @param args + */ + public static void main(String[] args) throws Exception { + GenericServerJavaApplication app = new GenericServerJavaApplication(); + app.processArguments(args); + app.initialize(); + if (app.configURL != null) + System.out.println("Generic server started with config from " + app.configURL); //$NON-NLS-1$ + else + System.out.println("Generic server started with id=" + app.serverName); //$NON-NLS-1$ + System.out.println("Ctrl-c to exit"); //$NON-NLS-1$ + } + +} |