Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-09-04 06:32:52 +0000
committerslewis2007-09-04 06:32:52 +0000
commitf32c63af75b4bc86a214e37fa39ec61d47a86093 (patch)
tree8aa04d3e5fda650ebbf17153b410c268dac1f847 /framework/bundles/org.eclipse.ecf.provider
parenta1ee6a0e7b26655ef322179cf7259285d0d11252 (diff)
downloadorg.eclipse.ecf-f32c63af75b4bc86a214e37fa39ec61d47a86093.tar.gz
org.eclipse.ecf-f32c63af75b4bc86a214e37fa39ec61d47a86093.tar.xz
org.eclipse.ecf-f32c63af75b4bc86a214e37fa39ec61d47a86093.zip
Removed ECF generic provider application classes (now in org.eclipse.ecf.server.generic) for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=202100
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.provider')
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF1
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/plugin.xml24
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java172
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/Connector.java93
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/GenericServer.java254
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/NamedGroup.java43
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java175
-rw-r--r--framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerConfigParser.java140
8 files changed, 0 insertions, 902 deletions
diff --git a/framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF
index f077e221d..9ebd70859 100644
--- a/framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF
+++ b/framework/bundles/org.eclipse.ecf.provider/META-INF/MANIFEST.MF
@@ -8,7 +8,6 @@ Bundle-Localization: plugin
Eclipse-LazyStart: true
Provide-Package: org.eclipse.ecf.provider.comm.tcp, org.eclipse.ecf.provider.app, org.eclipse.ecf.provider.generic, org.eclipse.ecf.provider.generic.gmm
Export-Package: org.eclipse.ecf.internal.provider;x-internal:=true,
- org.eclipse.ecf.provider.app,
org.eclipse.ecf.provider.comm,
org.eclipse.ecf.provider.comm.tcp,
org.eclipse.ecf.provider.generic,
diff --git a/framework/bundles/org.eclipse.ecf.provider/plugin.xml b/framework/bundles/org.eclipse.ecf.provider/plugin.xml
index 6e42e50f1..9663f57d6 100644
--- a/framework/bundles/org.eclipse.ecf.provider/plugin.xml
+++ b/framework/bundles/org.eclipse.ecf.provider/plugin.xml
@@ -19,28 +19,4 @@
name="ecf.generic.client">
</containerFactory>
</extension>
- <!-- Eclipse 3.3.0 has a bug that doesn't allow 'any' threads to run as main apps -->
- <extension
- id="AppGenericServer"
- point="org.eclipse.core.runtime.applications">
- <application
- cardinality="*"
- thread="main"
- visible="true">
- <run
- class="org.eclipse.ecf.provider.app.GenericServer"/>
- </application>
- </extension>
- <!-- Eclipse 3.3.1 may have a fix to allow this to run in either main/any thread -->
- <extension
- id="GenericServer"
- point="org.eclipse.core.runtime.applications">
- <application
- cardinality="*"
- thread="any"
- visible="true">
- <run
- class="org.eclipse.ecf.provider.app.GenericServer"/>
- </application>
- </extension>
</plugin>
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java
deleted file mode 100644
index 10b245d66..000000000
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ClientApplication.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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.provider.app;
-
-import java.util.HashMap;
-import java.util.Random;
-import org.eclipse.ecf.core.ContainerTypeDescription;
-import org.eclipse.ecf.core.ContainerFactory;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.IDFactory;
-import org.eclipse.ecf.core.sharedobject.ISharedObject;
-import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
-import org.eclipse.ecf.core.sharedobject.SharedObjectContainerFactory;
-import org.eclipse.ecf.provider.generic.GenericContainerInstantiator;
-import org.eclipse.ecf.provider.generic.TCPServerSOContainer;
-
-/**
- * An ECF client container implementation that runs as an application.
- * <p>
- * Usage: java org.eclipse.ecf.provider.app.ClientApplication &lt;serverid&gt
- * <p>
- * If &lt;serverid&gt; is omitted or "-" is specified,
- * ecftcp://localhost:3282/server" is used.
- *
- */
-public class ClientApplication {
-
- public static final int DEFAULT_WAITTIME = 40000;
-
- public static final int DEFAULT_TIMEOUT = TCPServerSOContainer.DEFAULT_KEEPALIVE;
-
- public static final String CONTAINER_FACTORY_NAME = GenericContainerInstantiator.class
- .getName();
- public static final String CONTAINER_FACTORY_CLASS = CONTAINER_FACTORY_NAME;
-
- public static final String COMPOSENT_CONTAINER_NAME = GenericContainerInstantiator.class
- .getName();
-
- // Number of clients to create
- static int clientCount = 1;
- // Array of client instances
- ISharedObjectContainer[] sm = new ISharedObjectContainer[clientCount];
- // ServerApplication name to connect to
- String serverName = null;
- // Class names of any sharedObjects to be created. If null, no sharedObjects
- // created.
- String[] sharedObjectClassNames = null;
- // IDs of sharedObjects created
- ID[] sharedObjects = null;
-
- static ContainerTypeDescription contd = null;
- static Random aRan = new Random();
-
- public ClientApplication() {
- super();
- }
-
- public void init(String[] args) throws Exception {
- serverName = TCPServerSOContainer.getDefaultServerURL();
- if (args.length > 0) {
- if (!args[0].equals("-"))serverName = args[0]; //$NON-NLS-1$
- }
- if (args.length > 1) {
- sharedObjectClassNames = new String[args.length - 1];
- for (int i = 0; i < args.length - 1; i++) {
- sharedObjectClassNames[i] = args[i + 1];
- }
- }
- // Setup factory descriptions since Eclipse does not do this for us
- contd = new ContainerTypeDescription(CONTAINER_FACTORY_NAME,
- CONTAINER_FACTORY_CLASS, null);
- ContainerFactory.getDefault().addDescription(contd);
- for (int i = 0; i < clientCount; i++) {
- sm[i] = createClient();
- }
- }
-
- protected ISharedObjectContainer createClient() throws Exception {
- // Make identity instance for the new container
- ID newContainerID = IDFactory.getDefault().createGUID();
- ISharedObjectContainer result = SharedObjectContainerFactory
- .getDefault().createSharedObjectContainer(
- contd,
- new Object[] { newContainerID,
- new Integer(DEFAULT_TIMEOUT) });
- return result;
- }
-
- public void connect(ID server) throws Exception {
- for (int i = 0; i < clientCount; i++) {
- System.out
- .print("ClientApplication " + sm[i].getID().getName() + " joining " + server.getName() + "..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- sm[i].connect(server, null);
- System.out.println("completed."); //$NON-NLS-1$
- }
- }
-
- public void disconnect() {
- for (int i = 0; i < clientCount; i++) {
- System.out
- .print("ClientApplication " + sm[i].getID().getName() + " leaving..."); //$NON-NLS-1$ //$NON-NLS-2$
- sm[i].disconnect();
- System.out.println("completed."); //$NON-NLS-1$
- }
- }
-
- public void createSharedObjects() throws Exception {
- if (sharedObjectClassNames != null) {
- for (int j = 0; j < clientCount; j++) {
- ISharedObjectContainer scg = sm[j];
- sharedObjects = new ID[sharedObjectClassNames.length];
- for (int i = 0; i < sharedObjectClassNames.length; i++) {
- System.out
- .println("Creating sharedObject: " + sharedObjectClassNames[i] + " for client " + scg.getID().getName()); //$NON-NLS-1$ //$NON-NLS-2$
- ISharedObject so = (ISharedObject) Class.forName(
- sharedObjectClassNames[i]).newInstance();
- sharedObjects[i] = IDFactory.getDefault().createStringID(
- sharedObjectClassNames[i] + "_" + i); //$NON-NLS-1$
- scg.getSharedObjectManager().addSharedObject(
- sharedObjects[i], so, new HashMap());
- System.out
- .println("Created sharedObject for client " + scg.getID().getName()); //$NON-NLS-1$
- }
- }
- }
-
- }
-
- public void removeSharedObjects() throws Exception {
- if (sharedObjects == null)
- return;
- for (int j = 0; j < clientCount; j++) {
- for (int i = 0; i < sharedObjects.length; i++) {
- System.out
- .println("Removing sharedObject: " + sharedObjects[i].getName() + " for client " + sm[j].getID().getName()); //$NON-NLS-1$ //$NON-NLS-2$
- sm[j].getSharedObjectManager().removeSharedObject(
- sharedObjects[i]);
- }
- }
- }
-
- /**
- * An ECF client container implementation that runs as an application.
- * <p>
- * Usage: java org.eclipse.ecf.provider.app.ClientApplication
- * &lt;serverid&gt
- * <p>
- * If &lt;serverid&gt; is omitted or "-" is specified,
- * ecftcp://localhost:3282/server" is used.
- *
- */
- public static void main(String[] args) throws Exception {
- ClientApplication st = new ClientApplication();
- st.init(args);
- // Get server id to join
- ID serverID = IDFactory.getDefault().createStringID(st.serverName);
- st.connect(serverID);
- st.createSharedObjects();
- System.out.println("Waiting " + DEFAULT_WAITTIME + " ms..."); //$NON-NLS-1$ //$NON-NLS-2$
- Thread.sleep(DEFAULT_WAITTIME);
- st.removeSharedObjects();
- st.disconnect();
- System.out.println("Exiting."); //$NON-NLS-1$
- }
-
-}
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/Connector.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/Connector.java
deleted file mode 100644
index 4151ecd75..000000000
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/Connector.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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.provider.app;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.ecf.provider.generic.TCPServerSOContainer;
-
-public class Connector {
- public static final int DEFAULT_PORT = TCPServerSOContainer.DEFAULT_PORT;
- public static final int DEFAULT_TIMEOUT = TCPServerSOContainer.DEFAULT_KEEPALIVE;
- public static final String DEFAULT_HOSTNAME = TCPServerSOContainer.DEFAULT_HOST;
- public static final String DEFAULT_SERVERNAME = TCPServerSOContainer.DEFAULT_NAME;
- public static final String DEFAULT_PROTOCOL = TCPServerSOContainer.DEFAULT_PROTOCOL;
-
- int port = DEFAULT_PORT;
- int timeout = DEFAULT_TIMEOUT;
- String protocol = DEFAULT_PROTOCOL;
- String hostname = DEFAULT_HOSTNAME;
- boolean discovery = false;
- List groups = new ArrayList();
-
- public Connector(String protocol, String host, int port, int timeout,
- boolean discovery) {
- if (protocol != null && !protocol.equals(""))this.protocol = protocol; //$NON-NLS-1$
- if (host != null && !host.equals(""))this.hostname = host; //$NON-NLS-1$
- else {
- try {
- InetAddress addr = InetAddress.getLocalHost();
- this.hostname = addr.getCanonicalHostName();
- } catch (Exception e) {
- this.hostname = "localhost"; //$NON-NLS-1$
- }
- }
- this.port = port;
- this.timeout = timeout;
- this.discovery = discovery;
- }
-
- public Connector(String protocol, String host, int port, int timeout) {
- this(protocol, host, port, timeout, false);
- }
-
- public boolean shouldRegisterForDiscovery() {
- return discovery;
- }
-
- public boolean addGroup(NamedGroup grp) {
- if (grp == null)
- return false;
- for (Iterator i = groups.iterator(); i.hasNext();) {
- NamedGroup namedGroup = (NamedGroup) i.next();
- if (namedGroup.getName().equals(grp.getName()))
- return false;
- }
- groups.add(grp);
- grp.setParent(this);
- return true;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public int getPort() {
- return port;
- }
-
- public int getTimeout() {
- return timeout;
- }
-
- public List getGroups() {
- return groups;
- }
-
- public String getID() {
- return getProtocol() + "://" + getHostname() + ":" + getPort(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/GenericServer.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/GenericServer.java
deleted file mode 100644
index a76eb7777..000000000
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/GenericServer.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/****************************************************************************
- * Copyright (c) 2007 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.provider.app;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.PermissionCollection;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-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.security.IConnectHandlerPolicy;
-import org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager;
-import org.eclipse.ecf.provider.generic.SOContainerConfig;
-import org.eclipse.ecf.provider.generic.TCPServerSOContainer;
-import org.eclipse.ecf.provider.generic.TCPServerSOContainerGroup;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
-
-/**
- * This class controls all aspects of the application's execution
- */
-public class GenericServer implements IApplication {
-
- private static Map serverGroups = new HashMap();
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
- */
- public Object start(IApplicationContext context) throws Exception {
- try {
- String[] args = mungeArguments((String[]) context.getArguments()
- .get("application.args")); //$NON-NLS-1$
- if (args.length == 1
- && (args[0].equals("-help") || args[0].equals("-h"))) { //$NON-NLS-1$ //$NON-NLS-2$
- usage();
- return IApplication.EXIT_OK;
- } else if (args.length == 2
- && (args[0].equals("-config") || args[0].equals("-c"))) { //$NON-NLS-1$ //$NON-NLS-2$
- // Setup from configuration file (expected after -c <file>
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(args[1]);
- setupServerFromConfig(new ServerConfigParser().load(fis));
- } finally {
- if (fis != null)
- fis.close();
- }
- } else {
- String hostname = TCPServerSOContainer.DEFAULT_HOST;
- int port = TCPServerSOContainer.DEFAULT_PORT;
- String name = TCPServerSOContainer.DEFAULT_NAME;
- int keepAlive = TCPServerSOContainer.DEFAULT_KEEPALIVE;
- switch (args.length) {
- case 4:
- keepAlive = Integer.parseInt(args[3]);
- case 3:
- hostname = args[2];
- case 2:
- name = args[1];
- if (!name.startsWith("/")) name = "/"+name;
- case 1:
- port = Integer.parseInt(args[0]);
- }
- setupServerFromParameters(hostname, port, name, keepAlive);
- }
- synchronized (this) {
- this.wait();
- }
- return IApplication.EXIT_OK;
- } catch (Exception e) {
- stop();
- throw e;
- }
- }
-
- private void usage() {
- System.out
- .println("Usage: eclipse.exe -application " //$NON-NLS-1$
- + this.getClass().getName()
- + "[port [groupname [hostname [keepAlive]]]] | [-config|-c <configfile.xml>]"); //$NON-NLS-1$
- System.out
- .println(" Examples: eclipse -application org.eclipse.ecf.provider.GenericServer"); //$NON-NLS-1$
- System.out
- .println(" eclipse -application org.eclipse.ecf.provider.GenericServer " + 7777); //$NON-NLS-1$
- System.out
- .println(" eclipse -application org.eclipse.ecf.provider.GenericServer " + 7777 //$NON-NLS-1$
- + " mygroup foobarhost.wherever.com 35000"); //$NON-NLS-1$
- System.out
- .println(" eclipse -application org.eclipse.ecf.provider.GenericServer -c myconfig.xml"); //$NON-NLS-1$
-
- }
-
- /**
- * @param hostname
- * @param port
- * @param name
- * @param keepAlive
- */
- protected void setupServerFromParameters(String hostname, int port,
- String name, int keepAlive) throws IOException, IDCreateException {
- String hostnamePort = hostname + ":" + port; //$NON-NLS-1$
- synchronized (serverGroups) {
- TCPServerSOContainerGroup serverGroup = (TCPServerSOContainerGroup) serverGroups
- .get(hostnamePort);
- if (serverGroup == null) {
- System.out
- .println("Putting server " + hostnamePort + " on the air..."); //$NON-NLS-1$ //$NON-NLS-2$
- serverGroup = new TCPServerSOContainerGroup(hostname, port);
- String url = TCPServerSOContainer.DEFAULT_PROTOCOL + "://" //$NON-NLS-1$
- + hostnamePort + name;
- // Create
- TCPServerSOContainer container = createServerContainer(url,
- serverGroup, name, keepAlive);
- // Configure
- configureServerContainer(container);
- // Put on the air
- serverGroup.putOnTheAir();
- serverGroups.put(hostnamePort, serverGroup);
- System.out
- .println("GenericServer " + hostnamePort + " on the air."); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- System.out.println("GenericServer " + hostnamePort //$NON-NLS-1$
- + " already on the air. No changes made."); //$NON-NLS-1$
- }
- }
-
- }
-
- /**
- * This method may be overridden by subclasses in order to customize the configuration of the
- * newly created server containers (before they are put on the air). For example, to set the appropriate
- * connect policy.
- *
- * @param container the container to configure
- */
- protected void configureServerContainer(TCPServerSOContainer container) {
- // Setup join policy
- ((ISharedObjectContainerGroupManager) container)
- .setConnectPolicy(new JoinListener());
-
- }
-
- protected void setupServerFromConfig(List connectors) throws IOException,
- IDCreateException {
- for (Iterator i = connectors.iterator(); i.hasNext();) {
- Connector connector = (Connector) i.next();
- String hostname = connector.getHostname();
- int port = connector.getPort();
- String hostnamePort = hostname + ":" + port; //$NON-NLS-1$
- TCPServerSOContainerGroup serverGroup = null;
- synchronized (serverGroups) {
- serverGroup = (TCPServerSOContainerGroup) serverGroups
- .get(hostnamePort);
- if (serverGroup == null) {
- System.out
- .println("Putting server " + hostnamePort + " on the air..."); //$NON-NLS-1$ //$NON-NLS-2$
- serverGroup = new TCPServerSOContainerGroup(hostname, port);
- List groups = connector.getGroups();
- for (Iterator g = groups.iterator(); g.hasNext();) {
- NamedGroup group = (NamedGroup) g.next();
- // Create
- TCPServerSOContainer container = createServerContainer(
- group.getIDForGroup(), serverGroup, group
- .getName(), connector.getTimeout());
- // Configure
- configureServerContainer(container);
- }
- serverGroup.putOnTheAir();
- serverGroups.put(hostnamePort, serverGroup);
- System.out.println("GenericServer " + hostnamePort //$NON-NLS-1$
- + " on the air."); //$NON-NLS-1$
- } else {
- System.out.println("GenericServer " + hostnamePort //$NON-NLS-1$
- + " already on the air. No changes made."); //$NON-NLS-1$
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.equinox.app.IApplication#stop()
- */
- public void stop() {
- synchronized (serverGroups) {
- for (Iterator i = serverGroups.keySet().iterator(); i.hasNext();) {
- TCPServerSOContainerGroup serverGroup = (TCPServerSOContainerGroup) serverGroups
- .get(i.next());
- serverGroup.takeOffTheAir();
- Iterator iter = serverGroup.elements();
- for (; iter.hasNext();) {
- TCPServerSOContainer container = (TCPServerSOContainer) iter
- .next();
- container.dispose();
- }
- }
- }
- synchronized (this) {
- this.notify();
- }
- }
-
- private String[] mungeArguments(String originalArgs[]) {
- if (originalArgs == null)
- return new String[0];
- 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[] {});
- }
-
- private static TCPServerSOContainer createServerContainer(String id,
- TCPServerSOContainerGroup group, String path, int keepAlive)
- throws IDCreateException {
- System.out
- .println(" Creating container with id=" + id + " keepAlive=" + keepAlive); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ID newServerID = IDFactory.getDefault().createStringID(id);
- SOContainerConfig config = new SOContainerConfig(newServerID);
- return new TCPServerSOContainer(config, group, path, keepAlive);
- }
-
- static class JoinListener implements IConnectHandlerPolicy {
- public PermissionCollection checkConnect(Object addr, ID fromID,
- ID targetID, String targetGroup, Object joinData)
- throws Exception {
- System.out
- .println("CLIENT CONNECT: fromAddress=" + addr + ";fromID=" + fromID + ";targetGroup=" + targetGroup); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return null;
- }
-
- public void refresh() {
- }
-
- }
-
-}
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/NamedGroup.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/NamedGroup.java
deleted file mode 100644
index aed1e9209..000000000
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/NamedGroup.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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.provider.app;
-
-public class NamedGroup {
- Connector parent;
- String name;
-
- public NamedGroup(String name) {
- this.name = name;
- }
-
- protected void setParent(Connector c) {
- this.parent = c;
- }
-
- public Connector getConnector() {
- return parent;
- }
-
- public String getRawName() {
- return name;
- }
-
- public String getName() {
- return cleanGroupName(name);
- }
-
- public String getIDForGroup() {
- return parent.getID() + getName();
- }
-
- protected String cleanGroupName(String n) {
- String res = ((n.startsWith("/")) ? n : "/" + n); //$NON-NLS-1$ //$NON-NLS-2$
- return res;
- }
-} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java
deleted file mode 100644
index 84961a7a4..000000000
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerApplication.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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.provider.app;
-
-import java.io.FileInputStream;
-import java.security.PermissionCollection;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-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.security.IConnectHandlerPolicy;
-import org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager;
-import org.eclipse.ecf.core.sharedobject.ISharedObjectManager;
-import org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription;
-import org.eclipse.ecf.core.sharedobject.security.ISharedObjectPolicy;
-import org.eclipse.ecf.provider.generic.SOContainerConfig;
-import org.eclipse.ecf.provider.generic.TCPServerSOContainer;
-import org.eclipse.ecf.provider.generic.TCPServerSOContainerGroup;
-
-/**
- * An ECF server container implementation that runs as an application.
- * <p>
- * Usage: java org.eclipse.ecf.provider.app.ServerApplication [-c
- * &lt;configfile&gt | &lt;serverid&gt]
- * <p>
- * If -p &lt;configfile&gt is used, the server configuration is loaded and used
- * to setup servers. If &lt;serverid&gt; is omitted or "-" is specified,
- * ecftcp://localhost:3282/server" is used. The &lt;serverid&gt; must correspond
- * to URI syntax as defined by <a href="http://www.ietf.org/rfc/rfc2396.txt"><i>RFC&nbsp;2396:
- * Uniform Resource Identifiers (URI): Generic Syntax</i></a>, amended by <a
- * href="http://www.ietf.org/rfc/rfc2732.txt"><i>RFC&nbsp;2732: Format for
- * Literal IPv6 Addresses in URLs</i></a>
- *
- */
-public class ServerApplication {
- public static final int DEFAULT_KEEPALIVE = TCPServerSOContainer.DEFAULT_KEEPALIVE;
- static TCPServerSOContainerGroup serverGroups[] = null;
- static List servers = new ArrayList();
-
- static class JoinListener implements IConnectHandlerPolicy {
- public PermissionCollection checkConnect(Object addr, ID fromID,
- ID targetID, String targetGroup, Object joinData)
- throws Exception {
- System.out
- .println("JOIN Addr=" + addr + ";From=" + fromID + ";Target Group=" + targetGroup + ";Data=" + joinData); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return null;
- }
-
- public void refresh() {
- System.out.println("connectHandlerPolicy.refresh()"); //$NON-NLS-1$
- }
-
- }
-
- static class SharedObjectAddListener implements ISharedObjectPolicy {
-
- public PermissionCollection checkAddSharedObject(ID fromID, ID toID,
- ID localID, ReplicaSharedObjectDescription newObject)
- throws SecurityException {
- System.out
- .println("CHECKADDSHAREDOBJECT From=" + fromID + ";To=" + toID + ";SharedObject=" + newObject); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return null;
- }
-
- public void refresh() {
- System.out.println("connectHandlerPolicy.refresh()"); //$NON-NLS-1$
- }
-
- }
-
- public static void main(String args[]) throws Exception {
- // Get server identity
- String serverName = null;
- List connectors = null;
- if (args.length > 0) {
- if (args[0].equals("-c")) { //$NON-NLS-1$
- ServerConfigParser parser = new ServerConfigParser();
- connectors = parser.load(new FileInputStream(args[1]));
- } else if (!args[0].equals("-")) //$NON-NLS-1$
- serverName = args[0];
- }
- if (connectors != null) {
- serverGroups = new TCPServerSOContainerGroup[connectors.size()];
- int j = 0;
- for (Iterator i = connectors.iterator(); i.hasNext();) {
- Connector connect = (Connector) i.next();
- serverGroups[j] = createServerGroup(connect.getHostname(),
- connect.getPort());
- List groups = connect.getGroups();
-
- for (Iterator g = groups.iterator(); g.hasNext();) {
- NamedGroup group = (NamedGroup) g.next();
- TCPServerSOContainer cont = createServerContainer(group
- .getIDForGroup(), serverGroups[j], group.getName(),
- connect.getTimeout());
- // Setup join policy
- ((ISharedObjectContainerGroupManager) cont)
- .setConnectPolicy(new JoinListener());
- servers.add(cont);
- }
- System.out
- .println("Putting server " + connect.getHostname() + " on the air"); //$NON-NLS-1$ //$NON-NLS-2$
- serverGroups[j].putOnTheAir();
- j++;
- System.out.println("<ctrl>-c to stop server"); //$NON-NLS-1$
- }
- } else {
- if (serverName == null) {
- serverName = TCPServerSOContainer.getDefaultServerURL();
- }
- 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());
- // Create identity for server
- ID id = IDFactory.getDefault().createStringID(serverName);
- // Create server config object with identity and default timeout
- SOContainerConfig config = new SOContainerConfig(id);
- // Make server instance
- System.out.print("Creating ECF server container..."); //$NON-NLS-1$
- TCPServerSOContainer server = new TCPServerSOContainer(config,
- serverGroups[0], name,
- TCPServerSOContainer.DEFAULT_KEEPALIVE);
- // Setup join policy
- ((ISharedObjectContainerGroupManager) server)
- .setConnectPolicy(new JoinListener());
- // Setup add shared object policy
- ISharedObjectManager manager = server.getSharedObjectManager();
- manager.setRemoteAddPolicy(new SharedObjectAddListener());
-
- serverGroups[0].putOnTheAir();
- servers.add(server);
- System.out.println("success!"); //$NON-NLS-1$
- System.out
- .println("Waiting for JOIN requests at '" + id.getName() + "'..."); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("<ctrl>-c to stop server"); //$NON-NLS-1$
- }
- }
-
- protected static TCPServerSOContainerGroup createServerGroup(String name,
- int port) {
- System.out
- .println("Creating server group named " + name + " to listen on port " + port); //$NON-NLS-1$ //$NON-NLS-2$
- TCPServerSOContainerGroup group = new TCPServerSOContainerGroup(name,
- port);
- return group;
- }
-
- protected static TCPServerSOContainer createServerContainer(String id,
- TCPServerSOContainerGroup group, String path, int keepAlive)
- throws IDCreateException {
- System.out
- .println(" Creating container with id=" + id + ", group=" + path + " keepAlive=" + keepAlive); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ID newServerID = IDFactory.getDefault().createStringID(id);
- SOContainerConfig config = new SOContainerConfig(newServerID);
- return new TCPServerSOContainer(config, group, path, keepAlive);
- }
-} \ No newline at end of file
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerConfigParser.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerConfigParser.java
deleted file mode 100644
index 96a6cea6e..000000000
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/app/ServerConfigParser.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 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.provider.app;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Entity;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-public class ServerConfigParser {
-
- public static final String SERVER_ELEMENT = "server"; //$NON-NLS-1$
- public static final String CONNECTOR_ELEMENT = "connector"; //$NON-NLS-1$
- public static final String GROUP_ELEMENT = "group"; //$NON-NLS-1$
-
- public static final String PROTOCOL_ATTR = "protocol"; //$NON-NLS-1$
- public static final String HOSTNAME_ATTR = "hostname"; //$NON-NLS-1$
- public static final String PORT_ATTR = "port"; //$NON-NLS-1$
- public static final String TIMEOUT_ATTR = "timeout"; //$NON-NLS-1$
- public static final String NAME_ATTR = "name"; //$NON-NLS-1$
-
- protected void findElementsNamed(Node top, String name, List aList) {
- int type = top.getNodeType();
- switch (type) {
- case Node.DOCUMENT_TYPE_NODE:
- // Print entities if any
- NamedNodeMap nodeMap = ((DocumentType) top).getEntities();
- for (int i = 0; i < nodeMap.getLength(); i++) {
- Entity entity = (Entity) nodeMap.item(i);
- findElementsNamed(entity, name, aList);
- }
- break;
- case Node.ELEMENT_NODE:
- String elementName = top.getNodeName();
- if (name.equals(elementName)) {
- aList.add(top);
- }
- default:
- for (Node child = top.getFirstChild(); child != null; child = child
- .getNextSibling()) {
- findElementsNamed(child, name, aList);
- }
- }
- }
-
- protected List processConnectorNodes(List connectorNodes) {
- List res = new ArrayList();
- for (Iterator i = connectorNodes.iterator(); i.hasNext();) {
- Node n = (Node) i.next();
- String ports = getAttributeValue(n, PORT_ATTR);
- int port = Connector.DEFAULT_PORT;
- if (ports != null) {
- try {
- Integer porti = new Integer(ports);
- port = porti.intValue();
- } catch (NumberFormatException e) {
- // ignore
- }
- }
- String timeouts = getAttributeValue(n, TIMEOUT_ATTR);
- int timeout = Connector.DEFAULT_TIMEOUT;
- if (timeouts != null) {
- try {
- Integer timeouti = new Integer(timeouts);
- timeout = timeouti.intValue();
- } catch (NumberFormatException e) {
- // ignore
- }
- }
- String prot = getAttributeValue(n, PROTOCOL_ATTR);
- String host = getAttributeValue(n, HOSTNAME_ATTR);
- Connector c = new Connector(prot, host, port, timeout);
- processConnector(n, c);
- res.add(c);
- }
- return res;
- }
-
- protected void processConnector(Node n, Connector c) {
- List groupList = new ArrayList();
- findElementsNamed(n, GROUP_ELEMENT, groupList);
- for (Iterator i = groupList.iterator(); i.hasNext();) {
- Node node = (Node) i.next();
- String name = getAttributeValue(node, NAME_ATTR);
- if (name != null && !name.equals("")) { //$NON-NLS-1$
- NamedGroup g = new NamedGroup(name);
- c.addGroup(g);
- g.setParent(c);
- }
- }
- }
-
- protected List loadConnectors(Document doc) {
- List ps = new ArrayList();
- findElementsNamed(doc, CONNECTOR_ELEMENT, ps);
- return processConnectorNodes(ps);
- }
-
- protected String getAttributeValue(Node node, String attrName) {
- NamedNodeMap attrs = node.getAttributes();
- Node attrNode = attrs.getNamedItem(attrName);
- if (attrNode != null) {
- return attrNode.getNodeValue();
- } else
- return ""; //$NON-NLS-1$
- }
-
- public List load(InputStream ins) throws ParserConfigurationException,
- SAXException, IOException {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse(ins);
- return loadConnectors(doc);
- }
-
- public static void main(String[] args) throws Exception {
- InputStream ins = new FileInputStream(args[0]);
- ServerConfigParser configParser = new ServerConfigParser();
- configParser.load(ins);
- }
-}

Back to the top