Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server')
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ConnectionEstablisher.java518
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/IServerLogger.java54
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ISystemService.java41
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SecuredThread.java173
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/Server.java183
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLauncher.java686
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLogger.java227
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerReceiver.java122
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SystemServiceManager.java70
9 files changed, 0 insertions, 2074 deletions
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ConnectionEstablisher.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ConnectionEstablisher.java
deleted file mode 100644
index 16641e356..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ConnectionEstablisher.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) [220123][dstore] Configurable timeout on irresponsiveness
- * David McKnight (IBM) [220892][dstore] Backward compatibility: Server and Daemon should support old clients
- * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
- * David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
- * Jacob Garcowski (IBM) [225175] [dstore] error handling change for Client
- * David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types
- * Noriaki Takatsu (IBM) - [226074] process for getStatus() API
- * Noriaki Takatsu (IBM) - [226237] [dstore] Move the place where the ServerLogger instance is made
- * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed
- * Noriaki Takatsu (IBM) - [242968] [multithread] serverSocket must be closed when an exception happens in Accept
- * Noriaki Takatsu (IBM) - [283656] [dstore][multithread] Serviceability issue
- *******************************************************************************/
-
-package org.eclipse.dstore.core.server;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.BindException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-
-import org.eclipse.dstore.core.model.Client;
-import org.eclipse.dstore.core.model.DE;
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.core.model.DataStore;
-import org.eclipse.dstore.core.model.DataStoreAttributes;
-import org.eclipse.dstore.core.model.ISSLProperties;
-import org.eclipse.dstore.internal.core.server.ServerAttributes;
-import org.eclipse.dstore.internal.core.server.ServerCommandHandler;
-import org.eclipse.dstore.internal.core.server.ServerReturnCodes;
-import org.eclipse.dstore.internal.core.server.ServerSSLProperties;
-import org.eclipse.dstore.internal.core.server.ServerUpdateHandler;
-import org.eclipse.dstore.internal.core.util.ExternalLoader;
-import org.eclipse.dstore.internal.core.util.Sender;
-import org.eclipse.dstore.internal.core.util.ssl.DStoreSSLContext;
-
-/**
- * ConnectionEstablisher is responsible for managing the server DataStore and
- * facilitating the communication between client and server DataStores.
- *
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- *
- * @since 3.0 moved from non-API to API
- */
-public class ConnectionEstablisher
-{
-
-
- private ServerSocket _serverSocket;
- private static boolean _continue;
-
- private ArrayList _receivers;
-
- private ServerCommandHandler _commandHandler;
- private ServerUpdateHandler _updateHandler;
-
- private ServerAttributes _serverAttributes = new ServerAttributes();
- private DataStore _dataStore;
-
- private int _maxConnections;
- private int _timeout;
- private String _msg;
-
-
- /**
- * Creates the default ConnectionEstablisher. Communication occurs
- * on a default port, there is no timeout and no ticket is required
- * for a client to work with the DataStore.
- *
- */
- public ConnectionEstablisher()
- {
- String port = _serverAttributes.getAttribute(DataStoreAttributes.A_HOST_PORT);
- setup(port, null, null);
- }
-
- /**
- * Creates a ConnectionEstablisher. Communication occurs
- * on the specified port, there is no timeout and no ticket is required
- * for a client to work with the DataStore.
- *
- * @param port the number of the socket port
- */
- public ConnectionEstablisher(String port)
- {
- setup(port, null, null);
- }
-
- /**
- * Creates a ConnectionEstablisher. Communication occurs
- * on the specified port, a timeout value indicates the idle wait
- * time before shutting down, and no ticket is required
- * for a client to work with the DataStore.
- *
- * @param port the number of the socket port
- * @param timeout the idle duration to wait before shutting down
- */
- public ConnectionEstablisher(String port, String timeout)
- {
- setup(port, timeout, null);
- }
-
- /**
- * Creates a ConnectionEstablisher. Communication occurs
- * on the specified port, a timeout value indicates the idle wait
- * time before shutting down, and ticket specified the required
- * ticket for a client to present in order to work with the DataStore.
- *
- * @param port the number of the socket port
- * @param timeout the idle duration to wait before shutting down
- * @param ticket validation id required by the client to access the DataStore
- */
- public ConnectionEstablisher(String port, String timeout, String ticket)
- {
- setup(port, timeout, ticket);
- }
-
-
- /**
- * Starts the run loop for the ConnectionEstablisher.
- */
- public void start()
- {
- run();
- }
-
-
-
- /**
- * Returns the DataStore.
- *
- * @return the DataStore
- */
- public DataStore getDataStore()
- {
- return _dataStore;
- }
-
- /**
- * Return the Server port opened for this client
- *
- * @return the Server port opened for this client
- */
- public int getServerPort()
- {
- if (_serverSocket != null)
- {
- return _serverSocket.getLocalPort();
- }
-
- return -1;
- }
-
- /**
- * Return the connection status for this client
- *
- * * @return the connection status for this client
- */
- public String getStatus()
- {
- return _msg;
- }
-
- /**
- * Tells the connection establisher to clean up and shutdown
- */
- public void finished(ServerReceiver receiver)
- {
- _updateHandler.removeSenderWith(receiver.socket());
- _receivers.remove(receiver);
- _dataStore.removeDataStorePreferenceListener(receiver);
- //if (_receivers.size() == 0)
- {
- _continue = false;
- _commandHandler.finish();
- _updateHandler.finish();
- _dataStore.finish();
- System.out.println(ServerReturnCodes.RC_FINISHED);
-
- if (SystemServiceManager.getInstance().getSystemService() == null)
- System.exit(0);
- }
- }
-
- private void waitForConnections()
- {
- while (_continue == true)
- {
- try
- {
- Socket newSocket = _serverSocket.accept();
- if (_dataStore.usingSSL())
- {
-
- // wait for connection
- SSLSocket sslSocket = (SSLSocket)newSocket;
- sslSocket.setUseClientMode(false);
- sslSocket.setNeedClientAuth(false);
- SSLSession session = sslSocket.getSession();
-
- if (session == null)
- {
- System.out.println("handshake failed"); //$NON-NLS-1$
- sslSocket.close();
- return;
- }
- }
-
- doHandShake(newSocket);
- newSocket.setKeepAlive(true);
-
- ServerReceiver receiver = new ServerReceiver(newSocket, this);
- _dataStore.addDataStorePreferenceListener(receiver);
-
- if (_dataStore.getClient() != null)
- _dataStore.getClient().setServerReceiver(receiver);
-
- Sender sender = new Sender(newSocket, _dataStore);
-
- // add this connection to list of elements
- _receivers.add(receiver);
- _updateHandler.addSender(sender);
-
- receiver.start();
-
- if (_receivers.size() == 1)
- {
- _updateHandler.start();
- _commandHandler.start();
- }
-
- if (_receivers.size() == _maxConnections)
- {
- _continue = false;
- _serverSocket.close();
-
- }
- }
- catch (IOException ioe)
- {
- System.err.println(ServerReturnCodes.RC_CONNECTION_ERROR);
- System.err.println("Server: error initializing socket: " + ioe); //$NON-NLS-1$
- _msg = ioe.toString();
- try
- {
- _serverSocket.close();
- }
- catch (Throwable e)
- {
-
- }
- _continue = false;
- }
- }
- }
-
-
-
-
- private ServerSocket createSocket(String portStr) throws UnknownHostException
- {
- ServerSocket serverSocket = null;
- SSLContext sslContext = null;
- // port
- int port = 0;
-
- if (_dataStore.usingSSL())
- {
- String keyStoreFileName = _dataStore.getKeyStoreLocation();
- String keyStorePassword = _dataStore.getKeyStorePassword();
-
- try
- {
- sslContext = DStoreSSLContext.getServerSSLContext(keyStoreFileName, keyStorePassword);
- }
- catch (Exception e)
- {
-
- }
- }
-
- // determine if portStr is a port range or just a port
- String[] range = portStr.split("-"); //$NON-NLS-1$
- if (range.length == 2)
- {
- int lPort = 0;
- int hPort = 0;
- try
- {
- lPort = Integer.parseInt(range[0]);
- hPort = Integer.parseInt(range[1]);
- }
- catch (Exception e)
- {
- }
-
- for (int i = lPort; i < hPort; i++)
- {
- // create server socket from port
- try
- {
- if (_dataStore.usingSSL() && sslContext != null)
- {
- try
- {
- serverSocket = sslContext.getServerSocketFactory().createServerSocket(i);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- serverSocket = new ServerSocket(i);
- }
- }
- catch (Exception e)
- {
- _dataStore.trace(e);
- }
- if (serverSocket != null && serverSocket.getLocalPort() > 0)
- {
- return serverSocket;
- }
- }
- }
- else
- {
- port = Integer.parseInt(portStr);
-
-
- // create server socket from port
- if (_dataStore.usingSSL() && sslContext != null)
- {
- try
- {
- serverSocket = sslContext.getServerSocketFactory().createServerSocket(port);
- }
- catch (Exception e)
- {
- _dataStore.trace(e);
- }
- }
- else
- {
- try
- {
- serverSocket = new ServerSocket(port);
- }
- catch (Exception e)
- {
- _dataStore.trace(e);
- }
- }
- }
- return serverSocket;
- }
-
- /**
- * Create the DataStore and initializes it's handlers and communications.
- *
- * @param portStr the number of the socket port
- * @param timeoutStr the idle duration to wait before shutting down
- * @param ticketStr validation id required by the client to access the DataStore
- */
- private void setup(String portStr, String timeoutStr, String ticketStr)
- {
- _maxConnections = 1;
-
-
- ArrayList loaders = new ArrayList();
- loaders.add(new ExternalLoader(getClass().getClassLoader(), "*")); //$NON-NLS-1$
- _commandHandler = new ServerCommandHandler(loaders);
- _updateHandler = new ServerUpdateHandler();
-
- ISSLProperties sslProperties = new ServerSSLProperties();
-
- _dataStore = new DataStore(_serverAttributes, _commandHandler, _updateHandler, null);
- _dataStore.setSSLProperties(sslProperties);
-
- DataElement ticket = _dataStore.getTicket();
- ticket.setAttribute(DE.A_NAME, ticketStr);
-
- _updateHandler.setDataStore(_dataStore);
- _commandHandler.setDataStore(_dataStore);
-
- if (SystemServiceManager.getInstance().getSystemService() == null)
- {
- Client client = new Client();
- _dataStore.setClient(client);
- ServerLogger logger = new ServerLogger(_dataStore.getUserPreferencesDirectory());
- client.setLogger(logger);
- }
-
- _receivers = new ArrayList();
- _continue = true;
-
- try
- {
-
- _serverSocket = createSocket(portStr);
- if (_serverSocket == null)
- {
- System.err.println(ServerReturnCodes.RC_BIND_ERROR);
- _msg = ServerReturnCodes.RC_BIND_ERROR;
- _continue = false;
- }
- else
- {
- // timeout
- if (timeoutStr != null)
- {
- _timeout = Integer.parseInt(timeoutStr);
- }
- else
- {
- _timeout = 120000;
- }
-
- if (_timeout > 0)
- {
- _serverSocket.setSoTimeout(_timeout);
- }
-
- System.err.println(ServerReturnCodes.RC_SUCCESS);
- System.err.println(_serverSocket.getLocalPort());
- _msg = ServerReturnCodes.RC_SUCCESS;
- try
- {
- System.err.println("Server running on: " + InetAddress.getLocalHost().getHostName()); //$NON-NLS-1$
- }
- catch (UnknownHostException e)
- {
- // keep running
- }
- }
- }
- catch (UnknownHostException e)
- {
- System.err.println(ServerReturnCodes.RC_UNKNOWN_HOST_ERROR);
- _msg = ServerReturnCodes.RC_UNKNOWN_HOST_ERROR;
- _continue = false;
- }
- catch (BindException e)
- {
- System.err.println(ServerReturnCodes.RC_BIND_ERROR);
- _msg = ServerReturnCodes.RC_BIND_ERROR;
- _continue = false;
- }
- catch (IOException e)
- {
- System.err.println(ServerReturnCodes.RC_GENERAL_IO_ERROR);
- _msg = ServerReturnCodes.RC_GENERAL_IO_ERROR;
- _continue = false;
- }
- catch (SecurityException e)
- {
- System.err.println(ServerReturnCodes.RC_SECURITY_ERROR);
- _msg = ServerReturnCodes.RC_SECURITY_ERROR;
- _continue = false;
- }
- }
-
- private void run()
- {
- waitForConnections();
- }
-
- private void doHandShake(Socket socket)
- {
- try
- {
- BufferedWriter bwriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), DE.ENCODING_UTF_8));
- PrintWriter writer = new PrintWriter(bwriter);
-
- String version = DataStoreAttributes.DATASTORE_VERSION;
- String preferenceVersion = System.getProperty("DSTORE_VERSION"); //$NON-NLS-1$
- if (preferenceVersion != null && preferenceVersion.length() > 0){
- version = preferenceVersion;
- }
- writer.println(version);
- writer.flush();
- }
- catch (IOException e)
- {
- if (_dataStore.getClient() != null) {
- _dataStore.getClient().getLogger().logError(this.getClass().toString(), e.toString(), e);
- }
- System.out.println(e);
- }
-
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/IServerLogger.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/IServerLogger.java
deleted file mode 100644
index 862282b21..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/IServerLogger.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: Noriaki Takatsu and Masao Nishimoto
-
- * Contributors:
- * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
- *******************************************************************************/
-
-package org.eclipse.dstore.core.server;
-
-/**
- * @since 3.0
- */
-public interface IServerLogger
-{
- /**
- * logInfo
- *
- * @param minerName
- * @param message Message text to be logged.
- */
- public void logInfo(String minerName, String message);
-
- /**
- * logWarning
- *
- * @param minerName
- * @param message Message text to be logged.
- */
- public void logWarning(String minerName, String message);
-
- /**
- * logError
- *
- * @param minerName
- * @param message Message text to be logged.
- * @param exception Exception that generated the error. Used to print a stack trace.
- */
- public void logError(String minerName, String message, Throwable exception);
-
- /**
- * logDebugMessage
- * @param minerName
- * @param message Message text to be logged.
- */
- public void logDebugMessage(String minerName, String message);
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ISystemService.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ISystemService.java
deleted file mode 100644
index 90137a4e6..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ISystemService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: Noriaki Takatsu and Masao Nishimoto
- *
- * Contributors:
- * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
- *******************************************************************************/
-
-
-package org.eclipse.dstore.core.server;
-
-import org.eclipse.dstore.core.model.Client;
-
-/**
- * @since 3.0
- */
-public interface ISystemService
-{
- /**
- * This method is used to establish a thread-level security.
- *
- * @param client the object of the client
- */
- public void setThreadSecurity(Client client);
-
- /**
- * This method is used to execute run() in a thread assigned
- * from thread pools.
- *
- * @param securedThread the securedThread object that implements
- * Runnable.
- */
- public void executeThread(SecuredThread securedThread);
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SecuredThread.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SecuredThread.java
deleted file mode 100644
index ed2f97cf1..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SecuredThread.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: Noriaki Takatsu and Masao Nishimoto
- *
- * Contributors:
- * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
- * Noriaki Takatsu (IBM) - [228335] [dstore][multithread] start() in SecuredThread class
- *******************************************************************************/
-
-package org.eclipse.dstore.core.server;
-
-
-import java.io.PrintWriter;
-
-import org.eclipse.dstore.core.model.DataStore;
-
-/**
- * @since 3.0
- */
-public class SecuredThread extends Thread
-{
-
- public DataStore _dataStore;
-
-
- /**
- * Constructs a new SecuredThread without a DataStore. In this case, the DataStore
- * needs to be set sometime after creation via <code>setDataStore(DataStore)</code>.
- */
- public SecuredThread() {
- }
-
- /**
- * Constructs a new SecuredThread given a DataStore.
- *
- * @param dataStore used to extract user id and password for a client
- */
- public SecuredThread(DataStore dataStore)
- {
- this(null, dataStore);
- }
-
-
- /**
- * Constructs a new SecuredThread with a DataStore and a runnable. After
- * the thread starts, the runnable will be implicitly executed.
- *
- * @param runnable the runnable to be executed by the thread
- * @param dataStore used to extract user id and password for a client
- */
- public SecuredThread(Runnable runnable, DataStore dataStore) {
- super(runnable);
- _dataStore = dataStore;
- }
-
-
- /**
- * Constructs a new SecuredThread with a DataStore, a runnable and name for the thread.
- * After the thread starts, the runnable will be implicitly executed.
- *
- * @param runnable the runnable to be executed by the thread
- * @param threadName the name for the SecuredThread being created
- * @param dataStore used to extract user id and password for a client
- */
- public SecuredThread(Runnable runnable, String threadName, DataStore dataStore) {
- this(null, runnable, threadName, dataStore);
- }
-
- /**
- * Constructs a new SecuredThread with a DataStore, a runnable and a ThreadGroup.
- * After the thread starts, the runnable will be implicitly executed.
- *
- * @param group the thread group for which this thread will belong
- * @param runnable the runnable to be executed by the thread
- * @param dataStore used to extract user id and password for a client
- */
- public SecuredThread(ThreadGroup group, Runnable runnable, DataStore dataStore) {
- super(group, runnable);
- _dataStore = dataStore;
- }
-
-
- /**
- * Constructs a new SecuredThread with a DataStore, a runnable, a name and a ThreadGroup.
- * After the thread starts, the runnable will be implicitly executed.
- *
- * @param group the thread group for which this thread will belong
- * @param runnable the runnable to be executed by the thread
- * @param threadName the name for the SecuredThread being created
- * @param dataStore used to extract user id and password for a client
- */
- public SecuredThread(ThreadGroup group, Runnable runnable, String threadName, DataStore dataStore) {
- super(group, runnable, threadName);
- _dataStore = dataStore;
- }
-
-
- /**
- * Sets the DataStore associated with the client
- * @param dataStore
- */
- public void setDataStore(DataStore dataStore)
- {
- _dataStore = dataStore;
- }
-
-
- /**
- * When run() is called, a check is made to see if there is an ISystemService. If there is
- * the <code>ISystemService.setThreadSecurity(Client)</code> is called before <code>Thread.run()</code>
- * is called.
- *
- * If a Runnable was passed into the constructor for SecuredThread then, when <code>Thread.run()</code>
- * is called, the Runnable will be invoked.
- */
- public void run()
- {
- try
- {
- ISystemService systemService = SystemServiceManager.getInstance().getSystemService();
- if (systemService != null){
- systemService.setThreadSecurity(_dataStore.getClient());
- }
- }
- catch (Throwable e)
- {
- e.printStackTrace(new PrintWriter(System.err));
- }
-
- super.run();
- }
-
- /**
- *
- * As per bug 228335, this is commented out.
- *
- * When start() is called, a check is made to see if there is an ISystemService.
- * If there is, the <code>ISystemService.executeThread(SecuredThread)</code> is called.
- * In this case, the run() method is invoked in a thread assigned from the running
- * work threads
- * If there isn't, the <code>super.start()</code> is called.
- * In this case. the run() method is invoked as a new thread.
-
- public void start()
- {
-
- try
- {
-
- ISystemService systemService = SystemServiceManager.getInstance().getSystemService();
- if (systemService != null){
- systemService.executeThread(this);
- }
- else
- {
- super.start();
- }
- }
- catch(Throwable e)
- {
- e.printStackTrace(new PrintWriter(System.err));
- }
- }
- */
-}
-
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/Server.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/Server.java
deleted file mode 100644
index cfe1040f9..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/Server.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
- * David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
- * David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types
- * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed
- *******************************************************************************/
-
-package org.eclipse.dstore.core.server;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.dstore.internal.core.server.ServerReturnCodes;
-
-/**
- * Server is the standard way of instantiating and controlling a remote DataStore.
- * The server runs a ConnectionEstablisher which manages client connections to
- * the DataStore.
- *
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class Server implements Runnable
-{
-
- private ConnectionEstablisher _establisher;
-
- /**
- * The startup interface to run the Server.
- *
- * @param args a list of arguments for running the server. These consist of
- * the socket port to wait on, the timeout value, and the the ticket
- */
- public static void main(String[] args)
- {
- //Tell the Launcher that we are starting
- System.err.println(ServerReturnCodes.RC_DSTORE_SERVER_MAGIC);
-
- String jversion = System.getProperty("java.version"); //$NON-NLS-1$
-
- StringTokenizer tokenizer = new StringTokenizer(jversion, "."); //$NON-NLS-1$
- try
- {
- String[] vers = new String[3];
- vers[0] = tokenizer.nextToken();
- vers[1] = tokenizer.nextToken();
-
- int version = Integer.parseInt(vers[0]);
- int major = Integer.parseInt(vers[1]);
-
-
- if (version >= 1 && major >= 4)
- {
- // version is good
- }
- else
- {
- // version is bad
- System.err.println(ServerReturnCodes.RC_JRE_VERSION_ERROR);
- if (SystemServiceManager.getInstance().getSystemService() == null)
- System.exit(-1);
- }
- }
- catch (Exception e)
- {
- // version is bad
- System.err.println(ServerReturnCodes.RC_JRE_VERSION_ERROR);
- if (SystemServiceManager.getInstance().getSystemService() == null)
- System.exit(-1);
- }
-
- try
- {
- Server theServer = null;
- switch (args.length)
- {
- case 0 :
- theServer = new Server();
- break;
- case 1 :
- theServer = new Server(args[0]);
- break;
- case 2 :
- theServer = new Server(args[0], args[1]);
- break;
- case 3 :
- theServer = new Server(args[0], args[1], args[2]);
- break;
- default :
- break;
- }
-
-
- if (theServer != null)
- {
- theServer.run();
- }
- }
- catch (SecurityException e)
- {
- System.err.println(ServerReturnCodes.RC_SECURITY_ERROR);
- throw e; // Optional
- }
- }
-
- /**
- * Creates a new Server with default DataStore and connection attributes.
- *
- */
- public Server()
- {
- _establisher = new ConnectionEstablisher();
- }
-
- /**
- * Creates a new Server that waits on the specified socket port.
- *
- * @param port the number of the socket port to wait on
- */
- public Server(String port)
- {
- _establisher = new ConnectionEstablisher(port);
- }
-
- /**
- * Creates a new Server that waits on the specified socket port for
- * the specified time interval before shutting down.
- *
- * @param port the number of the socket port to wait on
- * @param timeout the idle time to wait before shutting down
- */
- public Server(String port, String timeout)
- {
- _establisher = new ConnectionEstablisher(port, timeout);
- }
-
- /**
- * Creates a new Server that waits on the specified socket port for
- * the specified time interval before shutting down.
- *
- * @param port the number of the socket port to wait on
- * @param timeout the idle time to wait before shutting down
- * @param ticket the ticket that the client needs to interact with the DataStore
- */
- public Server(String port, String timeout, String ticket)
- {
- _establisher = new ConnectionEstablisher(port, timeout, ticket);
- }
-
-
- /**
- * Runs the server by starting the ConnectionEstablisher
- */
- public void run()
- {
- _establisher.start();
- }
-
-
- /**
- * Return the reference for the ConnectionEstablisher for this client
- *
- * @return the the reference for the ConnectionEstablisher instance for this
- * client
- * @since 3.0
- */
- public ConnectionEstablisher getEstablisher()
- {
- return _establisher;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLauncher.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLauncher.java
deleted file mode 100644
index 5f6fdef60..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLauncher.java
+++ /dev/null
@@ -1,686 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [193426] don't display exceptions
- * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed
- * David McKnight (IBM) - [245714] [dstore] Multiple user ID/password prompts and connect fails
- *******************************************************************************/
-
-package org.eclipse.dstore.core.server;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.BindException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-
-import javax.net.ssl.HandshakeCompletedEvent;
-import javax.net.ssl.HandshakeCompletedListener;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-
-import org.eclipse.dstore.core.model.DE;
-import org.eclipse.dstore.core.model.IDataStoreConstants;
-import org.eclipse.dstore.core.model.ISSLProperties;
-import org.eclipse.dstore.internal.core.server.ServerReturnCodes;
-import org.eclipse.dstore.internal.core.server.ServerSSLProperties;
-import org.eclipse.dstore.internal.core.util.ssl.DStoreSSLContext;
-
-/**
- * This class is the DataStore daemon. It is used for authenticating users,
- * launching DataStore servers under particular user IDs, and providing a client
- * with enough information to connect to a launched server.
- *
- */
-public class ServerLauncher extends Thread {
-
- /**
- * An instances of this class get loaded whenever a client requests access
- * to a DataStore server. The ConnectionListener attempts to launch a server
- * under the client user's ID, communicating back information to the client
- * so that if may connect to the launched server. If the authentification
- * and connection to the server are successful, ConnectionListener continues
- * to monitor the server connection until it is terminated.
- */
- public class ConnectionListener extends Thread implements
- HandshakeCompletedListener {
-
- private Socket _socket;
-
- private PrintWriter _writer;
-
- private BufferedReader _reader;
-
- private Process _serverProcess;
-
- private String _port;
-
- private boolean _done;
-
- private BufferedReader _outReader;
-
- private BufferedReader _errReader;
-
- /**
- * Constructor
- *
- * @param socket
- * a socket to the daemon
- */
- public ConnectionListener(Socket socket) {
-
- _socket = socket;
- try {
- _writer = new PrintWriter(new OutputStreamWriter(_socket
- .getOutputStream(), DE.ENCODING_UTF_8));
- _reader = new BufferedReader(new InputStreamReader(_socket
- .getInputStream(), DE.ENCODING_UTF_8));
- } catch (java.io.IOException e) {
- System.out.println("ServerLauncher:" + e); //$NON-NLS-1$
- }
- }
-
- /**
- * Called when shutdown
- */
- public void finalize() throws Throwable {
- if (_serverProcess != null) {
- _serverProcess.destroy();
- }
- super.finalize();
- }
-
- /**
- * Listens to the connection and prints any output while the connection
- * is active
- */
- public void run() {
- _done = true;
- if (listen()) {
- if (_serverProcess != null) {
- _done = false;
-
- try {
- String line = null;
-
- while ((_outReader != null)
- && ((line = _outReader.readLine()) != null)) {
- if (line.equals(ServerReturnCodes.RC_FINISHED)) {
- break;
- } else {
- System.out.println(line);
- }
- }
-
- if (_outReader != null) {
- _outReader.close();
- }
- if (_errReader != null) {
- _errReader.close();
- }
-
- _serverProcess.waitFor();
- } catch (Exception e) {
- System.out.println("ServerLauncher:" + e); //$NON-NLS-1$
- }
- }
-
- System.out.println("finished on port " + _port); //$NON-NLS-1$
- _outReader = null;
- _errReader = null;
- _serverProcess = null;
- _done = true;
- } else {
- _done = true;
- }
- }
-
- /**
- * Indicates whether the connection has terminated or not
- *
- * @return true if the connection has terminated
- */
- public boolean isDone() {
- return _done;
- }
-
- /**
- * Returns the DataStore server port used
- *
- * @return the server port
- */
- public String getServerPort() {
- return _port;
- }
-
- private boolean isPortInRange(String portStr, String portRange) {
- if (portRange != null) {
- String[] range = portRange.split("-"); //$NON-NLS-1$
- if (range.length == 2) {
- int lPort = 0;
- int hPort = 0;
- int port = 0;
- try {
- lPort = Integer.parseInt(range[0]);
- hPort = Integer.parseInt(range[1]);
- port = Integer.parseInt(portStr);
- } catch (Exception e) {
- }
-
- return (port >= lPort && port <= hPort);
- }
- }
- return true;
- }
-
- /**
- * Attempt to start a new DataStore server. The port and the ticket for
- * a newly started DataStore are captured and sent back to the client so
- * that it may connect to the server.
- *
- * @return whether the server started successfully
- */
- public boolean listen()
- {
- boolean connected = false;
-
- String user = null;
- String password = null;
-
- _port = null;
-
- boolean problemReadingSocket = false;
- try
- {
- user = _reader.readLine();
- password = _reader.readLine();
- _port = _reader.readLine();
- }
- catch (IOException e)
- {
- // don't display exceptions 193426
- //e.printStackTrace();
- _port = "0"; //$NON-NLS-1$
-
- // this is probably an SSL exception
- _writer.println(IDataStoreConstants.SERVER_FAILURE + e);
- problemReadingSocket = true;
- }
-
-
- if (_serverPortRange != null && (_port == null || _port.equals("0"))) //$NON-NLS-1$
- {
- _port = _serverPortRange;
- }
-
- if (!problemReadingSocket)
- {
- boolean isError = false;
- if (_serverPortRange != null && _port != _serverPortRange)
- {
- if (!isPortInRange(_port, _serverPortRange))
- {
- String message = IDataStoreConstants.PORT_OUT_RANGE;
- message += _serverPortRange;
- _writer.println(message);
- isError = true;
- }
- }
- if (!isError)
- {
- // start new server
- try
- {
- String launchStatus = null;
- String ticket = new String("" + System.currentTimeMillis()); //$NON-NLS-1$
-
- String theOS = System.getProperty("os.name"); //$NON-NLS-1$
- String timeout = "120000"; //$NON-NLS-1$
-
-
- if (!theOS.toLowerCase().startsWith("win")) //$NON-NLS-1$
- {
- // assuming unix compatable
- //
- // Get the property which
- // contains the authorization
- // script path
- //
- String authPath = System.getProperty("RSE.AUTH"); //$NON-NLS-1$
- File authFile = null;
- if (authPath != null && authPath.length() > 0)
- {
- authFile = new File(authPath);
- }
- if (authFile == null || !authFile.exists())
- {
- authPath = "perl " + _path + File.separator + "auth.pl"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- String authString =
- authPath
- + " " //$NON-NLS-1$
- + user
- + " " //$NON-NLS-1$
- + _path
- + " " //$NON-NLS-1$
- + _port
- + " " //$NON-NLS-1$
- + timeout
- + " " //$NON-NLS-1$
- + ticket
- + " " //$NON-NLS-1$
- + System.getProperty("java.home") //$NON-NLS-1$
- ;
-
- String[] authArray = { "sh", "-c", authString }; //$NON-NLS-1$ //$NON-NLS-2$
-
- // test password
- _serverProcess = Runtime.getRuntime().exec(authArray);
-
- _outReader = new BufferedReader(new InputStreamReader(_serverProcess.getInputStream()));
- _errReader = new BufferedReader(new InputStreamReader(_serverProcess.getErrorStream()));
- BufferedWriter inWriter = new BufferedWriter(new OutputStreamWriter(_serverProcess.getOutputStream()));
- // write password
- if (password != null)
- {
- inWriter.write(password);
- inWriter.newLine();
- inWriter.flush();
-
- launchStatus = _outReader.readLine();
- }
- }
- else
- {
-
- // launch new server
- String[] cmdArray =
- {
- "java", //$NON-NLS-1$
- "-DA_PLUGIN_PATH=" + _path, //$NON-NLS-1$
- "-DDSTORE_SPIRIT_ON=true", //$NON-NLS-1$
- "org.eclipse.dstore.core.server.Server", //$NON-NLS-1$
- _port,
- timeout,
- ticket};
-
- _serverProcess = Runtime.getRuntime().exec(cmdArray);
- _outReader = new BufferedReader(new InputStreamReader(_serverProcess.getInputStream()));
- _errReader = new BufferedReader(new InputStreamReader(_serverProcess.getErrorStream()));
-
- launchStatus = "success"; //$NON-NLS-1$
- }
-
- if ((launchStatus == null) || !launchStatus.equals("success")) //$NON-NLS-1$
- {
- _writer.println(IDataStoreConstants.AUTHENTICATION_FAILED);
- }
- else
- {
- // look for the server startup string, it needs to occur
- // somewhere in the line.
- String status = _errReader.readLine();
- while (status!=null && (status.indexOf(ServerReturnCodes.RC_DSTORE_SERVER_MAGIC) < 0))
- {
- status = _errReader.readLine();
- }
- // now read the real server status
- if (status != null)
- {
- status = _errReader.readLine();
- }
- if ((status != null) && status.equals(ServerReturnCodes.RC_SUCCESS))
- {
- _port = _errReader.readLine();
- _errReader.readLine();
- _writer.println(IDataStoreConstants.CONNECTED);
- _writer.println(_port);
- _writer.println(ticket);
-
- System.out.println("launched new server on " + _port); //$NON-NLS-1$
- connected = true;
- }
- else
- {
- if (status == null)
- {
- status = new String(IDataStoreConstants.UNKNOWN_PROBLEM);
- }
- // TODO Make sure that the client doesnt try
- // connecting forever
- _writer.println(status);
-
- _serverProcess.destroy();
- _serverProcess = null;
- _outReader.close();
- _outReader = null;
-
- _errReader.close();
- _errReader = null;
- }
- }
-
- }
- catch (IOException e)
- {
- _writer.println(IDataStoreConstants.SERVER_FAILURE + e);
- }
- }
- }
-
- _writer.flush();
-
- // close socket
- try
- {
- _socket.close();
- }
- catch (IOException e)
- {
- System.out.println("ServerLauncher:" + e); //$NON-NLS-1$
- }
-
- return connected;
- }
-
- public void handshakeCompleted(HandshakeCompletedEvent event) {
- System.out.println("handshake completed"); //$NON-NLS-1$
- System.out.println(event);
-
- }
- }
-
- private ServerSocket _serverSocket;
-
- private String _path;
-
- private ArrayList _connections;
-
- private String _serverPortRange;
-
- private ISSLProperties _sslProperties;
-
- public static int DEFAULT_DAEMON_PORT = 4075;
-
- /**
- * Constructor
- */
- public ServerLauncher() {
- String pluginPath = System.getProperty("A_PLUGIN_PATH"); //$NON-NLS-1$
- if (pluginPath == null) {
- System.out.println("A_PLUGIN_PATH is not defined"); //$NON-NLS-1$
- System.exit(-1);
- }
- else
- {
- _path = pluginPath.trim();
-
- _connections = new ArrayList();
-
- init(DEFAULT_DAEMON_PORT + ""); //$NON-NLS-1$
- }
- }
-
- /**
- * Constructor
- *
- * @param portStr
- * the port for the daemon socket to run on
- */
- public ServerLauncher(String portStr) {
- String pluginPath = System.getProperty("A_PLUGIN_PATH"); //$NON-NLS-1$
- if (pluginPath == null) {
- System.out.println("A_PLUGIN_PATH is not defined"); //$NON-NLS-1$
- System.exit(-1);
- }
- else
- {
- _path = pluginPath.trim();
-
- _connections = new ArrayList();
- init(portStr);
- }
- }
-
- /**
- * Constructor
- *
- * @param portStr
- * the port for the daemon socket to run on
- * @param serverPortRange
- * the port range for launched servers
- */
- public ServerLauncher(String portStr, String serverPortRange) {
- String pluginPath = System.getProperty("A_PLUGIN_PATH"); //$NON-NLS-1$
- if (pluginPath == null) {
- System.out.println("A_PLUGIN_PATH is not defined"); //$NON-NLS-1$
- System.exit(-1);
- }
- else
- {
- _path = pluginPath.trim();
-
- _serverPortRange = serverPortRange;
- _connections = new ArrayList();
- init(portStr);
- }
- }
-
- private String getKeyStoreLocation() {
- return _sslProperties.getDaemonKeyStorePath();
- }
-
- private String getKeyStorePassword() {
- return _sslProperties.getDaemonKeyStorePassword();
- }
-
- /**
- * initializes the DataStore daemon
- *
- * @param portStr the daemon port
- */
- public void init(String portStr) {
- // create server socket from port
- _sslProperties = new ServerSSLProperties();
-
- // determine if portStr is a port range or just a port
- String[] range = portStr.split("-"); //$NON-NLS-1$
- if (range.length == 2) {
- int lPort = 0;
- int hPort = 0;
- try {
- lPort = Integer.parseInt(range[0]);
- hPort = Integer.parseInt(range[1]);
- } catch (Exception e) {
- }
-
- boolean socketBound = false;
- for (int i = lPort; i < hPort && !socketBound; i++) {
- // create server socket from port
- try {
- if (_sslProperties.usingSSL()) {
- String keyStoreFileName = getKeyStoreLocation();
- String keyStorePassword = getKeyStorePassword();
-
- try {
- SSLContext sslContext = DStoreSSLContext
- .getServerSSLContext(keyStoreFileName,
- keyStorePassword);
-
- _serverSocket = sslContext.getServerSocketFactory()
- .createServerSocket(i);
- } catch (Exception e) {
- // don't display exceptions 193426
- //e.printStackTrace();
- }
- } else {
- _serverSocket = new ServerSocket(i);
- }
- if (_serverSocket != null
- && _serverSocket.getLocalPort() > 0) {
- socketBound = true;
- System.out.println("Daemon running on: " //$NON-NLS-1$
- + InetAddress.getLocalHost().getHostName()
- + ", port: " + i); //$NON-NLS-1$
- }
- } catch (UnknownHostException e) {
- System.err
- .println("Networking problem, can't resolve local host"); //$NON-NLS-1$
- // don't display exceptions 193426
- //e.printStackTrace();
- System.exit(-1);
- } catch (BindException e) {
- System.err.println("socket taken on " + i); //$NON-NLS-1$
- // keep going
- } catch (IOException e) {
- System.err.println("Failure to create ServerSocket"); //$NON-NLS-1$
- // don't display exceptions 193426
- //e.printStackTrace();
- System.exit(-1);
- }
-
- }
- } else {
- int port = Integer.parseInt(portStr);
- try {
- if (_sslProperties.usingSSL()) {
- String keyStoreFileName = getKeyStoreLocation();
- String keyStorePassword = getKeyStorePassword();
-
- try {
- SSLContext sslContext = DStoreSSLContext
- .getServerSSLContext(keyStoreFileName,
- keyStorePassword);
-
- _serverSocket = sslContext.getServerSocketFactory()
- .createServerSocket(port);
- } catch (Exception e) {
- // don't display exceptions 193426
- //e.printStackTrace();
- System.err.println(e.getMessage());
- System.exit(-1);
- }
- } else {
- _serverSocket = new ServerSocket(port);
- }
- System.out.println("Daemon running on: " //$NON-NLS-1$
- + InetAddress.getLocalHost().getHostName() + ", port: " //$NON-NLS-1$
- + port);
- } catch (UnknownHostException e) {
- System.err
- .println("Networking problem, can't resolve local host"); //$NON-NLS-1$
- // don't display exceptions 193426
- //e.printStackTrace();
- System.exit(-1);
- } catch (IOException e) {
- System.err.println("Failure to create ServerSocket"); //$NON-NLS-1$
- // don't display exceptions 193426
- //e.printStackTrace();
- System.exit(-1);
- }
- }
- }
-
- /**
- * Return the connection listener for the specified port if there is one
- *
- * @param port
- * the port
- * @return the listener associated with the port
- */
- protected ConnectionListener getListenerForPort(String port) {
- for (int i = 0; i < _connections.size(); i++) {
- ConnectionListener listener = (ConnectionListener) _connections
- .get(i);
- if (listener.getServerPort().equals(port)) {
- return listener;
- }
- }
-
- return null;
- }
-
- /**
- * Run the daemon
- */
- public void run() {
- while (true) {
- try {
- boolean connectionOkay = true;
- Socket newSocket = _serverSocket.accept();
- if (_sslProperties.usingSSL()) {
-
- SSLSocket sslSocket = (SSLSocket) newSocket;
- sslSocket
- .addHandshakeCompletedListener(new HandshakeCompletedListener() {
-
- public void handshakeCompleted(
- HandshakeCompletedEvent event) {
- System.out.println("handshake completed"); //$NON-NLS-1$
- }
-
- });
- SSLSession session = sslSocket.getSession();
- if (session == null) {
- System.out.println("handshake failed"); //$NON-NLS-1$
-
- sslSocket.close();
- connectionOkay = false;
- }
- }
- if (connectionOkay) {
- ConnectionListener listener = new ConnectionListener(
- newSocket);
- listener.start();
- _connections.add(listener);
- }
- } catch (IOException ioe) {
- System.err.println("Server: error initializing socket: " + ioe); //$NON-NLS-1$
- System.exit(-1);
- }
- }
- }
-
- /**
- * Entry point into the DataStore daemon
- *
- * @param args
- * the port for the daemon to run on (default is 4075).
- * Optionally, the second arg specifies whether to use SSL or
- * not. an optional second arg can be used to specify the port
- * range of servers that get launched
- */
- public static void main(String args[]) {
- if (args.length == 2) {
- ServerLauncher theServer = new ServerLauncher(args[0], args[1]);
- theServer.start();
- } else if (args.length == 1) {
- ServerLauncher theServer = new ServerLauncher(args[0]);
- theServer.start();
- } else {
- ServerLauncher theServer = new ServerLauncher();
- theServer.start();
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLogger.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLogger.java
deleted file mode 100644
index f60b8c836..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerLogger.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation. 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
- * David McKnight (IBM) - [226086] [dstore][api][breaking] Move ServerLogger class to dstore.core
- * Jacob Garcowski (IBM) - [232738] [dstore] Delay creation of log file until written to
- * Noriaki Takatsu (IBM) - [232443] [multithread] A single rsecomm.log for all clients
- * Noriaki Takatsu (IBM) - [239419] [multithread] Dynamically change the level of logging
- * David McKnight (IBM) - [244876] [dstore] make DEBUG a non-final variable of the ServerLogger class
- ********************************************************************************/
-
-package org.eclipse.dstore.core.server;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.ResourceBundle;
-
-/**
- * Class that facilitates logging for errors, warnings, debug messages and info
- * for DataStore servers.
- *
- * @since 3.0 moved from non-API to API
- */
-public class ServerLogger implements IServerLogger
-{
-
-
- // Constants for logging - for use in rsecomm.properties
- private static final String DEBUG_LEVEL = "debug_level"; //$NON-NLS-1$
- private static final String LOG_LOCATION = "log_location"; //$NON-NLS-1$
-
- private static final int LOG_WARNING = 1;
- private static final int LOG_INFO = 2;
- private static final int LOG_DEBUG = 3;
-
- private static final String LOG_TO_STDOUT = "Log_To_StdOut"; //$NON-NLS-1$
-
- private Object writeLock = new Object();
- private PrintWriter _logFileStream = null;
-
- /**
- * Switch to enable debug-level logging. Note that, in 3.0, this variable
- * was final but, as of 3.0.1, it's not.
- */
- public static boolean DEBUG = false;
-
- private int log_level = 0;
-
- private boolean initialized = false;
- private String logPathName = null;
- private boolean logToFile = true;
-
- /**
- * Constructs a new ServerLogger.
- *
- * @param logPathName the path on the filesystem to store the log information
- */
- public ServerLogger(String logPathName) {
- this.logPathName = logPathName;
- // Read .properties file to configure
- try {
- ResourceBundle properties = ResourceBundle.getBundle("rsecomm"); //$NON-NLS-1$
- String debug_level = properties.getString(DEBUG_LEVEL).trim();
- log_level = Integer.parseInt(debug_level);
- String log_location = properties.getString(LOG_LOCATION).trim();
- if (log_location.equalsIgnoreCase(LOG_TO_STDOUT)) {
- logToFile = false;
- _logFileStream = new PrintWriter(System.out);
- }
- } catch (Exception e) {
- // Just use logging defaults: log_level = 0, log to file
- //e.printStackTrace();
- }
- }
-
- private void initialize()
- {
- initialized = true;
- if (_logFileStream == null) {
- if (logToFile) {
- try {
- File _logFile = new File(logPathName, "rsecomm.log"); //$NON-NLS-1$
-
- if (!_logFile.exists()) {
- _logFile.createNewFile();
- }
-
- _logFileStream = new PrintWriter(new FileOutputStream(_logFile));
-
- } catch (IOException e) {
- System.out.println("Error opening log file " + logPathName + "rsecomm.log"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- }
-
-
- /**
- * Logs an informational message
- *
- * @param minerName the name of the miner associated with this message
- * @param message Message text to be logged.
- */
- public void logInfo(String minerName, String message) {
- if (!initialized)
- initialize();
- String loggerLogLevel = System.getProperty("DSTORE_LOGGER_LOG_LEVEL"); //$NON-NLS-1$
- if (loggerLogLevel != null){
- try {
- log_level = Integer.parseInt(loggerLogLevel);
- }
- catch (NumberFormatException e){
- System.err.println("ServerLogger: "+e.toString()); //$NON-NLS-1$
- }
- }
- if (log_level >= LOG_INFO) {
- if (_logFileStream != null) {
- synchronized(writeLock) {
- try {
- _logFileStream.println(new Date());
- _logFileStream.println("INFO " + minerName + ": " + message); //$NON-NLS-1$ //$NON-NLS-2$
- _logFileStream.println("---------------------------------------------------------------"); //$NON-NLS-1$
- _logFileStream.flush();
- }catch (Exception e) {}
- }
- }
- }
- }
-
-
- /**
- * Logs a warning message
- *
- * @param minerName the name of the miner associated with this message
- * @param message Message text to be logged.
- */
- public void logWarning(String minerName, String message) {
- if (!initialized)
- initialize();
- String loggerLogLevel = System.getProperty("DSTORE_LOGGER_LOG_LEVEL"); //$NON-NLS-1$
- if (loggerLogLevel != null){
- try {
- log_level = Integer.parseInt(loggerLogLevel);
- }
- catch (NumberFormatException e){
- System.err.println("ServerLogger: "+e.toString()); //$NON-NLS-1$
- }
- }
- if (log_level >= LOG_WARNING) {
- if (_logFileStream != null) {
- synchronized(writeLock) {
- try {
- _logFileStream.println(new Date());
- _logFileStream.println("WARNING " + minerName + ": " + message); //$NON-NLS-1$ //$NON-NLS-2$
- _logFileStream.println("---------------------------------------------------------------"); //$NON-NLS-1$
- _logFileStream.flush();
- }catch (Exception e) {}
- }
- }
- }
- }
-
-
- /**
- * Logs an error message
- *
- * @param minerName the name of the miner associated with this message
- * @param message Message text to be logged.
- *
- * @param exception Exception that generated the error. Used to print a stack trace.
- */
- public void logError(String minerName, String message, Throwable exception) {
- if (!initialized)
- initialize();
- if (_logFileStream != null) {
- synchronized(writeLock) {
- try {
- _logFileStream.println(new Date());
- _logFileStream.println("ERROR " + minerName + ": " + message); //$NON-NLS-1$ //$NON-NLS-2$
- if (exception != null) {
- exception.printStackTrace(_logFileStream);
- }
- _logFileStream.println("---------------------------------------------------------------"); //$NON-NLS-1$
- _logFileStream.flush();
- }catch (Exception e) {}
- }
- }
- }
-
-
- /**
- * Logs a debug message
- *
- * @param minerName the name of the miner associated with this message
- * @param message Message text to be logged.
- */
- public synchronized void logDebugMessage(String minerName, String message) {
- if (!initialized)
- initialize();
- if (DEBUG && log_level == LOG_DEBUG) {
- if (_logFileStream != null) {
- synchronized(writeLock) {
- try {
- _logFileStream.println(new Date());
- _logFileStream.println("DEBUG " + minerName + ": " + message); //$NON-NLS-1$ //$NON-NLS-2$
- _logFileStream.println("---------------------------------------------------------------"); //$NON-NLS-1$
- _logFileStream.flush();
- }catch (Exception e) {}
- }
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerReceiver.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerReceiver.java
deleted file mode 100644
index c0f9ab94e..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/ServerReceiver.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 IBM Corporation 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:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types
- * Noriaki Takatsu (IBM) - [227905] prevent double invocations of finished in ConncetionEstablisher
- * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed
- * Noriaki Takatsu (IBM) - [257666] [multithread] TCP/IP socket connection is not closed
- * David McKnight (IBM) - [257666] modified original patch to simplify
- * Noriaki Takatsu (IBM) - [283656] [dstore][multithread] Serviceability issue
- *******************************************************************************/
-
-package org.eclipse.dstore.core.server;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.core.util.Receiver;
-
-/**
- * The ServerReciever is responsible for recieving data from the client side.
- *
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- * @since 3.0 moved from non-API to API
- */
-public class ServerReceiver extends Receiver
-{
-
- private ConnectionEstablisher _connection;
-
- /**
- * Constructor
- *
- * @param socket the socket to receive from
- * @param connection the connection establisher
- */
- public ServerReceiver(Socket socket, ConnectionEstablisher connection)
- {
- super(socket, connection.getDataStore());
- _connection = connection;
- }
-
-
- /**
- * Implementation for handling the receiving on documents on
- * the server side.
- *
- * @param documentObject to tree root of received data.
- */
- public void handleDocument(DataElement documentObject)
- {
- // parse request and determine what is wanted
- for (int a = 0; a < documentObject.getNestedSize(); a++)
- {
- DataElement rootOutput = documentObject.get(a);
-
- DataElement log = _dataStore.getLogRoot();
- log.addNestedData(rootOutput, false);
-
- if (rootOutput.getName().equals("C_EXIT")) //$NON-NLS-1$
- {
- finish();
-
- }
- else
- {
- _dataStore.command(rootOutput);
- }
- }
- }
-
- public void finish()
- {
- _dataStore.setConnected(false);
- super.finish();
- _connection.finished(this);
- try
- {
- socket().close();
- }
- catch (IOException e){
- if (_dataStore.getClient() != null) {
- _dataStore.getClient().getLogger().logError(this.getClass().toString(), e.toString(), e);
- }
- System.out.println(e);
- }
- }
-
- /**
- * @see Receiver#finish()
- */
- public void handleError(Throwable e)
- {
- if (_dataStore.getClient() != null) {
- _dataStore.getClient().getLogger().logError(this.getClass().toString(), e.toString(), e);
- }
- System.out.println("RECEIVER ERROR"); //$NON-NLS-1$
- e.printStackTrace();
- System.out.println(e);
- _connection.finished(this);
- try
- {
- socket().close();
- }
- catch (IOException IOe){
- System.out.println(IOe);
- }
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SystemServiceManager.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SystemServiceManager.java
deleted file mode 100644
index 88f8fb1a4..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/core/server/SystemServiceManager.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: Noriaki Takatsu and Masao Nishimoto
- *
- * Contributors:
- * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients
- *******************************************************************************/
-
-package org.eclipse.dstore.core.server;
-
-/**
- * @since 3.0
- */
-public class SystemServiceManager
-{
- private static SystemServiceManager instance = null;
- private static ISystemService _systemService;
-
-
- /**
- * Creates an instance of SystemServiceManager to hold the system-specific
- * parts that needs unique implementations for this system.
- *
- */
- private SystemServiceManager()
- {}
-
- /**
- * Get the SystemServiceManager object for this system.
- *
- * @return the object of the SystemServiceManager
- */
- public static SystemServiceManager getInstance()
- {
- if (instance == null)
- {
- instance = new SystemServiceManager();
- }
- return instance;
- }
-
- /**
- * Set the SystemService object for this system.
- *
- * @param systemService the object of the SystemService
- */
- public void setSystemService(ISystemService systemService)
- {
- _systemService = systemService;
- }
-
- /**
- * Get the SystemService object for this system.
- *
- * @return the object of the SystemService stored in SystemServiceManager
- */
- public ISystemService getSystemService()
- {
- return _systemService;
- }
-
-
-}

Back to the top