Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core')
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientAttributes.java58
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientCommandHandler.java396
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientReceiver.java78
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientSSLProperties.java107
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientUpdateHandler.java190
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/model/DefaultByteConverter.java95
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/model/SchemaRegistry.java96
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/MinerLoader.java426
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerAttributes.java73
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerCommandHandler.java590
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerReturnCodes.java40
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerSSLProperties.java148
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerUpdateHandler.java480
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/DataElementRemover.java239
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ExternalLoader.java109
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ISender.java28
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/MemoryManager.java161
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Pattern.java166
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Sender.java366
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Sorter.java72
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLgenerator.java694
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java1115
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreKeyManager.java69
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreSSLContext.java112
-rw-r--r--rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DataStoreTrustManager.java153
25 files changed, 0 insertions, 6061 deletions
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientAttributes.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientAttributes.java
deleted file mode 100644
index a03f6c811..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientAttributes.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.client;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.eclipse.dstore.core.model.DataStoreAttributes;
-
-/**
- * ClientAttributes is a container of communication related
- * information.
- */
-public class ClientAttributes extends DataStoreAttributes
-{
-
- /**
- * Constructor
- */
- public ClientAttributes()
- {
- super();
-
- try
- {
- String pluginPath = System.getProperty("A_PLUGIN_PATH"); //$NON-NLS-1$
- if ((pluginPath != null) && (pluginPath.length() > 0))
- {
- setAttribute(A_PLUGIN_PATH, pluginPath + File.separator);
- }
-
- setAttribute(A_LOCAL_NAME, InetAddress.getLocalHost().getHostName());
- setAttribute(A_LOCAL_PATH, "/tmp/"); //$NON-NLS-1$
- setAttribute(A_HOST_NAME, "local"); //$NON-NLS-1$
- setAttribute(A_HOST_PATH, "/"); //$NON-NLS-1$
- }
-
- catch (UnknownHostException e)
- {
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientCommandHandler.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientCommandHandler.java
deleted file mode 100644
index 8071ae40c..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientCommandHandler.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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) [222168][dstore] Buffer in DataElement is not sent
- * David McKnight (IBM) [246826][dstore] KeepAlive does not work correctly
- * David McKnight (IBM) [306853][dstore] RD/z client hang after browse copy book command
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.client;
- import org.eclipse.dstore.core.java.IRemoteClassInstance;
-import org.eclipse.dstore.core.model.CommandHandler;
-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.DataStoreResources;
-import org.eclipse.dstore.internal.core.util.Sender;
-
-
-
-/**
- * The ClientCommandHandler is reponsible for maintaining
- * a queue of commands and periodically sending commands
- * from the queue to the server side.
- */
-public class ClientCommandHandler extends CommandHandler
-{
-
- private Sender _sender;
- protected DataElement _requestClassDocumentElement;
- protected DataElement _keepAliveDocumentElement;
- protected DataElement _confirmKeepAliveDocumentElement;
- protected DataElement _pendingKeepAliveRequest;
- protected DataElement _pendingKeepAliveConfirmation;
-
- private static String[] _docAttributes = {
- DataStoreResources.DOCUMENT_TYPE,
- "client.doc.root.id", //$NON-NLS-1$
- "client.document", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _fileAttributes = {
- DataStoreResources.FILE_TYPE,
- "client.file.root.id", //$NON-NLS-1$
- "client.file", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _classAttributes = {
- DataStoreResources.CLASS_TYPE,
- "client.class.root.id", //$NON-NLS-1$
- "client.class", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _serializeAttributes = {
- DataStoreResources.SERIALIZED_TYPE,
- "client.serialized.root.id", //$NON-NLS-1$
- "client.serialized", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _requestClassAttributes = {
- DataStoreResources.REQUEST_CLASS_TYPE,
- "client.requestclass.root.id", //$NON-NLS-1$
- "client.requestclass", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _keepAliveAttributes = {
- DataStoreResources.KEEPALIVE_TYPE,
- "client.keepalive.root.id", //$NON-NLS-1$
- "server.keepalive", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _confirmKeepAliveAttributes = {
- DataStoreResources.KEEPALIVECONFIRM_TYPE,
- "client.keepalive.confirm.root.id", //$NON-NLS-1$
- "server.confirmkeepalive", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
-
- protected DataElement _fileDocumentElement;
- protected DataElement _docDocumentElement;
- protected DataElement _classDocumentElement;
- protected DataElement _serializedDocumentElement;
-
- /**
- * Constructor
- * @param sender the Sender
- */
- public ClientCommandHandler(Sender sender)
- {
- super();
- _sender = sender;
- }
-
-
- public void setDataStore(DataStore dataStore)
- {
- super.setDataStore(dataStore);
- _fileDocumentElement = dataStore.createTransientObject(_fileAttributes);
- _docDocumentElement = dataStore.createObject(null, _docAttributes);
- _classDocumentElement = dataStore.createTransientObject(_classAttributes);
- _serializedDocumentElement = dataStore.createTransientObject(_serializeAttributes);
- _requestClassDocumentElement = dataStore.createTransientObject(_requestClassAttributes);
- _keepAliveDocumentElement = dataStore.createTransientObject(_keepAliveAttributes);
- _confirmKeepAliveDocumentElement = dataStore.createTransientObject(_confirmKeepAliveAttributes);
- }
-
- /**
- * Transmits the bytes of a file from the client to the server
- * @param bytes the bytes of a file to send
- * @param size the number of bytes to send
- * @param binary indicates whether to send the bytes as binary or unicode
- * @param byteStreamHandlerId indicates wwhich byte stream handler should receive the bytes
- */
- public synchronized void sendFile(String fileName, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
- {
- // send pending commands before file
- if (_commands.size() > 0)
- sendCommands();
-
- //DataElement document = _dataStore.createObject(null, DataStoreResources.FILE_TYPE, byteStreamHandlerId, fileName, fileName);
- DataElement document = _fileDocumentElement;
- document.setAttribute(DE.A_NAME, byteStreamHandlerId);
- document.setAttribute(DE.A_VALUE, byteStreamHandlerId);
- document.setAttribute(DE.A_SOURCE, fileName);
- document.setPendingTransfer(true);
- document.setParent(null);
- _sender.sendFile(document, bytes, size, binary);
- }
-
- /**
- * Transmits the bytes of a file from the client to the server
- * @param bytes the bytes of a file to send
- * @param size the number of bytes to send
- * @param binary indicates whether to send the bytes as binary or unicode
- */
- public synchronized void sendFile(String fileName, byte[] bytes, int size, boolean binary)
- {
- sendFile(fileName, bytes, size, binary, "default"); //$NON-NLS-1$
- }
-
- /**
- * Appends bytes of a file from the client to the server
- * @param bytes the bytes of a file to send
- * @param size the number of bytes to send
- * @param binary indicates whether to send the bytes as binary or unicode
- * @param byteStreamHandlerId indicates which byte stream handler should receive the bytes
- */
- public synchronized void sendAppendFile(String fileName, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
- {
- // send pending commands before file
- if (_commands.size() > 0)
- sendCommands();
-
- //DataElement document = _dataStore.createObject(null, DataStoreResources.FILE_TYPE, byteStreamHandlerId, fileName, fileName);
-
- DataElement document = _fileDocumentElement;
- document.setAttribute(DE.A_NAME, byteStreamHandlerId);
- document.setAttribute(DE.A_VALUE, byteStreamHandlerId);
- document.setAttribute(DE.A_SOURCE, fileName);
- document.setPendingTransfer(true);
- document.setParent(null);
- _sender.sendAppendFile(document, bytes, size, binary);
- }
-
-
- /**
- * Appends bytes of a file from the client to the server
- * @param bytes the bytes of a file to send
- * @param size the number of bytes to send
- * @param binary indicates whether to send the bytes as binary or unicode
- */
- public synchronized void sendAppendFile(String fileName, byte[] bytes, int size, boolean binary)
- {
- sendAppendFile(fileName, bytes, size, binary, "default"); //$NON-NLS-1$
- }
-
- /**
- * Called periodically to send the current queue of commands to the server
- */
- public synchronized void sendCommands()
- {
- //DataElement commandRoot = _dataStore.createObject(null, DataStoreResources.DOCUMENT_TYPE, "client.doc"/*"client.doc." + _requests++*/);
- DataElement commandRoot = _docDocumentElement;
- commandRoot.removeNestedData();
- commandRoot.setPendingTransfer(true);
- commandRoot.setParent(null);
- while (_commands.size() > 0)
- {
- DataElement command = null;
- synchronized (_commands)
- {
- command = (DataElement)_commands.remove(0);
- }
-
- commandRoot.addNestedData(command, false);
- }
-
- _sender.sendDocument(commandRoot, 3);
-
- if (_pendingKeepAliveConfirmation != null)
- {
- _sender.sendKeepAliveConfirmation(_pendingKeepAliveConfirmation);
- _pendingKeepAliveConfirmation = null;
- }
- if (_pendingKeepAliveRequest != null)
- {
- _sender.sendKeepAliveRequest(_pendingKeepAliveRequest);
- _pendingKeepAliveRequest = null;
- }
-
- // finished sending commands, now send all classes that are waiting
- // in the queue
- while (_classesToSend != null && _classesToSend.size() > 0)
- {
- DataElement document = null;
- synchronized (_classesToSend)
- {
- document = (DataElement)_classesToSend.remove(0);
- }
- _sender.sendClass(document);
- }
-
-
- }
-
- public void handle()
- {
- if (!_commands.isEmpty() || _pendingKeepAliveConfirmation != null || _pendingKeepAliveRequest != null || !_classesToSend.isEmpty())
- {
- sendCommands();
- }
- }
-
- /**
- * Implemented to provide the means by which classes are sent
- * across the comm channel.
- * @param className the name of the class to send
- * @param classbyteStreamHandlerId the name of the byte stream handler to use to receive the class
- */
- public synchronized void sendClass(String className, String classbyteStreamHandlerId)
- {
- // send pending commands before sending class
- if (_commands.size() > 0)
- sendCommands();
-
- DataElement document = _classDocumentElement;
- document.setAttribute(DE.A_NAME, className);
- document.setAttribute(DE.A_SOURCE, classbyteStreamHandlerId);
- //document.setAttribute(DE.A_SOURCE, className);
- document.setPendingTransfer(true);
- document.setParent(null);
-
- addClassToSend(document);
- }
-
- /**
- * Implemented to provide the means by which classes are requested and sent
- * across the comm channel.
- * @param className the name of the class to send
- */
- public synchronized void sendClass(String className)
- {
- sendClass(className, "default"); //$NON-NLS-1$
- }
-
- /**
- * Adds a class to the queue of classes (represented by DataElements) to
- * be sent to the server.
- * @param classElement the DataElement representing the class to be sent
- */
- public void addClassToSend(DataElement classElement)
- {
- synchronized (_classesToSend)
- {
- if (!_classesToSend.contains(classElement))
- {
- _classesToSend.add(classElement);
- }
- }
- notifyInput();
- }
-
-
- public synchronized void sendClassInstance(IRemoteClassInstance runnable, String deserializebyteStreamHandlerId)
- {
- // send pending commands before sending class
- if (_commands.size() > 0)
- sendCommands();
-
- DataElement document = _serializedDocumentElement;
- document.setAttribute(DE.A_NAME, runnable.toString());
- document.setAttribute(DE.A_SOURCE, deserializebyteStreamHandlerId);
- document.setPendingTransfer(true);
- document.setParent(null);
-
-
- _sender.sendRemoteClassRunnable(document, runnable);
- }
-
- /**
- * Implemented to provide the means by which classes are requested
- * across the comm channel.
- * @param className the name of the class to request
- */
- public void requestClass(String className)
- {
- DataElement document = _requestClassDocumentElement;
- document.setPendingTransfer(true);
- document.setAttribute(DE.A_NAME, className);
- document.setAttribute(DE.A_VALUE, className);
- document.setParent(null);
-
- _sender.requestClass(document);
- }
-
-
- public void sendKeepAliveConfirmation()
- {
- DataElement document = _confirmKeepAliveDocumentElement;
- document.setPendingTransfer(true);
- document.setAttribute(DE.A_NAME, "confirm"); //$NON-NLS-1$
- document.setAttribute(DE.A_VALUE, "confirm"); //$NON-NLS-1$
- document.setParent(null);
- _pendingKeepAliveConfirmation = document;
-
- handle(); // bypassing threading
- }
-
- public void sendKeepAliveRequest()
- {
- DataElement document = _keepAliveDocumentElement;
- document.setPendingTransfer(true);
- document.setAttribute(DE.A_NAME, "request"); //$NON-NLS-1$
- document.setAttribute(DE.A_VALUE, "request"); //$NON-NLS-1$
- document.setParent(null);
- _pendingKeepAliveRequest = document;
-
- handle(); // bypassing threading
- }
-
- public synchronized void waitForInput()
- {
- if (_commands.size() == 0 && _classesToSend.size() == 0 && _pendingKeepAliveConfirmation == null && _pendingKeepAliveRequest == null)
- {
- super.waitForInput();
- }
- }
-
- /**
- * Indicates whether the xml generator should transfer the buffer attribute of a DataElement
- * @param flag true to transfer the buffer attribute
- */
- public void setGenerateBuffer(boolean flag)
- {
- _sender.setGenerateBuffer(flag);
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientReceiver.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientReceiver.java
deleted file mode 100644
index 8f0b13147..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientReceiver.java
+++ /dev/null
@@ -1,78 +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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.client;
-
-import java.net.Socket;
-
-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.util.Receiver;
-
-/*
- * The ClientReciever is responsible for recieving data from
- * the server side.
- */
-public class ClientReceiver extends Receiver
-{
-
- /**
- * Constructor
- */
- public ClientReceiver(Socket socket, DataStore dataStore)
- {
- super(socket, dataStore);
- }
-
- /**
- * Called when new data is received from the server side.
- * @param documentObject the root object of incoming data
- */
- public void handleDocument(DataElement documentObject)
- {
- if (documentObject.getName().equals("exit")) //$NON-NLS-1$
- {
- _canExit = true;
- }
- else
- {
- synchronized (documentObject)
- {
- for (int i = 0; i < documentObject.getNestedSize(); i++)
- {
- DataElement rootOutput = documentObject.get(i);
- _dataStore.refresh(rootOutput);
- }
- documentObject.removeNestedData();
- //_dataStore.deleteObject(documentObject.getParent(), documentObject);
- }
- }
- }
-
- /**
- * Called when an error occurs
- * @param e the exception that occurred
- */
- public void handleError(Throwable e)
- {
- DataElement status = _dataStore.getStatus();
- status.setAttribute(DE.A_NAME, e.getMessage());
- _dataStore.refresh(status);
- _dataStore.setConnected(false);
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientSSLProperties.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientSSLProperties.java
deleted file mode 100644
index c4df4a8b5..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientSSLProperties.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.client;
-
-import org.eclipse.dstore.core.model.ISSLProperties;
-public class ClientSSLProperties implements ISSLProperties
-{
- private boolean _enableSSL = false;
- private boolean _disableServerSSL = false;
- private String _daemonKeyStorePath;
- private String _daemonKeyStorePassword;
-
- private String _serverKeyStorePath;
- private String _serverKeyStorePassword;
-
- public ClientSSLProperties(boolean enableSSL,
- String daemonKeystore, String daemonPassword,
- String serverKeystore, String serverPassword)
- {
- _enableSSL = enableSSL;
- _daemonKeyStorePath = daemonKeystore;
- _daemonKeyStorePassword = daemonPassword;
- _serverKeyStorePath = serverKeystore;
- _serverKeyStorePassword = serverPassword;
- }
-
- public ClientSSLProperties(boolean enableSSL, boolean disableServerSSL,
- String daemonKeystore, String daemonPassword,
- String serverKeystore, String serverPassword)
- {
- _enableSSL = enableSSL;
- _disableServerSSL = disableServerSSL;
- _daemonKeyStorePath = daemonKeystore;
- _daemonKeyStorePassword = daemonPassword;
- _serverKeyStorePath = serverKeystore;
- _serverKeyStorePassword = serverPassword;
- }
-
- public ClientSSLProperties(boolean enableSSL, String keystore, String password)
- {
- _enableSSL = enableSSL;
- _daemonKeyStorePath = keystore;
- _daemonKeyStorePassword = password;
-
- _serverKeyStorePath = keystore;
- _serverKeyStorePassword = password;
- }
-
- public ClientSSLProperties(boolean enableSSL, boolean disableServerSSL, String keystore, String password)
- {
- _enableSSL = enableSSL;
- _disableServerSSL = disableServerSSL;
- _daemonKeyStorePath = keystore;
- _daemonKeyStorePassword = password;
-
- _serverKeyStorePath = keystore;
- _serverKeyStorePassword = password;
- }
-
-
- public boolean usingSSL()
- {
- return _enableSSL;
- }
-
- public boolean usingServerSSL()
- {
- return !_disableServerSSL;
- }
-
-
- public String getDaemonKeyStorePassword()
- {
- return _daemonKeyStorePassword;
- }
-
- public String getDaemonKeyStorePath()
- {
- return _daemonKeyStorePath;
- }
-
- public String getServerKeyStorePassword()
- {
- return _serverKeyStorePassword;
- }
-
- public String getServerKeyStorePath()
- {
- return _serverKeyStorePath;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientUpdateHandler.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientUpdateHandler.java
deleted file mode 100644
index c873c442c..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/client/ClientUpdateHandler.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.client;
-
-import java.io.File;
-
-import org.eclipse.dstore.core.java.IRemoteClassInstance;
-import org.eclipse.dstore.core.model.DE;
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.core.model.UpdateHandler;
-import org.eclipse.dstore.extra.DomainEvent;
-import org.eclipse.dstore.extra.IDomainNotifier;
-
-/**
- * The ClientUpdateHandler is contains a queue of data update requests
- * and periodically sends out domain notifications to domain listeners
- */
-public class ClientUpdateHandler extends UpdateHandler
-{
-
- /**
- * Constructor
- */
- public ClientUpdateHandler()
- {
- super();
- _waitIncrement = 200;
- }
-
- /**
- * Not applicable - this is only applicable on the server side
- */
- public void updateFile(String path, byte[] bytes, int size, boolean binary)
- {
- }
-
- /**
- * Not applicable - this is only applicable on the server side
- */
- public void updateAppendFile(String path, byte[] bytes, int size, boolean binary)
- {
- }
-
- /**
- * Not applicable - this is only applicable on the server side
- */
- public void updateFile(String path, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
- {
- }
-
- /**
- * Not applicable - this is only applicable on the server side
- */
- public void updateAppendFile(String path, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
- {
- }
-
- /**
- * Notifies domain listeners that a file has been updated
- * @param file the updated file
- * @param object the element associated with the updated file
- */
- public void updateFile(File file, DataElement object)
- {
- IDomainNotifier notifier = _dataStore.getDomainNotifier();
- notifier.fireDomainChanged(new DomainEvent(DomainEvent.FILE_CHANGE, object, DE.P_NESTED));
- }
-
- /**
- * Periodically called to notify domain listeners of updated data from the
- * server
- */
- public void sendUpdates()
- {
- if (_dataStore != null && !isFinished())
- {
- while (_dataObjects.size() > 0)
- {
- DataElement object = null;
- synchronized (_dataObjects)
- {
- if (_dataObjects.size() > 0)
- {
- object = (DataElement) _dataObjects.get(0);
- _dataObjects.remove(object);
- }
- }
-
- if ((object != null))
- {
-
- if (!object.isUpdated() && !object.isDescriptor())
- {
-
- //DataElement parent = object.getParent();
- //System.out.println("notifying "+parent);
- notify(object);
- }
- clean(object);
- }
- }
- }
- }
-
- private void notify(DataElement object)
- {
- if (object.isExpanded())
- {
- object.setUpdated(true);
- }
-
- object.setExpanded(true);
-
- IDomainNotifier notifier = _dataStore.getDomainNotifier();
-
- if (object.getNestedSize() == 0)
- {
- notifier.fireDomainChanged(new DomainEvent(DomainEvent.NON_STRUCTURE_CHANGE, object, DE.P_NESTED));
-
- }
- else
- {
- notifier.fireDomainChanged(new DomainEvent(DomainEvent.INSERT, object, DE.P_NESTED));
- }
- }
-
- /**
- * Implemented to provide the means by which classes are requested
- * across the comm channel. (Only applies to ServerUpdateHandler, so is a dummy method here)
- * @param className the name of the class to request
- */
- public void requestClass(String className)
- {
- }
-
- /**
- * Impleted to provide the means by which a class on the host is updated on the client
- * @param runnable
- * @param deserializebyteStreamHandlerId
- */
- public synchronized void updateClassInstance(IRemoteClassInstance runnable, String deserializebyteStreamHandlerId)
- {
- notifyInput();
- }
-
- /**
- * Does not apply in this case. Use ClientCommandHandler.sendClass().
- */
- public void sendClass(String className, String classByteStreamHandlerId)
- {
- }
-
- /**
- * Does not apply in this case. Use ClientCommandHandler.sendClass().
- */
- public void sendClass(String className)
- {
- }
-
- /**
- * Does not apply in this case. Use ClientCommandHandler.sendKeepAliveRequest().
- */
- public void sendKeepAliveRequest()
- {
- }
-
- /**
- * Does not apply in this case. Use ClientCommandHandler.sendKeepAliveConfirmation().
- */
- public void sendKeepAliveConfirmation()
- {
- }
-
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/model/DefaultByteConverter.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/model/DefaultByteConverter.java
deleted file mode 100644
index 2b56aa9ea..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/model/DefaultByteConverter.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.model;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.dstore.core.model.DE;
-import org.eclipse.dstore.core.model.IByteConverter;
-
-/**
- * @author dmcknigh
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class DefaultByteConverter implements IByteConverter
-{
- private String _clientEncoding = DE.ENCODING_UTF_8;
- private String _hostEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
- public void setContext(File file)
- {
- }
-
- public void setHostEncoding(String hostEncoding)
- {
- _hostEncoding = hostEncoding;
- }
-
- public void setClientEncoding(String clientEncoding)
- {
- _clientEncoding = clientEncoding;
- }
-
- public byte[] convertHostBytesToClientBytes(byte[] buffer, int offset, int length)
- {
- byte[] convertedBytes =null;
- try
- {
- convertedBytes = (new String(buffer, offset, length, _hostEncoding)).getBytes(_clientEncoding);
- }
- catch (UnsupportedEncodingException e)
- {
- try
- {
- convertedBytes = (new String(buffer, offset, length)).getBytes(_clientEncoding);
- }
- catch (UnsupportedEncodingException e2)
- {
- return buffer;
- }
- }
-
- return convertedBytes;
- }
-
- public byte[] convertClientBytesToHostBytes(byte[] buffer, int offset, int length)
- {
- byte[] convertedBytes = null;
-
- try
- {
- convertedBytes = (new String(buffer, offset, length, _clientEncoding)).getBytes(_hostEncoding);
- }
- catch (UnsupportedEncodingException e)
- {
- try
- {
- convertedBytes = (new String(buffer, offset, length)).getBytes(_hostEncoding);
- }
- catch (UnsupportedEncodingException e2)
- {
- return buffer;
- }
- }
-
- return convertedBytes;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/model/SchemaRegistry.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/model/SchemaRegistry.java
deleted file mode 100644
index 73375a26e..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/model/SchemaRegistry.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.model;
-
-import java.util.ArrayList;
-
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.core.model.DataStore;
-import org.eclipse.dstore.core.model.IExternalLoader;
-import org.eclipse.dstore.core.model.ISchemaExtender;
-import org.eclipse.dstore.core.model.ISchemaRegistry;
-
-/**
- * SchemaRegistry implements the interface for external tools to contribute their
- * schemas to the DataStore.
- */
-public class SchemaRegistry implements ISchemaRegistry
-{
-
-
- private ArrayList _initializedDataStores = new ArrayList();
- private ArrayList _extenders = new ArrayList();
-
- /**
- * Registers a schema extender with the associated DataStores
- * @param extender the schema extender to register
- */
- public void registerSchemaExtender(ISchemaExtender extender)
- {
- if (!_extenders.contains(extender))
- {
- _extenders.add(extender);
- for (int i = 0; i < _initializedDataStores.size(); i++)
- {
- DataStore dataStore = (DataStore) _initializedDataStores.get(i);
- DataElement schemaRoot = dataStore.getDescriptorRoot();
- extender.extendSchema(schemaRoot);
- }
- }
- }
-
- /**
- * Calls extendSchema() on each of the registered schema extenders to
- * extend the schema of the specified DataStore
- *
- * @param dataStore the DataStore whos schema will be updated
- */
- public void extendSchema(DataStore dataStore)
- {
- if (!_initializedDataStores.contains(dataStore))
- {
- DataElement schemaRoot = dataStore.getDescriptorRoot();
- for (int i = 0; i < _extenders.size(); i++)
- {
- ISchemaExtender extender = (ISchemaExtender) _extenders.get(i);
- extender.extendSchema(schemaRoot);
- }
- _initializedDataStores.add(dataStore);
- }
- }
-
- /**
- * Gets the <code>ExternalLoader</code> for the specified qualified classname
- *
- * @param source the qualified classname
- * @return the external loader for the specified classname
- */
- public IExternalLoader getLoaderFor(String source)
- {
- for (int i = 0; i < _extenders.size(); i++)
- {
- ISchemaExtender extender = (ISchemaExtender) _extenders.get(i);
- IExternalLoader loader = extender.getExternalLoader();
- if (loader.canLoad(source))
- {
- return loader;
- }
- }
- return null;
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/MinerLoader.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/MinerLoader.java
deleted file mode 100644
index 94ca939a3..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/MinerLoader.java
+++ /dev/null
@@ -1,426 +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
- *
- * 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) - [244388] [dstore] Connection hangs when a miner not installed
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.server;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-
-import org.eclipse.dstore.core.java.RemoteClassLoader;
-import org.eclipse.dstore.core.miners.Miner;
-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.IExternalLoader;
-import org.eclipse.dstore.core.model.ISchemaExtender;
-import org.eclipse.dstore.core.model.ISchemaRegistry;
-import org.eclipse.dstore.internal.core.util.ExternalLoader;
-
-/**
- * MinerLoader is an implementation of <code>ISchemaRegistry</code> used for
- * loading and initializing miners.
- */
-public class MinerLoader implements ISchemaRegistry
-{
-
-
- private DataStore _dataStore;
- private ArrayList _miners;
- private ArrayList _minerList;
- private ArrayList _minerFileList;
- private ArrayList _connectedList;
- private ArrayList _loaders;
- private RemoteClassLoader _remoteLoader;
- private ExternalLoader _externalRemoteLoader;
-
- /**
- * Constructor
- *
- * @param dataStore the associated DataStore
- * @param loaders the list of <code>ExternalLoader</code>s used be the miner loader
- */
- public MinerLoader(DataStore dataStore, ArrayList loaders)
- {
- _dataStore = dataStore;
- _loaders = loaders;
- _miners = new ArrayList();
- _minerList = new ArrayList();
- _minerFileList = new ArrayList();
- _connectedList = new ArrayList();
- }
-
- /**
- * Loads all miners that are specified in the default <i>minerFile.dat</i> as
- * well as any others indicated by <code>DataStore.getMinersLocation</code> that
- * have not yet been loaded.
- */
- public void loadMiners()
- {
- // load the miners
- String pluginDir = _dataStore.getAttribute(DataStoreAttributes.A_PLUGIN_PATH);
-
- // default location
- String defaultMinerFile = pluginDir + File.separator + "minerFile.dat"; //$NON-NLS-1$
- File defaultMF = new File(defaultMinerFile);
- if (defaultMF.exists())
- {
- try
- {
- loadMiners(defaultMinerFile, DE.ENCODING_UTF_8);
- }
- catch (Exception e)
- {
- _dataStore.trace("failed to load minerFile.data with UTF-8. Trying with native encoding"); //$NON-NLS-1$
-
- try
- {
- loadMiners(defaultMinerFile, null);
- }
- catch (Exception ex)
- {
- _dataStore.trace(ex);
- }
- }
- _minerFileList.add(defaultMinerFile);
- }
-
- ArrayList minerLocations = _dataStore.getMinersLocation();
-
- for (int i = 0; i < minerLocations.size(); i++)
- {
- String minersDir = (String) minerLocations.get(i);
- String minerFile = null;
- if (minersDir.endsWith(".dat")) //$NON-NLS-1$
- {
- minerFile = pluginDir + File.separator + minersDir;
- }
- else
- {
- minerFile = pluginDir + File.separator + minersDir + File.separator + "minerFile.dat"; //$NON-NLS-1$
- }
- //_dataStore.trace("load miners for " + minerFile);
- if (!_minerFileList.contains(minerFile))
- {
- try
- {
- loadMiners(minerFile, DE.ENCODING_UTF_8);
- }
- catch (Exception e)
- {
- _dataStore.trace("failed to load minerFile.data with UTF-8. Trying with native encoding"); //$NON-NLS-1$
- try
- {
- loadMiners(minerFile, null);
- }
- catch (Exception ex)
- {
- _dataStore.trace(ex);
- }
- }
- _minerFileList.add(minerFile);
- }
- }
- }
-
- /**
- * Loads that miners specified in a particular miner configuration file (i.e. <i>minerFile.dat</i>)
- * @param minerFile a file specifying a list of miners
- * @return a list of the loaded miners
- */
- public ArrayList loadMiners(String minerFile, String encoding) throws Exception
- {
- // load the miners
- ArrayList unconnectedMiners = new ArrayList();
- File file = new File(minerFile);
-
- FileInputStream inFile = new FileInputStream(file);
- BufferedReader in = null;
- if (encoding == null)
- {
- in = new BufferedReader(new InputStreamReader(inFile));
- }
- else
- {
- in = new BufferedReader(new InputStreamReader(inFile, encoding));
- }
-
- String name = null;
- while ((name = in.readLine()) != null)
- {
- // check name
- name = name.trim();
-
- if (!name.startsWith("#") && (name.length() > 5)) //$NON-NLS-1$
- {
- Miner miner = loadMiner(name);
- if (miner != null)
- {
- unconnectedMiners.add(miner);
- }
- }
- }
-
- connectMiners(unconnectedMiners);
- return _miners;
- }
-
-
-
- public Miner loadMiner(String name)
- {
- Miner miner = null;
- if (!_minerList.contains(name))
- {
- // only load new miners
- try
- {
- IExternalLoader loader = getLoaderFor(name);
- if (loader != null)
- {
- // try to load and instantiate the miner
- // the RemoteClassLoader will kick off a synchronous
- // request to the client for any classes that cannot be found
- // on the host.
- Class theClass = loader.loadClass(name);
- miner = (Miner) theClass.newInstance();
- if (miner != null)
- {
- miner.setExternalLoader(loader);
- _minerList.add(name);
- }
- else {
- System.out.println("miner is null"); //$NON-NLS-1$
- }
- }
- }
- catch (NoClassDefFoundError e)
- {
- e.printStackTrace();
- handleNoClassFound(e.getMessage().replace('/','.'));
- }
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- handleNoClassFound(name);
- }
- catch (InstantiationException e)
- {
- e.printStackTrace();
- }
- catch (IllegalAccessException e)
- {
- e.printStackTrace();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- }
- return miner;
- }
-
- private void handleNoClassFound(String name)
- {
- if (_remoteLoader != null){
- _remoteLoader.loadClassInThread(name);
- }
- }
-
- private void connectMiners(ArrayList unconnectedMiners)
- {
- // init list
- for (int i = 0; i < _miners.size(); i++)
- {
- _connectedList.add(((Miner) _miners.get(i)).getMinerName());
- }
-
- while (unconnectedMiners.size() > 0)
- {
- Miner miner = (Miner) unconnectedMiners.get(0);
- unconnectedMiners.remove(miner);
- if (connectMiner(miner))
- {
- _dataStore.trace("connected " + miner.getMinerName()); //$NON-NLS-1$
- }
- else
- {
- unconnectedMiners.add(miner);
- }
- }
-
- }
-
- public boolean connectMiner(Miner miner)
- {
- boolean canConnect = true;
- ArrayList dependencies = miner.getMinerDependencies();
- for (int i = 0; i < dependencies.size(); i++)
- {
- String dependency = (String) dependencies.get(i);
- if (!_connectedList.contains(dependency))
- {
- canConnect = false;
- }
- }
-
- if (canConnect)
- {
- // set the datastore for the miner
- miner.setDataStore(_dataStore);
- miner.extendSchema(_dataStore.getDescriptorRoot());
- _dataStore.refresh(_dataStore.getDescriptorRoot());
- _miners.add(miner);
- _connectedList.add(miner.getMinerName());
- miner.start();
- }
- return canConnect;
- }
-
- /**
- * Currently not used for the miner loader
- */
- public void registerSchemaExtender(ISchemaExtender extender)
- {
- }
-
- /**
- * Calls <code>extendSchema</code> on each of the loaded miners
- *
- * @param dataStore the DataStore containing the base schema to extend
- */
- public void extendSchema(DataStore dataStore)
- {
- DataElement schemaRoot = dataStore.getDescriptorRoot();
- for (int i = 0; i < _miners.size(); i++)
- {
- Miner miner = (Miner) _miners.get(i);
- miner.extendSchema(schemaRoot);
- }
-
- }
-
- public ExternalLoader getExternalRemoteLoader()
- {
- if (_externalRemoteLoader == null)
- {
- _externalRemoteLoader = new ExternalLoader(getRemoteLoader(), "*"); //$NON-NLS-1$
- }
- return _externalRemoteLoader;
- }
-
- public RemoteClassLoader getRemoteLoader()
- {
- return _dataStore.getRemoteClassLoader();
- }
-
- /**
- * Returns the <code>ExternalLoader</code> for a particular
- * class.
- *
- * @param source a qualified classname
- * @return the loader for the specified class
- */
- public IExternalLoader getLoaderFor(String source)
- {
- ExternalLoader remoteLoader = getExternalRemoteLoader();
-
- // for now we always return the RemoteClassLoader
-
- //if (remoteLoader.canLoad(source))
- if(true)
- {
- //System.out.println("using RemoteClassLoader");
- return remoteLoader;
- }
-
- for (int i = 0; i < _loaders.size(); i++)
- {
- ExternalLoader loader = (ExternalLoader) _loaders.get(i);
- if (loader.canLoad(source))
- {
- // System.out.println("using local loader");
- return loader;
- }
- else
- {
- }
- }
-
- return null;
- }
-
- /**
- * Returns the loaded miners
- *
- * @return the loaded miners
- */
- public ArrayList getMiners()
- {
- return _miners;
- }
-
- /**
- * Returns the miner indicated with the specified name
- *
- * @param name the qualified classname of the miner
- * @return the miner
- */
- public Miner getMiner(String name)
- {
- for (int i = 0; i < _miners.size(); i++)
- {
- Miner miner = (Miner) _miners.get(i);
- if (miner.getClass().getName().equals(name))
- {
- return miner;
- }
- }
-
- return null;
- }
-
- /**
- * Terminates the specified miner
- *
- * @param name the qualified classname of the miner to terminate
- */
- public void finishMiner(String name)
- {
- Miner miner = getMiner(name);
- miner.finish();
- _miners.remove(miner);
- }
-
- /**
- * Terminate all the miners
- */
- public void finishMiners()
- {
- for (int i = 0; i < _miners.size(); i++)
- {
- Miner miner = (Miner) _miners.get(i);
- miner.finish();
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerAttributes.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerAttributes.java
deleted file mode 100644
index 6b0fa84fe..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerAttributes.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.server;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.eclipse.dstore.core.model.DataStoreAttributes;
-
-/**
- * This class is used to store attributes that are required
- * for configurating a remote connection.
- */
-public class ServerAttributes extends DataStoreAttributes
-{
-
- /**
- * Constructor
- */
- public ServerAttributes()
- {
- super();
-
- try
- {
- String pluginPath = System.getProperty("A_PLUGIN_PATH"); //$NON-NLS-1$
- if (pluginPath != null) pluginPath = pluginPath.trim();
- if ((pluginPath != null) && (pluginPath.length() > 0))
- {
- File f = new File(pluginPath);
- try
- {
- pluginPath = f.getCanonicalPath();
- }
- catch (Exception e)
- {
- pluginPath = f.getAbsolutePath();
- }
-
- setAttribute(A_PLUGIN_PATH, pluginPath + File.separator);
- }
- else
- {
- setAttribute(A_PLUGIN_PATH, "/home/"); //$NON-NLS-1$
- }
-
- setAttribute(A_LOCAL_NAME, InetAddress.getLocalHost().getHostName());
-
- setAttribute(A_HOST_NAME, "server_host"); //$NON-NLS-1$
- setAttribute(A_HOST_PATH, "/home/"); //$NON-NLS-1$
- }
- catch (UnknownHostException e)
- {
- }
-
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerCommandHandler.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerCommandHandler.java
deleted file mode 100644
index 34b100ab7..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerCommandHandler.java
+++ /dev/null
@@ -1,590 +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
- *
- * 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) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
- * David McKnight (IBM) - [244388] [dstore] Connection hangs when a miner not installed
- * David McKnight (IBM) - [278341] [dstore] Disconnect on idle causes the client hang
- * Noriaki Takatsu (IBM) - [283656] [dstore][multithread] Serviceability issue
- * David McKnight (IBM) - [294933] [dstore] RSE goes into loop
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.server;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.dstore.core.java.IRemoteClassInstance;
-import org.eclipse.dstore.core.miners.Miner;
-import org.eclipse.dstore.core.model.CommandHandler;
-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.DataStoreResources;
-import org.eclipse.dstore.core.model.DataStoreSchema;
-import org.eclipse.dstore.core.model.IDataStoreConstants;
-import org.eclipse.dstore.core.server.SystemServiceManager;
-
-/**
- * The ServerCommandHandler is reponsible for maintaining
- * a queue of commands and periodically routing commands
- * from the queue to the appropriate miners.
- */
-public class ServerCommandHandler extends CommandHandler
-{
- public class ServerIdleThread extends Thread
- {
- private long _timeout;
- private boolean _serverTimedOut = false;
-
- public ServerIdleThread(long timeout)
- {
- _timeout = timeout;
- }
-
- public void run()
- {
- while (!_serverTimedOut)
- {
- waitForTimeout();
- }
- if (_serverTimedOut)
- {
- _dataStore.getCommandHandler().finish();
- _dataStore.getUpdateHandler().finish();
- _dataStore.finish();
- System.out.println(ServerReturnCodes.RC_FINISHED);
- if (_dataStore.getClient() != null) {
- _dataStore.getClient().getLogger().logInfo(this.getClass().toString(), "Server timeout");
- }
-
- // only exit if there's no service manager
- if (SystemServiceManager.getInstance().getSystemService() == null){
- System.exit(0);
- }
- else {
- _dataStore.getClient().disconnectServerReceiver();
- }
- }
- }
-
- protected synchronized void waitForTimeout()
- {
- try
- {
- wait(_timeout);
- }
- catch (InterruptedException e)
- {
- // whenver a new command comes through we interrupt this
- // if we do timeout then it's time to shutdown the server
- return;
- }
- _serverTimedOut = true;
- }
-
- }
-
-
- private ArrayList _loaders;
- private MinerLoader _minerLoader;
- private ServerIdleThread _serverIdleThread;
-
- /**
- * Constructor
- *
- * @param loaders a list of <code>ExternalLoader</code>s used for loading miners
- */
- public ServerCommandHandler(ArrayList loaders)
- {
- super();
- _loaders = loaders;
- }
-
- /**
- * Sets the associated DataStore
- *
- * @param dataStore the associated DataStore
- */
- public void setDataStore(DataStore dataStore)
- {
- super.setDataStore(dataStore);
- }
-
- /**
- * Loads the miners
- */
- public void loadMiners()
- {
- if (_dataStore != null)
- {
- if (_minerLoader == null)
- {
- _minerLoader = new MinerLoader(_dataStore, _loaders);
- }
- // load the miners
- _minerLoader.loadMiners();
-
- }
- }
-
- public Miner loadMiner(String minerId)
- {
-
- if (_dataStore != null)
- {
- if (_minerLoader == null)
- {
- _minerLoader = new MinerLoader(_dataStore, _loaders);
- }
-
- _dataStore.trace("loading "+minerId); //$NON-NLS-1$
- // load and connect the miner
- Miner miner = _minerLoader.loadMiner(minerId);
- if (miner != null)
- {
- _minerLoader.connectMiner(miner);
- }
- return miner;
- }
- return null;
- }
-
- /**
- * Returns the list of loaded miners
- *
- * @return the list of miners
- */
- public ArrayList getMiners()
- {
- return _minerLoader.getMiners();
- }
-
- /**
- * Returns the specified miner
- *
- * @param name the qualified classname of the miner to return
- * @return the miner
- */
- public Miner getMiner(String name)
- {
- return _minerLoader.getMiner(name);
- }
-
- /**
- * Terminates a specified miner
- *
- * @param name the qualified classname of the miner to terminate
- */
- public void finishMiner(String name)
- {
- _minerLoader.finishMiner(name);
- }
-
- /**
- * Called when the DataStore session is finished or when there is
- * an unexpected error.
- */
- public void finish()
- {
- if (_minerLoader != null)
- _minerLoader.finishMiners();
- super.finish();
- }
-
- private void clearDeleted(DataElement element, int depth)
- {
- if (depth > 0 && element != null)
- {
- for (int i = 0; i < element.getNestedSize(); i++)
- {
- DataElement child = element.get(i);
- if (child != null)
- {
- if (child.isReference())
- child = child.dereference();
-
-
- if (child != null)
- {
- if (child.isDeleted())
- {
- element.removeNestedData(child);
- }
- else
- {
- clearDeleted(child, depth - 1);
- }
- }
- }
- }
- }
- }
-
-
- /**
- * Called periodically to route the current queue of commands to the appropriate miners
- */
- public void sendCommands()
- {
- // send commands to the appropriate miners
- while (_commands.size() > 0)
- {
- DataElement command = null;
-
- synchronized (_commands)
- {
- command = (DataElement) _commands.get(0);
- clearDeleted(command, 2);
- _commands.remove(command);
- }
-
- //DKM-status is always last
- DataElement status = command.get(command.getNestedSize() - 1);
- //_dataStore.find(command, DE.A_TYPE,DataStoreResources.model_status"), 1);
-
- String commandSource = command.getSource();
- String commandName = command.getName();
- _dataStore.trace(commandName);
-
- if (commandName.equals(DataStoreSchema.C_VALIDATE_TICKET))
- {
- DataElement serverTicket = _dataStore.getTicket();
- DataElement clientTicket = command.get(0);
- String st = serverTicket.getName();
- String ct = clientTicket.getName();
-
- if (st == null || (ct != null && ct.equals(st)))
- {
- serverTicket.setAttribute(DE.A_VALUE,DataStoreResources.model_valid);
- clientTicket.setAttribute(DE.A_VALUE,DataStoreResources.model_valid);
-
- DataElement host = _dataStore.getHostRoot();
- HashMap map = _dataStore.getHashMap();
- synchronized (map){
- map.remove(host.getId());
- }
- host.setAttribute(DE.A_ID, "host." + serverTicket.getName()); //$NON-NLS-1$
-
- synchronized (map){
- map.put(host.getId(), host);
- }
- _dataStore.update(host);
- }
- else
- {
- serverTicket.setAttribute(DE.A_VALUE,DataStoreResources.model_invalid);
- clientTicket.setAttribute(DE.A_VALUE,DataStoreResources.model_invalid);
- }
- _dataStore.update(clientTicket);
- _dataStore.startDataElementRemoverThread();
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_SET))
- {
- //DataElement dataObject = command.get(0);
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_MODIFY))
- {
- DataElement dataObject = command.get(0);
- DataElement original = _dataStore.find(dataObject.getId());
- original.setAttributes(dataObject.getAttributes());
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_SET_HOST))
- {
- DataElement dataObject = command.get(0);
-
- DataElement original = _dataStore.getHostRoot();
- original.setAttributes(dataObject.getAttributes());
-
- _dataStore.setAttribute(DataStoreAttributes.A_LOCAL_PATH, dataObject.getSource());
- _dataStore.setAttribute(DataStoreAttributes.A_HOST_PATH, dataObject.getSource());
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_ADD_MINERS))
- {
- DataElement location = command.get(1);
- _dataStore.addMinersLocation(location);
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_ACTIVATE_MINER))
- {
- DataElement minerId = command.get(0);
- String minerName = minerId.getName();
- Miner miner = loadMiner(minerName);
- if (miner != null){
- miner.initMiner(status);
- }
- else { // failed to load miner
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- status.setAttribute(DE.A_VALUE, DataStoreResources.model_failed);
- }
- //System.out.println("finished initing "+miner.getMinerName());
- //status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_SET_PREFERENCE))
- {
- DataElement dataObject = command.get(0);
- String property = dataObject.getName();
- String value = dataObject.getValue();
- _dataStore.setPreference(property, value);
- }
- else if (commandName.equals(DataStoreSchema.C_QUERY_INSTALL))
- {
- // determine where dstore is located
- status.setAttribute(DE.A_SOURCE, _dataStore.getAttribute(DataStoreAttributes.A_PLUGIN_PATH));
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_QUERY_CLIENT_IP))
- {
- // determine where dstore is connected to
- status.setAttribute(DE.A_SOURCE, _dataStore.getRemoteIP());
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_QUERY_JVM))
- {
- // get jvm stats
- // check memory consuption
- // if we're running low, try to free some
- Runtime runtime = Runtime.getRuntime();
- runtime.gc();
- long freeMem = runtime.freeMemory();
- long totalMem = runtime.totalMemory();
- long maxMem = runtime.maxMemory();
-
-
- StringBuffer statsBuffer = new StringBuffer();
- statsBuffer.append(freeMem);
- statsBuffer.append(',');
- statsBuffer.append(totalMem);
- statsBuffer.append(',');
- statsBuffer.append(maxMem);
- statsBuffer.append(',');
- statsBuffer.append(_dataStore.getNumElements());
- statsBuffer.append(',');
-
- // last 7 dataelements created
- List lastCreated = _dataStore.getLastCreatedElements();
- for (int i = 0; i < lastCreated.size(); i++)
- {
- DataElement element = (DataElement)lastCreated.get(i);
- statsBuffer.append(element.getName());
- statsBuffer.append(":"); //$NON-NLS-1$
- statsBuffer.append("id="+element.getId()); //$NON-NLS-1$
- statsBuffer.append(";"); //$NON-NLS-1$
- }
-
-
- status.setAttribute(DE.A_SOURCE, statsBuffer.toString());
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(DataStoreSchema.C_SCHEMA))
- {
- loadMiners();
-
- DataElement schemaRoot = _dataStore.getDescriptorRoot();
-
- // update all descriptor objects
- _dataStore.refresh(schemaRoot);
- status.setAttribute(DE.A_NAME,DataStoreResources.model_done);
- }
- else if (commandName.equals(IDataStoreConstants.C_START_SPIRIT))
- {
- _dataStore.receiveStartSpiritCommand();
- status.setAttribute(DE.A_NAME, DataStoreResources.model_done);
- }
- else if (_dataStore.validTicket() && _minerLoader != null)
- {
- if (status != null)
- {
- boolean failure = false;
- ArrayList miners = _minerLoader.getMiners();
- for (int j = 0;(j < miners.size()) && !failure; j++)
- {
- Miner miner = (Miner) miners.get(j);
-
- if (commandSource.equals("*") || commandSource.equals(miner.getClass().getName())) //$NON-NLS-1$
- {
- if (_dataStore.isAutoRefreshOn())
- {
- _dataStore.enableAutoRefresh(false);
- }
- /*
- status = miner.command(command);
-
- if ((status != null) && status.getAttribute(DE.A_NAME).equals(DataStoreResources.model_incomplete))
- {
- failure = true;
- }
- */
- miner.requestCommand(command);
-
-
-
- }
-
- }
- if (commandName.equals(DataStoreSchema.C_INIT_MINERS))
- {
- // old way was to submit this command for all miners at once
- // now we wait til activateMiner call is made per each miner
- // for backward compatibility, we still call init miners
- // so we need to make sure, in cases were miners are loaded dynamically,
- // that we set this to done if there's no miners to init
- status.setAttribute(DE.A_NAME, DataStoreResources.model_done);
- }
- }
-
- }
-
- _dataStore.refresh(status);
-
- }
- }
-
- /**
- * Set the contents of a file with the specified file
- * @param fileName the name of the target file
- * @param file the source file
- */
- public void sendFile(String fileName, File file)
- {
- //_dataStore.saveFile(fileName, file);
- }
-
- /**
- * Sets the contents of a file with bytes sent from the client
- * @param fileName the name of the file to append to
- * @param bytes the bytes of a file to insert
- * @param size the number of bytes to insert
- * @param binary indicates whether to insert the bytes as binary or unicode
- */
- public void sendFile(String fileName, byte[] bytes, int size, boolean binary)
- {
- sendFile(fileName, bytes, size, binary, "default"); //$NON-NLS-1$
- }
-
-/**
- * Sets the contents of a file with bytes sent from the client
- * @param fileName the name of the file to append to
- * @param bytes the bytes of a file to insert
- * @param size the number of bytes to insert
- * @param binary indicates whether to insert the bytes as binary or unicode
- * @param byteStreamHandlerId indicates which byte stream handler should receive the bytes
- */
- public void sendFile(String fileName, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
- {
- _dataStore.saveFile(fileName, bytes, size, binary, byteStreamHandlerId);
- }
-
- /**
- * Appends bytes sent from the client to a file
- * @param fileName the name of the file to append to
- * @param bytes the bytes of a file to append
- * @param size the number of bytes to append
- * @param binary indicates whether to append the bytes as binary or unicode
- */
- public void sendAppendFile(String fileName, byte[] bytes, int size, boolean binary)
- {
- sendAppendFile(fileName, bytes, size, binary, "default"); //$NON-NLS-1$
- }
-
- /**
- * Appends bytes sent from the client to a file
- * @param fileName the name of the file to append to
- * @param bytes the bytes of a file to append
- * @param size the number of bytes to append
- * @param binary indicates whether to append the bytes as binary or unicode
- * @param byteStreamHandlerId indicates which byte stream handler should receive the bytes
- */
- public void sendAppendFile(String fileName, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
- {
- _dataStore.appendToFile(fileName, bytes, size, binary);
- }
-
- /**
- * Implemented to provide the means by which classes are requested and sent
- * across the comm channel.
- * @param className the name of the class to request
- */
- public synchronized void sendClass(String className)
- {
- sendClass(className, "default"); //$NON-NLS-1$
- }
-
- /**
- * Implemented to provide the means by which classes are requested and sent
- * across the comm channel.
- * @param className the name of the class to request
- */
- public synchronized void sendClass(String className, String classByteStreamHandlerId)
- {
- //_dataStore.sendClass(className, classByteStreamHandlerId);
- }
-
- public void sendClassInstance(IRemoteClassInstance runnable, String classByteStreamHandlerId)
- {
- notifyInput();
- }
-
- /**
- * Does not apply to server. Use ServerUpdateHandler.requestClass().
- */
- public void requestClass(String className)
- {
- }
-
- /**
- * Does not apply to server. Use ServerUpdateHandler.sendKeepAliveConfirmation().
- */
- public void sendKeepAliveConfirmation()
- {
- }
-
- /**
- * Does not apply to server. Use ServerUpdateHandler.sendKeepAliveRequest().
- */
- public void sendKeepAliveRequest()
- {
- }
-
-
- /**
- * Overridden so that ServerIdleThread knows when new commands are received
- */
- public void addCommand(DataElement command, boolean immediate)
- {
- super.addCommand(command, immediate);
-
- int serverIdleShutdownTimeout = _dataStore.getServerIdleShutdownTimeout();
- if (serverIdleShutdownTimeout > 0)
- {
- if (_serverIdleThread != null)
- {
- // new command so restart timeout
- _serverIdleThread.interrupt();
- }
- else
- {
- _serverIdleThread = new ServerIdleThread(serverIdleShutdownTimeout);
- _serverIdleThread.start();
- }
- }
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerReturnCodes.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerReturnCodes.java
deleted file mode 100644
index 3b9ceaccf..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerReturnCodes.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.server;
-
-/**
- * This class contains a list of server return codes that are used
- * to negociate server communication with a client
- */
-public class ServerReturnCodes
-{
- public static final String RC_DSTORE_SERVER_MAGIC = "DStore Server Starting..."; //$NON-NLS-1$
-
- public static final String RC_SUCCESS = "Server Started Successfully"; //$NON-NLS-1$
-
- public static final String RC_UNKNOWN_HOST_ERROR = "Unknown host error"; //$NON-NLS-1$
- public static final String RC_BIND_ERROR = "Error binding socket"; //$NON-NLS-1$
- public static final String RC_GENERAL_IO_ERROR = "General IO error creating socket"; //$NON-NLS-1$
- public static final String RC_CONNECTION_ERROR = "Connection error"; //$NON-NLS-1$
-
- public static final String RC_SECURITY_ERROR = "Security error creating socket"; //$NON-NLS-1$
-
- public static final String RC_FINISHED = "Server Finished"; //$NON-NLS-1$
-
- public static final String RC_JRE_VERSION_ERROR = "JRE 1.4 or higher required"; //$NON-NLS-1$
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerSSLProperties.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerSSLProperties.java
deleted file mode 100644
index 0e4089921..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerSSLProperties.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.server;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.dstore.core.model.ISSLProperties;
-
-
-public class ServerSSLProperties implements ISSLProperties
-{
- private boolean _enableSSL = false;
- private boolean _disableServerSSL = false;
-
- private String _daemonKeyStorePath;
- private String _daemonKeyStorePassword;
-
- private String _serverKeyStorePath;
- private String _serverKeyStorePassword;
-
-
- private static final String ENABLE_SSL = "enable_ssl"; //$NON-NLS-1$
- private static final String DISABLE_SERVER_SSL = "disable_server_ssl"; //$NON-NLS-1$
-
- private static final String DAEMON_KEYSTORE_FILE = "daemon_keystore_file"; //$NON-NLS-1$
- private static final String DAEMON_KEYSTORE_PASSWORD = "daemon_keystore_password"; //$NON-NLS-1$
-
- private static final String SERVER_KEYSTORE_FILE = "server_keystore_file"; //$NON-NLS-1$
- private static final String SERVER_KEYSTORE_PASSWORD = "server_keystore_password"; //$NON-NLS-1$
-
-
- public ServerSSLProperties()
- {
- try
- {
- ResourceBundle properties = ResourceBundle.getBundle("ssl"); //$NON-NLS-1$
- _enableSSL = properties.getString(ENABLE_SSL).trim().equals("true"); //$NON-NLS-1$
- if (_enableSSL)
- {
- try
- {
- _disableServerSSL = properties.getString(DISABLE_SERVER_SSL).trim().equals("true"); //$NON-NLS-1$
- }
- catch (Exception e)
- {
-
- }
-
- try
- {
- _daemonKeyStorePath = properties.getString(DAEMON_KEYSTORE_FILE).trim();
- _daemonKeyStorePassword = properties.getString(DAEMON_KEYSTORE_PASSWORD).trim();
- }
- catch (Exception e)
- {
- }
-
- if (!_disableServerSSL)
- {
- try
- {
- _serverKeyStorePath = properties.getString(SERVER_KEYSTORE_FILE).trim();
- _serverKeyStorePassword = properties.getString(SERVER_KEYSTORE_PASSWORD).trim();
- }
- catch (Exception e)
- {
- }
- }
-
- if (_daemonKeyStorePath == null && _serverKeyStorePath != null)
- {
- _daemonKeyStorePath = _serverKeyStorePath;
- _daemonKeyStorePassword = _serverKeyStorePassword;
- }
- if (!_disableServerSSL && _serverKeyStorePath == null && _daemonKeyStorePath != null)
- {
- _serverKeyStorePath = _daemonKeyStorePath;
- _serverKeyStorePassword = _daemonKeyStorePassword;
- }
-
- }
-
- if (_enableSSL)
- {
- System.out.println("SSL Settings"); //$NON-NLS-1$
- System.out.println("[daemon keystore:\t"+_daemonKeyStorePath+"]"); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("[daemon keystore pw:\t"+_daemonKeyStorePassword+"]"); //$NON-NLS-1$ //$NON-NLS-2$
- if (!_disableServerSSL)
- {
- System.out.println("[server keystore:\t"+_serverKeyStorePath+"]"); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("[server keystore pw:\t"+_serverKeyStorePassword+"]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-
- public boolean usingSSL()
- {
- return _enableSSL;
- }
-
- public boolean usingServerSSL()
- {
- return !_disableServerSSL;
- }
-
-
- public String getDaemonKeyStorePath()
- {
- return _daemonKeyStorePath;
- }
-
- public String getServerKeyStorePath()
- {
- return _serverKeyStorePath;
- }
-
- public String getDaemonKeyStorePassword()
- {
- return _daemonKeyStorePassword;
- }
-
- public String getServerKeyStorePassword()
- {
- return _serverKeyStorePassword;
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerUpdateHandler.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerUpdateHandler.java
deleted file mode 100644
index 326da2c66..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/server/ServerUpdateHandler.java
+++ /dev/null
@@ -1,480 +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
- *
- * 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) [222168][dstore] Buffer in DataElement is not sent
- * David McKnight (IBM) - [225507][api][breaking] RSE dstore API leaks non-API types
- * David McKnight (IBM) [246826][dstore] KeepAlive does not work correctly
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.server;
-
-import java.net.Socket;
-import java.util.ArrayList;
-
-import org.eclipse.dstore.core.java.IRemoteClassInstance;
-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.DataStoreResources;
-import org.eclipse.dstore.core.model.UpdateHandler;
-import org.eclipse.dstore.core.util.CommandGenerator;
-import org.eclipse.dstore.internal.core.util.Sender;
-
-/**
- * The ServerUpdateHandler is contains a queue of data update requests
- * and periodically transmits it's queue to the client
- */
-public class ServerUpdateHandler extends UpdateHandler
-{
-
-
- private ArrayList _senders;
- private CommandGenerator _commandGenerator;
- protected DataElement _classDocumentElement;
- protected DataElement _keepAliveDocumentElement;
- protected DataElement _confirmKeepAliveDocumentElement;
- protected DataElement _pendingKeepAliveRequest;
- protected DataElement _pendingKeepAliveConfirmation;
-
- private static String[] _keepAliveAttributes = {
- DataStoreResources.KEEPALIVE_TYPE,
- "server.keepalive.root.id", //$NON-NLS-1$
- "server.keepalive", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _confirmKeepAliveAttributes = {
- DataStoreResources.KEEPALIVECONFIRM_TYPE,
- "server.keepalive.confirm.root.id", //$NON-NLS-1$
- "server.confirmkeepalive", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _docAttributes = {
- DataStoreResources.DOCUMENT_TYPE,
- "server.doc.root.id", //$NON-NLS-1$
- "server.document", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _fileAttributes = {
- DataStoreResources.FILE_TYPE,
- "server.file.root.id", //$NON-NLS-1$
- "server.file", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _classAttributes = {
- DataStoreResources.CLASS_TYPE,
- "server.class.root.id", //$NON-NLS-1$
- "server.class", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _requestClassAttributes = {
- DataStoreResources.REQUEST_CLASS_TYPE,
- "server.requestclass.root.id", //$NON-NLS-1$
- "server.requestclass", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- private static String[] _serializeAttributes = {
- DataStoreResources.SERIALIZED_TYPE,
- "server.serialized.root.id", //$NON-NLS-1$
- "server.serialized", //$NON-NLS-1$
- "doc", //$NON-NLS-1$
- "", //$NON-NLS-1$
- "", //$NON-NLS-1$
- DataStoreResources.FALSE,
- "2"}; //$NON-NLS-1$
-
- protected DataElement _fileDocumentElement;
- protected DataElement _docDocumentElement;
- protected DataElement _requestClassDocumentElement;
- protected DataElement _serializedDocumentElement;
-
- /**
- * Constructor
- */
- public ServerUpdateHandler()
- {
- _senders = new ArrayList();
- _commandGenerator = new CommandGenerator();
-
- }
-
- /**
- * Sets the associated DataStore
- */
- public void setDataStore(DataStore dataStore)
- {
- super.setDataStore(dataStore);
- _commandGenerator.setDataStore(dataStore);
- _fileDocumentElement = dataStore.createTransientObject(_fileAttributes);
- _docDocumentElement = dataStore.createObject(null, _docAttributes);
- _requestClassDocumentElement = dataStore.createTransientObject(_requestClassAttributes);
- _serializedDocumentElement = dataStore.createTransientObject(_serializeAttributes);
- _classDocumentElement = dataStore.createTransientObject(_classAttributes);
- _keepAliveDocumentElement = dataStore.createTransientObject(_keepAliveAttributes);
- _confirmKeepAliveDocumentElement = dataStore.createTransientObject(_confirmKeepAliveAttributes);
-
- }
-
- /**
- * Add a sender to the list of senders. Normally there is only one
- * client for the server, which requires one <code>Sender</code>. If
- * there are more than one clients, then this is how senders are added.
- *
- * @param sender a sender connected to a socket
- */
- public void addSender(Sender sender)
- {
- _senders.add(sender);
- }
-
- /**
- * Remove a sender from the list of senders.
- * @param sender the sender to remove
- */
- public void removeSender(Sender sender)
- {
- _senders.remove(sender);
- if (_senders.size() == 0)
- {
- finish();
- }
- }
-
- /**
- * Sends bytes to the specified file on the client.
- *
- * @param path the name of the file on the client
- * @param bytes the bytes to send
- * @param size the number of bytes to send
- * @param binary indicates whether to send the bytes and binary or text
- */
- public synchronized void updateFile(String path, byte[] bytes, int size, boolean binary)
- {
- updateFile(path, bytes, size, binary, DataStoreResources.DEFAULT_BYTESTREAMHANDLER);
- }
-
- /**
- * Sends bytes to the specified file on the client.
- *
- * @param path the name of the file on the client
- * @param bytes the bytes to send
- * @param size the number of bytes to send
- * @param binary indicates whether to send the bytes and binary or text
- * @param byteStreamHandlerId indicates the byte stream handler to receive the bytes
- *
- */
- public synchronized void updateFile(String path, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
- {
- //DataElement document = _dataStore.createObject(null, DataStoreResources.FILE_TYPE, byteStreamHandlerId, path, path);
- DataElement document = _fileDocumentElement;
- document.setAttribute(DE.A_NAME, byteStreamHandlerId);
- document.setAttribute(DE.A_VALUE, byteStreamHandlerId);
- document.setAttribute(DE.A_SOURCE, path);
- document.setPendingTransfer(true);
- document.setParent(null);
-
- for (int j = 0; j < _senders.size(); j++)
- {
- Sender sender = (Sender) _senders.get(j);
- sender.sendFile(document, bytes, size, binary);
- }
- }
-
- /**
- * Appends bytes to the specified file on the client.
- *
- * @param path the name of the file on the client
- * @param bytes the bytes to send
- * @param size the number of bytes to send
- * @param binary indicates whether to send the bytes and binary or text
- */
- public synchronized void updateAppendFile(String path, byte[] bytes, int size, boolean binary)
- {
- updateAppendFile(path, bytes, size, binary, DataStoreResources.DEFAULT_BYTESTREAMHANDLER);
- }
-
-/**
- * Appends bytes to the specified file on the client.
- *
- * @param path the name of the file on the client
- * @param bytes the bytes to send
- * @param size the number of bytes to send
- * @param binary indicates whether to send the bytes and binary or text
- * @param byteStreamHandlerId indicates the byte stream handler to receive the bytes
- */
- public synchronized void updateAppendFile(String path, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
- {
- //DataElement document = _dataStore.createObject(null, DataStoreResources.FILE_TYPE, byteStreamHandlerId, path, path);
- DataElement document = _fileDocumentElement;
- document.setAttribute(DE.A_NAME, byteStreamHandlerId);
- document.setAttribute(DE.A_VALUE, byteStreamHandlerId);
- document.setAttribute(DE.A_SOURCE, path);
- document.setPendingTransfer(true);
- document.setParent(null);
-
- for (int j = 0; j < _senders.size(); j++)
- {
- Sender sender = (Sender) _senders.get(j);
- sender.sendAppendFile(document, bytes, size, binary);
- }
- }
-
-
- /**
- * Periodically called on the handler thread to sends data updates.
- */
- public void handle()
- {
- if (!_dataObjects.isEmpty() || _pendingKeepAliveConfirmation != null || _pendingKeepAliveRequest != null || !_classesToSend.isEmpty())
- {
- sendUpdates();
- }
- }
-
- /**
- * Periodically called to send data in the queue from the server to the client
- */
- public void sendUpdates()
- {
- synchronized (_dataObjects)
- {
- //DataElement document = _dataStore.createObject(null, DataStoreResources.DOCUMENT_TYPE, "server.doc");
- DataElement document = _docDocumentElement;
- document.removeNestedData();
- document.setPendingTransfer(true);
- document.setUpdated(true);
- document.setParent(null);
-
- _commandGenerator.generateResponse(document, _dataObjects);
-
- for (int j = 0; j < _senders.size(); j++)
- {
- Sender sender = (Sender) _senders.get(j);
- sender.sendDocument(document, 5);
- if (_pendingKeepAliveConfirmation != null)
- {
- sender.sendKeepAliveConfirmation(_pendingKeepAliveConfirmation);
- _pendingKeepAliveConfirmation = null;
- }
- if (_pendingKeepAliveRequest != null)
- {
- sender.sendKeepAliveRequest(_pendingKeepAliveRequest);
- _pendingKeepAliveRequest = null;
- }
- }
-
- for (int i = 0; i < _dataObjects.size(); i++)
- {
- DataElement obj = (DataElement) _dataObjects.get(i);
- clean(obj);
- }
-
- _dataObjects.clear();
- //_dataStore.getLogRoot().removeNestedData();
- //_dataStore.getTempRoot().removeNestedData();
- }
-
- // finished sending updates, now send all classes that are waiting
- // in the queue
- while (_classesToSend.size() > 0)
- {
- DataElement document = null;
- synchronized (_classesToSend)
- {
- document = (DataElement)_classesToSend.remove(0);
- for (int i = 0; i < _senders.size(); i++)
- {
- Sender sender = (Sender) _senders.get(i);
- sender.sendClass(document);
- }
- }
- }
-
- }
-
- /**
- * Removes the sender that is associated with the specified socket. This causes
- * A disconnect for the client that is associated with this socket.
- *
- * @param socket the socket on which a sender communicates
- */
- public void removeSenderWith(Socket socket)
- {
- for (int i = 0; i < _senders.size(); i++)
- {
- Sender sender = (Sender) _senders.get(i);
- if (sender.socket() == socket)
- {
- // sender sends last ack before death
- DataElement document = _dataStore.createObject(null, DataStoreResources.DOCUMENT_TYPE, "exit", "exit"); //$NON-NLS-1$ //$NON-NLS-2$
- sender.sendDocument(document, 2);
- removeSender(sender);
- }
- }
- }
-
- /**
- * Implemented to provide the means by which classes are sent
- * across the comm channel.
- * @param className the name of the class to request
- */
- public synchronized void requestClass(String className)
- {
- DataElement document = _requestClassDocumentElement;
- document.setPendingTransfer(true);
- document.setAttribute(DE.A_NAME, className);
- document.setAttribute(DE.A_VALUE, className);
- document.setParent(null);
- //DataElement document = _dataStore.createObject(null, DataStoreResources.REQUEST_CLASS_TYPE, className);
-
- for (int j = 0; j < _senders.size(); j++)
- {
- Sender sender = (Sender) _senders.get(j);
- sender.requestClass(document);
- }
-
- }
-
-
- public synchronized void updateClassInstance(IRemoteClassInstance runnable, String deserializebyteStreamHandlerId)
- {
- DataElement document = _serializedDocumentElement;
- document.setAttribute(DE.A_NAME, runnable.toString());
- document.setAttribute(DE.A_SOURCE, deserializebyteStreamHandlerId);
- document.setPendingTransfer(true);
- document.setParent(null);
-
- for (int j = 0; j < _senders.size(); j++)
- {
- Sender sender = (Sender) _senders.get(j);
- sender.sendRemoteClassRunnable(document, runnable);
- }
- notifyInput();
- }
-
- /**
- * Implemented to provide the means by which classes are sent
- * across the comm channel.
- * @param className the name of the class to send
- * @param classByteStreamHandlerId the name of the byte stream handler to use to receive the class
- */
- public synchronized void sendClass(String className, String classByteStreamHandlerId)
- {
- // send pending updates before sending class
- if (_dataObjects.size() > 0)
- sendUpdates();
-
- DataElement document = _classDocumentElement;
- document.setAttribute(DE.A_NAME, className);
- document.setAttribute(DE.A_SOURCE, classByteStreamHandlerId);
- document.setPendingTransfer(true);
- document.setParent(null);
-
- addClassToSend(document);
- }
-
- /**
- * Adds a class to the queue of classes (represented by DataElements) to
- * be sent to the client.
- * @param classElement the DataElement representing the class to be sent
- */
- public void addClassToSend(DataElement classElement)
- {
- synchronized (_classesToSend)
- {
- if (!_classesToSend.contains(classElement))
- {
- _classesToSend.add(classElement);
- }
- }
- }
-
- /**
- * Implemented to provide the means by which classes are requested and sent
- * across the comm channel.
- * @param className the name of the class to send
- */
- public synchronized void sendClass(String className)
- {
- sendClass(className, "default"); //$NON-NLS-1$
- }
-
- public void sendKeepAliveRequest()
- {
- DataElement document = _keepAliveDocumentElement;
- document.setPendingTransfer(true);
- document.setAttribute(DE.A_NAME, "request"); //$NON-NLS-1$
- document.setAttribute(DE.A_VALUE, "request"); //$NON-NLS-1$
- document.setParent(null);
- _pendingKeepAliveRequest = document;
-
- handle(); // bypassing threading
- }
-
- public void sendKeepAliveConfirmation()
- {
- DataElement document = _confirmKeepAliveDocumentElement;
- document.setPendingTransfer(true);
- document.setAttribute(DE.A_NAME, "confirm"); //$NON-NLS-1$
- document.setAttribute(DE.A_VALUE, "confirm"); //$NON-NLS-1$
- document.setParent(null);
- _pendingKeepAliveConfirmation = document;
-
- handle(); // bypassing threading
- }
-
- public synchronized void waitForInput()
- {
- if (_dataObjects.size() == 0 && _classesToSend.size() == 0 && _pendingKeepAliveConfirmation == null && _pendingKeepAliveRequest == null)
- {
- super.waitForInput();
- }
- }
-
- /**
- * Indicates whether the xml generator should transfer the buffer attribute of a DataElement
- * @param flag true to transfer the buffer attribute
- */
- public void setGenerateBuffer(boolean flag)
- {
- for (int i = 0; i < _senders.size(); i++)
- {
- Sender sender = (Sender)_senders.get(i);
- sender.setGenerateBuffer(flag);
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/DataElementRemover.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/DataElementRemover.java
deleted file mode 100644
index 620fccc0d..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/DataElementRemover.java
+++ /dev/null
@@ -1,239 +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
- *
- * 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) - [202822] don't need to remove children from map here
- * David McKnight (IBM) - [255390] check memory to determine whether to queue
- * David McKnight (IBM) - [261644] [dstore] remote search improvements
- * David McKnight (IBM) - [294933] [dstore] RSE goes into loop
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.core.model.DataStore;
-import org.eclipse.dstore.core.model.Handler;
-import org.eclipse.dstore.core.model.IDataStoreConstants;
-
-public class DataElementRemover extends Handler
-{
- private LinkedList _queue;
- private static int numRemoved = 0;
- private static int numDisconnected = 0;
- private static int numCreated = 0;
- private static int numGCed = 0;
-
- // The following determine how DataElements are chosen to be removed once they
- // are in the queue for removal.
- // The queue is checked every _intervalTime milliseconds and all elements
- // that are older than _expiryTime milliseconds are removed.
- public static final int DEFAULT_EXPIRY_TIME = 600; // in seconds
- public static final int DEFAULT_INTERVAL_TIME = 60; // in seconds
- private int _intervalTime = DEFAULT_INTERVAL_TIME * 10;
- private int _expiryTime = DEFAULT_EXPIRY_TIME * 10;
- public static final String EXPIRY_TIME_PROPERTY_NAME = "SPIRIT_EXPIRY_TIME"; //$NON-NLS-1$
- public static final String INTERVAL_TIME_PROPERTY_NAME = "SPIRIT_INTERVAL_TIME"; //$NON-NLS-1$
- public MemoryManager _memoryManager;
-
- public DataElementRemover(DataStore dataStore)
- {
- super();
- _memoryManager = MemoryManager.getInstance(dataStore);
- _dataStore = dataStore;
- _queue = new LinkedList();
- getTimes();
- setWaitTime(_intervalTime);
- DataElement spiritnode = _dataStore.createObjectDescriptor(_dataStore.getDescriptorRoot(), IDataStoreConstants.DATASTORE_SPIRIT_DESCRIPTOR);
- _dataStore.createCommandDescriptor(spiritnode, "StartSpirit", "DataElementRemover", IDataStoreConstants.C_START_SPIRIT); //$NON-NLS-1$ //$NON-NLS-2$
- _dataStore.refresh(_dataStore.getDescriptorRoot());
- }
-
- protected void getTimes()
- {
- try
- {
- String expiryTime = System.getProperty(EXPIRY_TIME_PROPERTY_NAME);
- if (expiryTime != null && !expiryTime.equals("")) _expiryTime = Integer.parseInt(expiryTime) * 1000; //$NON-NLS-1$
- }
- catch (Exception e)
- {
- System.out.println("Invalid spirit expiry time property, using default."); //$NON-NLS-1$
- _expiryTime = DEFAULT_EXPIRY_TIME;
- }
- try
- {
- String intervalTime = System.getProperty(INTERVAL_TIME_PROPERTY_NAME);
- if (intervalTime != null && !intervalTime.equals("")) _intervalTime = Integer.parseInt(intervalTime) * 1000; //$NON-NLS-1$
- }
- catch (Exception e)
- {
- System.out.println("Invalid spirit interval time property, using default."); //$NON-NLS-1$
- _intervalTime = DEFAULT_INTERVAL_TIME;
- }
- }
-
- public static void addToRemovedCount()
- {
- numRemoved++;
- }
-
- public static void addToCreatedCount()
- {
- numCreated++;
- }
-
- public static void addToGCedCount()
- {
- numGCed++;
- }
-
-
- public synchronized void addToQueueForRemoval(DataElement element)
- {
- synchronized (_queue)
- {
- if(isMemoryThresholdExceeded()) {
- if(element.isSpirit()) {
- unmap(element);
- }
-
- // do immediate clearing of queue since we're low on memory
- clearQueue(true);
- return;
- }
- if (_dataStore.isDoSpirit() && _dataStore == element.getDataStore())
- {
- QueueItem item = new QueueItem(element, System.currentTimeMillis());
- _queue.add(item);
- }
- }
- notifyInput();
- }
-
- private boolean isMemoryThresholdExceeded(){
- return _memoryManager.isThresholdExceeded();
- }
-
- public void handle()
- {
- clearQueue(false);
- }
-
- public synchronized void clearQueue(boolean force)
- {
- synchronized (_queue)
- {
- _dataStore.memLog(" "); //$NON-NLS-1$
- int disconnected = 0;
- if (!_dataStore.isDoSpirit())
- {
- if (_queue.size() > 0)
- {
- _dataStore.memLog("Clearing queue of size " + _queue.size() + ". DSTORE_SPIRIT_ON not set or set to false."); //$NON-NLS-1$ //$NON-NLS-2$
- _queue.clear();
- }
- _dataStore.memLog("Total heap size: " + Runtime.getRuntime().totalMemory()); //$NON-NLS-1$
- _dataStore.memLog("Elements created so far: " + numCreated); //$NON-NLS-1$
- _dataStore.memLog("Elements disconnected so far: " + numDisconnected); //$NON-NLS-1$
- _dataStore.memLog("Spirit elements cleaned so far: " + numRemoved); //$NON-NLS-1$
- _dataStore.memLog("DataElements GCed so far: " + numGCed); //$NON-NLS-1$
- return;
- }
- _dataStore.memLog("Total heap size before disconnection: " + Runtime.getRuntime().totalMemory()); //$NON-NLS-1$
-
- _dataStore.memLog("Size of queue: " + _queue.size()); //$NON-NLS-1$
-
- ArrayList toRefresh = new ArrayList();
- while (_queue.size() > 0 && (force || System.currentTimeMillis() - ((QueueItem) _queue.getFirst()).timeStamp > _expiryTime))
- {
- DataElement toBeDisconnected = ((QueueItem) _queue.removeFirst()).dataElement;
- if (!toBeDisconnected.isSpirit())
- {
- toBeDisconnected.setSpirit(true);
- toBeDisconnected.setUpdated(false);
- DataElement parent = toBeDisconnected.getParent();
- if (!toRefresh.contains(parent))
- {
- //System.out.println("disconnect parent:"+parent.getName());
- toRefresh.add(toBeDisconnected.getParent());
- }
- //_dataStore.refresh(toBeDisconnected);
- disconnected++;
- numDisconnected++;
- }
- else
- {
- //_dataStore.memLog(toBeDisconnected.toString());
- }
- unmap(toBeDisconnected);
- }
-
- _dataStore.refresh(toRefresh);
-
- _dataStore.memLog("Disconnected " + disconnected + " DataElements."); //$NON-NLS-1$ //$NON-NLS-2$
- _dataStore.memLog("Elements created so far: " + numCreated); //$NON-NLS-1$
- _dataStore.memLog("Elements disconnected so far: " + numDisconnected); //$NON-NLS-1$
- _dataStore.memLog("Spirit elements cleaned so far: " + numRemoved); //$NON-NLS-1$
- _dataStore.memLog("DataElements GCed so far: " + numGCed); //$NON-NLS-1$
- System.gc();
- }
- }
-
- private void unmap(DataElement element)
- {
- HashMap map = _dataStore.getHashMap();
- synchronized (map){
- map.remove(element.getId());
- }
- }
-
-
- protected class QueueItem
- {
- public DataElement dataElement;
- public long timeStamp;
-
- public QueueItem(DataElement element, long stamp)
- {
- dataElement = element;
- timeStamp = stamp;
- }
- }
-
- /**
- * Runs the handler loop in a thread.
- */
- public void run()
- {
- while (_keepRunning)
- {
- try
- {
- Thread.sleep(100000); // wait 100 seconds
- Thread.yield();
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- finish();
- return;
- }
- handle();
- }
- }
-}
-
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ExternalLoader.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ExternalLoader.java
deleted file mode 100644
index f798277f3..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ExternalLoader.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import java.util.ArrayList;
-
-import org.eclipse.dstore.core.java.RemoteClassLoader;
-import org.eclipse.dstore.core.model.IExternalLoader;
-import org.eclipse.dstore.core.util.StringCompare;
-
-
-/**
- * ExternalLoader is a <code>ClassLoader</code> wrapper used for loading external
- * tools that are not in the same classpath as the DataStore. Each ExternalLoader
- * contains a <i>load scope</i>, a list of classpaths that it's class loader is able
- * to load.
- */
-public class ExternalLoader implements IExternalLoader
-{
-
- private ClassLoader _classLoader;
- private ArrayList _loadScope;
-
- /**
- * Constructor
- *
- * @param classLoader the classloader
- * @param loadScope the scope in which the classloader can load classes
- */
- public ExternalLoader(ClassLoader classLoader, String loadScope)
- {
- _classLoader = classLoader;
- _loadScope = new ArrayList();
- _loadScope.add(loadScope);
- }
-
- /**
- * Constructor
- *
- * @param classLoader the classloader
- * @param loadScope the scope in which the classloader can load classes
- */
- public ExternalLoader(ClassLoader classLoader, ArrayList loadScope)
- {
- _classLoader = classLoader;
- _loadScope = loadScope;
- }
-
- /**
- * Indicates whether this external loader can load a particular class
- * @param source a qualified classname
- * @return true if it can load the clas
- */
- public boolean canLoad(String source)
- {
- if (_classLoader instanceof RemoteClassLoader)
- {
- return true;
- }
-
- boolean result = false;
- if (_loadScope != null)
- {
- for (int i = 0; i < _loadScope.size(); i++)
- {
- String scope = (String) _loadScope.get(i);
- result = StringCompare.compare(scope, source, true);
- if (result)
- {
- return result;
- }
- }
- }
- return result;
- }
-
- /**
- * Loads the specified class
- * @param source a qualified classname
- * @return the loaded class
- * @throws ClassNotFoundException
- */
- public Class loadClass(String source) throws ClassNotFoundException
- {
- try
- {
- return _classLoader.loadClass(source);
- }
- catch (NoClassDefFoundError e)
- {
- throw new ClassNotFoundException(source);
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ISender.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ISender.java
deleted file mode 100644
index 064a6f8d7..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ISender.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import org.eclipse.dstore.core.model.DataElement;
-
-public interface ISender
-{
-
-
- public void sendDocument(String document);
- public void sendDocument(DataElement objectRoot, int depth);
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/MemoryManager.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/MemoryManager.java
deleted file mode 100644
index b5412e27e..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/MemoryManager.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight
- *
- * Contributors:
- * David McKnight (IBM) - [261644] [dstore] remote search improvements
- * David McKnight (IBM) - [277764] [dstore][regression] IllegalAccessException thrown when connecting to a running server
- ********************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.eclipse.dstore.core.model.DataStore;
-import org.eclipse.dstore.core.server.SystemServiceManager;
-
-public class MemoryManager {
- private Object mbean;
- private static MemoryManager _instance;
- private DataStore _dataStore;
-
- private MemoryManager(DataStore dataStore) {
- init();
- _dataStore = dataStore;
- }
-
- public static MemoryManager getInstance(DataStore dataStore){
- if (_instance == null){
- _instance = new MemoryManager(dataStore);
- }
- return _instance;
- }
-
- private void init(){
- String thresholdString = System.getProperty("search.threshold"); //$NON-NLS-1$
- double threshold = 0.8;
- if(thresholdString != null && thresholdString.length() > 0) {
- threshold = Integer.parseInt(thresholdString) / 100.0;
- }
-
- // do we have java 1.5?
- try {
- Class factoryClass = Class.forName("java.lang.management.ManagementFactory"); //$NON-NLS-1$
- Method method = factoryClass.getDeclaredMethod("getMemoryPoolMXBeans", new Class[0]); //$NON-NLS-1$
-
- List list = (List)method.invoke(null, null);
-
- for(int i = 0;i < list.size(); i++) {
- Object mbObj = list.get(i);
- Class mbClass = mbObj.getClass();
-
-
- Method getSupportedMethod = mbClass.getDeclaredMethod("isUsageThresholdSupported", new Class[0]); //$NON-NLS-1$
- getSupportedMethod.setAccessible(true);
- Boolean usageThresholdSupported = (Boolean)getSupportedMethod.invoke(mbObj, null);
- if (usageThresholdSupported.booleanValue()){
-
- Method getTypeMethod = mbClass.getDeclaredMethod("getType", new Class[0]); //$NON-NLS-1$
-
- getTypeMethod.setAccessible(true);
- Object typeObj = getTypeMethod.invoke(mbObj, null);
- Class memoryType = Class.forName("java.lang.management.MemoryType"); //$NON-NLS-1$
- Field field = memoryType.getField("HEAP"); //$NON-NLS-1$
- Object fieldObj = field.get(typeObj);
-
- if (fieldObj.equals(typeObj)){
- Method getUsageMethod = mbClass.getDeclaredMethod("getUsage", new Class[0]); //$NON-NLS-1$
- getUsageMethod.setAccessible(true);
- Object usageObj = getUsageMethod.invoke(mbObj, null);
-
- Class usageClass = usageObj.getClass();
- Method getMaxMethod = usageClass.getDeclaredMethod("getMax", new Class[0]); //$NON-NLS-1$
- getMaxMethod.setAccessible(true);
- Long maxObj = (Long)getMaxMethod.invoke(usageObj, null);
-
- Method setThresholdMethod = mbClass.getDeclaredMethod("setUsageThreshold", new Class[] { long.class }); //$NON-NLS-1$
- Object[] args = new Object[1];
- args[0] = new Long((long)(maxObj.longValue() * threshold));
-
- setThresholdMethod.setAccessible(true);
- setThresholdMethod.invoke(mbObj, args);
- mbean = mbObj;
- break;
- }
- }
- }
- }
- catch (Exception e){
- // java version to old so no mbean created - will use fallback
- }
- }
-
- public boolean isThresholdExceeded() {
-
- if (mbean != null){
- try {
- Method method = mbean.getClass().getMethod("isUsageThresholdExceeded", new Class[0]); //$NON-NLS-1$
- Boolean exceeded = (Boolean)method.invoke(mbean, null);
- return exceeded.booleanValue();
- }
- catch (Exception e){
- return false;
- }
- }
- else {
- // no Java 1.5 available, so this is the fallback
- Runtime runtime = Runtime.getRuntime();
- long freeMem = runtime.freeMemory();
-
- if (freeMem < 10000){
-
- return true;
- }
- return false;
- }
- }
-
- public void checkAndClearupMemory()
- {
- int count = 0;
- while(count < 5 && isThresholdExceeded()) {
- System.gc();
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- }
- count ++;
- _dataStore.trace("CLEAN free mem="+Runtime.getRuntime().freeMemory()); //$NON-NLS-1$
- }
- if(count == 5) {
-
-
- _dataStore.trace("Out of memory - shutting down"); //$NON-NLS-1$
-
- Exception e = new Exception();
- _dataStore.trace(e);
-
- /*
- * show the end of the log
- DataElement logRoot = _dataStore.getLogRoot();
- List nestedData = logRoot.getNestedData();
- for (int i = nestedData.size() - 10; i < nestedData.size(); i++){
- DataElement cmd = (DataElement)nestedData.get(i);
- System.out.println(cmd);
- }
- */
-
- if (SystemServiceManager.getInstance().getSystemService() == null)
- System.exit(-1);
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Pattern.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Pattern.java
deleted file mode 100644
index 22d66ae7c..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Pattern.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import java.util.ArrayList;
-
-/**
- * This class is used to define a wildcard string pattern. Strings
- * can be compared against a pattern to determine whether they match
- * or not.
- */
-public class Pattern
-{
-
- private String _pattern;
- private ArrayList _subMatches;
- private ArrayList _matchSchema;
-
- /**
- * Constructor
- * @param pattern a wildcard string
- * @param matchSchema
- */
- public Pattern(String pattern, ArrayList matchSchema)
- {
- _pattern = pattern;
-
- _matchSchema = matchSchema;
- }
-
- /**
- * Returns a list of submatches
- * @return a list of submatches
- */
- public ArrayList getSubMatches()
- {
- return _subMatches;
- }
-
- /**
- * Returns a submatch
- * @param attribute an attribute to match
- * @return a submatch
- */
- public String getSubMatch(String attribute)
- {
- // find attribute index in match schema
- int index = _matchSchema.indexOf(attribute);
- if ((index >= 0) && (index < _subMatches.size()))
- {
- Object match = _subMatches.get(index);
- return new String((String) match);
- }
- else
- {
- return new String("null"); //$NON-NLS-1$
- }
- }
-
- /**
- * Checks whther a compare string matches the pattern
- * @param compareStr to string to compare
- * @return true if there is a match
- */
- public boolean matches(String compareStr)
- {
- String currentMatch = new String(""); //$NON-NLS-1$
- _subMatches = new ArrayList();
-
- int iText = 0;
- int iPattern = 0;
- int lastStar = 0;
- int len = compareStr.length();
-
- int patternLen = _pattern.length();
-
- while (iPattern < patternLen)
- {
- char p = _pattern.charAt(iPattern++);
- if (p == '*')
- {
- if (currentMatch.length() > 0)
- {
- _subMatches.add(new String(currentMatch));
- }
- currentMatch = new String(""); //$NON-NLS-1$
-
- if (iPattern >= patternLen)
- {
- while (iText < len)
- {
- currentMatch += compareStr.charAt(iText++);
- }
- _subMatches.add(new String(currentMatch));
-
- return true;
- }
- else
- {
- lastStar = iPattern;
- }
- }
- else
- {
- if (iText >= len)
- {
- return false;
- }
- else
- {
- char t = compareStr.charAt(iText++);
- if (p == t)
- {
- if ((lastStar > 0) && (iPattern >= patternLen) && (iText < len))
- {
- }
- else
- {
- continue;
- }
-
- }
- else
- {
- currentMatch += t;
- if (lastStar == 0)
- {
- return false;
- }
- }
-
- int matched = iPattern - lastStar - 1;
- iPattern = lastStar;
-
- iText -= matched;
- }
- }
- }
-
- if (iText >= len)
- {
- _subMatches.add(new String(currentMatch));
- return true;
- }
- else
- {
- return false;
- }
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Sender.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Sender.java
deleted file mode 100644
index b991ac425..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Sender.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2011 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) [222168][dstore] Buffer in DataElement is not sent
- * David McKnight (IBM) [305218][dstore] problem reading double-byte characters through data socket layer
- * David McKnight (IBM) [307541][dstore] fix for Bug 305218 breaks RDz connections
- * David McKnight (IBM) [347412][dstore] Need an option to set TCP NODELAYACKS
- * David McKnight (IBM) [350315][dstore] regress change made for bug 305218
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintStream;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.URL;
-import java.util.ArrayList;
-
-import org.eclipse.dstore.core.java.IRemoteClassInstance;
-import org.eclipse.dstore.core.model.DE;
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.core.model.DataStore;
-
-/**
- * This class is used for sending data to a socket in the DataStore
- * communication layer.
- */
-public class Sender implements ISender
-{
-
- private Socket _socket;
- private PrintStream _outFile;
- private BufferedWriter _outData;
- private XMLgenerator _xmlGenerator;
- private DataStore _dataStore;
-
- /**
- * Constructor
- * @param socket the associated socket
- * @param dataStore the associated DataStore
- */
- public Sender(Socket socket, DataStore dataStore)
- {
- _socket = socket;
- _dataStore = dataStore;
-
- _xmlGenerator = new XMLgenerator(_dataStore);
- try
- {
- String noDelayStr = System.getProperty("DSTORE_TCP_NO_DELAY"); //$NON-NLS-1$
- if (noDelayStr != null && noDelayStr.length() > 0){
- try {
- boolean noDelay = Boolean.valueOf(noDelayStr).booleanValue();
- _socket.setTcpNoDelay(noDelay);
-
- noDelay = _socket.getTcpNoDelay();
- _dataStore.trace("tcp no delay set to " + noDelay); //$NON-NLS-1$
- }
- catch (Exception e){
- }
- }
- int bufferSize = _socket.getSendBufferSize();
- _xmlGenerator.setBufferSize(bufferSize);
- }
- catch (SocketException e)
- {
- }
- try
- {
- _outFile = new PrintStream(_socket.getOutputStream());
-
- String encoding = DE.ENCODING_UTF_8;
-
- OutputStreamWriter writer = new OutputStreamWriter(_socket.getOutputStream(), encoding);
- _outData = new BufferedWriter(writer);
-
- _xmlGenerator.setFileWriter(_outFile);
- _xmlGenerator.setDataWriter(_outData);
- _xmlGenerator.setGenerateBuffer(false);
- InetSocketAddress address = (InetSocketAddress)socket.getRemoteSocketAddress();
- if (address != null)
- {
- if (address.getAddress() != null)
- {
- String remoteIP = address.getAddress().getHostAddress();
- _dataStore.setRemoteIP(remoteIP);
- }
- else
- {
- String remoteIP = address.getHostName();
- _dataStore.setRemoteIP(remoteIP);
- }
- }
- else
- {
- String remoteIP = socket.getInetAddress().getHostAddress();
- _dataStore.setRemoteIP(remoteIP);
- }
- }
- catch (java.io.IOException e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * Returns the associated socket
- * @return the socket
- */
- public Socket socket()
- {
- return _socket;
- }
-
- /**
- * Sends a string through the socket
- * @param document the string to send
- */
- public void sendDocument(String document)
- {
- synchronized (_outData)
- {
- try
- {
- _outData.write(document, 0, document.length());
- _outData.flush();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Sends the bytes of a file through the socket
- * @param objectRoot the object representing the file to send
- * @param bytes the bytes to send over the socket
- * @param size the number of bytes to send over the socket
- * @param binary indicates whether to send the bytes and binary or text
- */
- public void sendFile(DataElement objectRoot, byte[] bytes, int size, boolean binary)
- {
-
- synchronized (_outData)
- {
- synchronized (_outFile)
- {
-
- _xmlGenerator.empty();
- _xmlGenerator.generate(objectRoot, bytes, size, false, binary);
- _xmlGenerator.flushData();
- }
- }
- }
-
- /**
- * Sends a class through the socket
- * @param classElement the object representing the class to send
- */
- public void sendClass(DataElement classElement)
- {
- String className = classElement.getName();
-
- ArrayList loaders = _dataStore.getLocalClassLoaders();
- if (loaders == null)
- {
- // could not get the registered classLoaders. Fail.
- generateEmptyClass(classElement);
- return;
- }
-
- InputStream classInStream = null;
- className = className.replace('.', '/');
- className = className + ".class"; //$NON-NLS-1$
- URL classLocation = null;
- for (int i = 0; i < loaders.size(); i++)
- {
- ClassLoader loader = (ClassLoader) loaders.get(i);
-
- classInStream = loader.getResourceAsStream(className);
- classLocation = loader.getResource(className);
- if (classInStream != null && classLocation != null) break;
- }
- if (classLocation == null || classInStream == null)
- {
- // could not load the class with any of the class loaders. Fail.
- generateEmptyClass(classElement);
- return;
- }
-
- // got a stream to read the classfile. Now read the class into a buffer.
- BufferedInputStream bufInputStream = new BufferedInputStream(classInStream);
-
- try
- {
- int classSize = bufInputStream.available();
- byte[] bytes = new byte[classSize];
- int result = 0;
- result = bufInputStream.read(bytes);
-
- if (result != classSize)
- {
- generateEmptyClass(classElement);
- return; // throw new IOException("Could not read class from BufferedInputStream: " + className);
- }
-
- synchronized (_outData)
- {
- synchronized (_outFile)
- {
-
- _xmlGenerator.empty();
- _xmlGenerator.generate(classElement, bytes, classSize);
- _xmlGenerator.flushData();
- }
- }
- }
- catch (IOException e)
- {
- generateEmptyClass(classElement);
- return;
- }
- }
-
- /**
- * Generates an empty class and sends it across the pipe, as a signal that the
- * class could not be found or loaded or read on the client.
- * @param classElement
- */
- private void generateEmptyClass(DataElement classElement)
- {
- _xmlGenerator.empty();
- _xmlGenerator.generate(classElement, new byte[0], 0);
- _xmlGenerator.flushData();
- }
-
- /**
- * Sends the bytes of a file through the socket to be appended to a file on the other end
- *
- * @param objectRoot the object representing the file to send
- * @param bytes the bytes to send over the socket
- * @param size the number of bytes to send over the socket
- * @param binary indicates whether to send the bytes and binary or text
- */
- public void sendAppendFile(DataElement objectRoot, byte[] bytes, int size, boolean binary)
- {
- synchronized (_outData)
- {
-
- synchronized (_outFile)
- {
- _xmlGenerator.empty();
- _xmlGenerator.generate(objectRoot, bytes, size, true, binary);
- _xmlGenerator.flushData();
- }
- }
- }
-
- /**
- * Sends a DataStore tree of data through the socket
- *
- * @param objectRoot the root of the tree to send
- * @param depth the depth of the tree to send
- */
- public void sendDocument(DataElement objectRoot, int depth)
- {
- synchronized (_outData)
- {
- synchronized (_outFile)
- {
-
- _xmlGenerator.empty();
- _xmlGenerator.generate(objectRoot, depth);
- _xmlGenerator.flushData();
- }
-
- }
-
-// if (objectRoot.getParent() != null)
- // objectRoot.getDataStore().deleteObject(objectRoot.getParent(), objectRoot);
- }
-
- /**
- * Requests a class from the client
- */
- public void requestClass(DataElement classRequest)
- {
- synchronized (_outData)
- {
- synchronized (_outFile)
- {
-
- _xmlGenerator.empty();
- _xmlGenerator.generateClassRequest(classRequest);
- _xmlGenerator.flushData();
- }
- }
- }
-
- public void sendRemoteClassRunnable(DataElement objectRoot, IRemoteClassInstance runnable)
- {
- synchronized (_outData)
- {
- synchronized (_outFile)
- {
- _xmlGenerator.empty();
- _xmlGenerator.generateSerializedObject(objectRoot, runnable);
- _xmlGenerator.flushData();
- }
- }
- }
-
- public void sendKeepAliveRequest(DataElement document)
- {
- synchronized (_outData)
- {
- synchronized (_outFile)
- {
- _xmlGenerator.empty();
- _xmlGenerator.generate(document, 2);
- _xmlGenerator.flushData();
- }
- }
- }
-
- public void sendKeepAliveConfirmation(DataElement document)
- {
- synchronized (_outData)
- {
- synchronized (_outFile)
- {
- _xmlGenerator.empty();
- _xmlGenerator.generate(document, 2);
- _xmlGenerator.flushData();
- }
- }
- }
-
-
- /**
- * Indicates whether the xml generator should transfer the buffer attribute of a DataElement
- * @param flag true to transfer the buffer attribute
- */
- public void setGenerateBuffer(boolean flag)
- {
- _xmlGenerator.setGenerateBuffer(flag);
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Sorter.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Sorter.java
deleted file mode 100644
index c87584090..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/Sorter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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:
- * {Name} (company) - description of contribution.
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import java.util.ArrayList;
-
-import org.eclipse.dstore.core.model.DataElement;
-
-/**
- * Utility class used for sorting a list of DataElements based on
- * their depth attributes.
- */
-public class Sorter
-{
-
- /**
- * Sort a list of DataElements based on their depth attributes
- * @param list a list of DataElements
- * @return a sorted list of DataElements
- */
- public static ArrayList sort(ArrayList list)
- {
- ArrayList sortedList = new ArrayList(list.size());
- while (list.size() > 0)
- {
- DataElement first = findFirst(list);
- sortedList.add(first);
- }
-
- return sortedList;
- }
-
- /**
- * Find the DataElement with the highest depth in the list
- * @param list a list of DataElements
- * @return the DataElement with the highest depth
- */
- private static DataElement findFirst(ArrayList list)
- {
- DataElement result = null;
- for (int i = 0; i < list.size(); i++)
- {
- DataElement item = (DataElement) list.get(i);
- if (item != null)
- {
- int depth = item.depth();
- if ((result == null) || (depth > result.depth()))
- {
- result = item;
- }
- }
- }
-
- list.remove(result);
- return result;
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLgenerator.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLgenerator.java
deleted file mode 100644
index da0261f75..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLgenerator.java
+++ /dev/null
@@ -1,694 +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) - [232233] [dstore] Buffer in DataElement is not retained
- * David McKnight (IBM) - [245481] [dstore] CR/LF not restored for new client/old server
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import java.io.PrintStream;
-import java.util.Stack;
-
-import org.eclipse.dstore.core.java.IRemoteClassInstance;
-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.DataStoreResources;
-
-/**
- * <p>
- * This class is used to serialize data and send it either
- * to a file or a socket.
- * </p>
- * <p>
- * When a DataStore tree needs to be transmitted, it's DataElements are
- * converted to XML before sending. Only those elements which have changed and
- * are thus out of synch with the DataStore on the other end of the socket are
- * actually transferred.
- * </p>
- * <p>
- * When a byte stream or file needs to be transmitted, bytes are
- * either send as is if binary transfer is requested or as unicode if
- * binary transfer is not requested.
- * </p>
- */
-public class XMLgenerator
-{
-
- private int _state;
-
- private StringBuffer _document;
-
- private int _indent;
- private Stack _tagStack;
-
- private PrintStream _fileWriter;
- private BufferedWriter _dataWriter;
-
- private int _bufferSize;
- private boolean _generateBuffer;
- private boolean _ignoreDeleted;
-
- private DataStore _dataStore;
-
- public static final int EMPTY = 0;
- public static final int OPEN = 1;
- public static final int CLOSE = 2;
- public static final int BODY = 3;
-
- /**
- * Constructor
- * @param dataStore the associated DataStore
- */
- public XMLgenerator(DataStore dataStore)
- {
- _dataStore = dataStore;
- _state = EMPTY;
- _bufferSize = 100000;
-
- _document = new StringBuffer(_bufferSize);
-
- _indent = 0;
- _generateBuffer = true;
- _ignoreDeleted = false;
- _tagStack = new Stack();
- }
-
- /**
- * Indicate whether DataElements marked as deleted should be sent.
- * @param flag whether deleted elements should be sent
- */
- public void setIgnoreDeleted(boolean flag)
- {
- _ignoreDeleted = flag;
- }
-
- /**
- * Sets the file writer used for file transfer
- * @param writer the file writer used for file transfer
- */
- public void setFileWriter(PrintStream writer)
- {
- _fileWriter = writer;
- }
-
- /**
- * Sets the data writer used for XML transfer
- * @param writer the data writer used for XML transfer
- */
- public void setDataWriter(BufferedWriter writer)
- {
- _dataWriter = writer;
- }
-
- /**
- * Set the buffer size
- * @param size of the buffer used for transmitting packets
- */
- public void setBufferSize(int size)
- {
- _bufferSize = size;
- }
-
- /**
- * Indicate whether the buffer attribute of each DataElement should be
- * transferred
- * @param flag whether the buffer should be transferred
- */
- public void setGenerateBuffer(boolean flag)
- {
- _generateBuffer = flag;
- }
-
- private void append(char c)
- {
- _document.append(c);
- }
-
- private void append(String buffer)
- {
- _document.append(buffer);
- }
-
- private void append(StringBuffer buffer)
- {
- _document.append(buffer);
- }
-
- private void nextLine()
- {
- if (_dataWriter != null)
- {
- _document.append('\n');
-
- int length = _document.length();
- if (length > _bufferSize)
- {
- flushData();
- }
- }
- }
-
- /**
- * Send all buffered data through the pipe.
- */
- public void flushData()
- {
- if (_document.length() > 0 && _dataWriter != null)
- {
- try
- {
- _dataWriter.write(_document.toString(), 0, _document.length());
- _dataWriter.write('\n');
- _dataWriter.flush();
- _document.setLength(0);
- }
- catch (Exception e)
- {
- _dataStore.trace(e);
- _dataWriter = null;
- }
- }
- }
-
- private void indent()
- {
- for (int i = 0; i < _indent; i++)
- {
- append(' ');
- }
- }
-
- private void startTag(String name)
- {
- if (_state == OPEN)
- {
- append('>');
- _indent++;
- }
- if (_state == CLOSE)
- {
- _indent--;
- }
- if (_state == BODY)
- {
- nextLine();
- }
- indent();
- if (_document == null)
- {
- append('<');
- append(name);
- }
- else
- {
- append('<');
- append(name);
- }
- _tagStack.push(name);
- _state = OPEN;
- }
-
- private void endTag(String name)
- {
- String top = (String) _tagStack.pop();
- if (_state == CLOSE)
- {
- }
- else if (_state == OPEN)
- {
- if (top == name)
- {
- append("/>"); //$NON-NLS-1$
- if (_tagStack.empty())
- {
- _state = CLOSE;
- }
- else
- {
- _state = BODY;
- }
- }
- }
- else if (_state == BODY)
- {
- if (top == name)
- {
- nextLine();
- _indent--;
- indent();
- append("</"); //$NON-NLS-1$
- append(name);
- append('>');
- if (_tagStack.empty())
- {
- _state = CLOSE;
- }
- }
- }
- }
-
- private void addAttribute(String name, String value)
- {
- if (_state != OPEN)
- {
- }
-
- StringBuffer niceValue = null;
- if (value != null)
- {
- niceValue = prepareStringForXML(value);
-
- append(' ');
- append(name);
- append("=\""); //$NON-NLS-1$
- append(niceValue);
- append('"');
- }
- else
- {
- append(' ');
- append(name);
- append("=\"\""); //$NON-NLS-1$
- }
-
- }
-
- private void addReferenceTypeAttribute(DataElement object)
- {
- if (object.isSpirit())
- {
- addAttribute(DE.P_REF_TYPE, DataStoreResources.SPIRIT);
- }
- else
- {
- if (object.isReference())
- {
- if (_dataStore.getReferenceTag() != null && _dataStore.getReferenceTag().equals(DE.P_REF_TYPE)) addAttribute(DE.P_REF_TYPE, DataStoreResources.REFERENCE);
- else addAttribute(DE.P_REF_TYPE, DataStoreResources.TRUE);
- }
- else
- {
- if (_dataStore.getReferenceTag() != null && _dataStore.getReferenceTag().equals(DE.P_REF_TYPE)) addAttribute(DE.P_REF_TYPE, DataStoreResources.VALUE);
- else addAttribute(DE.P_REF_TYPE, DataStoreResources.FALSE);
- }
- }
- }
-
- private void addFile(byte[] bytes, int size, boolean binary)
- {
- if (_state == OPEN)
- {
- append('>');
-
- _indent++;
- _state = BODY;
- }
- if (_state == BODY)
- {
- flushData();
-
- // send everything across
- if (binary)
- {
- _fileWriter.write(bytes, 0, size);
- _fileWriter.flush();
- }
- else
- {
- try
- {
- _dataWriter.write(new String(bytes), 0, size);
- _dataWriter.flush();
- }
- catch (IOException e)
- {
- _dataStore.trace(e);
- }
- }
- }
- else if (_state == EMPTY)
- {
- }
- else if (_state == CLOSE)
- {
- }
- }
-
- private void addData(StringBuffer data)
- {
- if (_state == OPEN)
- {
- append('>');
-
- _indent++;
- _state = BODY;
- }
- if (_state == BODY)
- {
- if (_generateBuffer && data != null && (data.length() > 0))
- {
- StringBuffer text = prepareStringForXML(data);
- if (text != null && text.length() > 0)
- {
- nextLine();
- indent();
- append("<Buffer>"); //$NON-NLS-1$
- nextLine();
- append(text.toString());
- nextLine();
- append("</Buffer>"); //$NON-NLS-1$
- }
- }
- else
- {
- append(""); //$NON-NLS-1$
- }
- }
- else if (_state == EMPTY)
- {
- }
- else if (_state == CLOSE)
- {
- }
- }
-
- /**
- * Returns the current serialized document
- * @return the current document
- */
- public StringBuffer document()
- {
- return _document;
- }
-
- /**
- * Clears the current serlized document
- */
- public void empty()
- {
- _indent = 0;
- _document.delete(0, _document.length());
- }
-
- /**
- * Converts special characters to appropriate representation in XML
- * @param input buffer to convert
- * @return the converted buffer
- */
- public static StringBuffer prepareStringForXML(StringBuffer input)
- {
- StringBuffer output = new StringBuffer();
-
- for (int idx = 0; idx < input.length(); idx++)
- {
- char currChar = input.charAt(idx);
- switch (currChar)
- {
- case '&' :
- output.append(XMLparser.STR_AMP);
- break;
- case '"' :
- output.append(XMLparser.STR_QUOTE);
- break;
- case '\'' :
- output.append(XMLparser.STR_APOS);
- break;
- case '<' :
- output.append(XMLparser.STR_LT);
- break;
- case '>' :
- output.append(XMLparser.STR_GT);
- break;
- case ';' :
- output.append(XMLparser.STR_SEMI);
- break;
- case '\n':
- output.append(XMLparser.STR_NL);
- break;
- case '\r':
- output.append(XMLparser.STR_CR);
- break;
- case '\0':
- output.append(XMLparser.STR_EOL);
- break;
- default :
- output.append(currChar);
- break;
- }
- }
-
- return output;
- }
-
- /**
- * Converts special characters to appropriate representation in XML
- * @param input buffer to convert
- * @return the converted buffer
- */
- public static StringBuffer prepareStringForXML(String input)
- {
- StringBuffer output = new StringBuffer();
-
- for (int idx = 0; idx < input.length(); idx++)
- {
- char currChar = input.charAt(idx);
- switch (currChar)
- {
- case '&' :
- output.append(XMLparser.STR_AMP);
- break;
- case '"' :
- output.append(XMLparser.STR_QUOTE);
- break;
- case '\'' :
- output.append(XMLparser.STR_APOS);
- break;
- case '<' :
- output.append(XMLparser.STR_LT);
- break;
- case '>' :
- output.append(XMLparser.STR_GT);
- break;
- case ';' :
- output.append(XMLparser.STR_SEMI);
- break;
- case '\n':
- output.append(XMLparser.STR_NL);
- break;
- case '\r':
- output.append(XMLparser.STR_CR);
- break;
- case '\0':
- output.append(XMLparser.STR_EOL);
- break;
- default :
- output.append(currChar);
- break;
- }
- }
-
- return output;
- }
-
- /**
- * Generate an tags for a file transfer and send bytes over the pipe.
- *
- * @param object the element representing the file transfer
- * @param bytes the bytes to send
- * @param size the number of bytes to send
- * @param isAppend indicates whether bytes should be appended or not to a file on the other end of the pipe
- * @param binary indicates whether the bytes should be sent as binary or text
- */
- public synchronized void generate(DataElement object, byte[] bytes, int size, boolean isAppend, boolean binary)
- {
- String tagType = XMLparser.STR_FILE;
- if (isAppend)
- {
- tagType += ".Append"; //$NON-NLS-1$
- }
- if (binary)
- {
- tagType += ".Binary"; //$NON-NLS-1$
- }
-
- if (object != null)
- {
- startTag(tagType);
- addAttribute(DE.P_TYPE, object.getAttribute(DE.A_TYPE));
- addAttribute(DE.P_ID, object.getAttribute(DE.A_ID));
- addAttribute(DE.P_NAME, object.getAttribute(DE.A_NAME));
- addAttribute(DE.P_VALUE, object.getAttribute(DE.A_VALUE));
- addAttribute(DE.P_SOURCE, object.getAttribute(DE.A_SOURCE));
- addAttribute(DE.P_SOURCE_LOCATION, object.getAttribute(DE.A_SOURCE_LOCATION));
-
- addReferenceTypeAttribute(object);
-
- addAttribute(DE.P_DEPTH, "" + size); //$NON-NLS-1$
- addFile(bytes, size, binary);
-
- endTag(tagType);
- }
- }
-
- /**
- * Generate tags for class transfer and send bytes over the pipe.
- *
- * @param object the element representing the class transfer
- * @param bytes the bytes to send
- * @param size the number of bytes to send
- */
- public synchronized void generate(DataElement object, byte[] bytes, int size)
- {
- String tagType = XMLparser.STR_CLASS;
-
- if (object != null)
- {
- startTag(tagType);
- addAttribute(DE.P_TYPE, object.getAttribute(DE.A_TYPE));
- addAttribute(DE.P_ID, object.getAttribute(DE.A_ID));
- addAttribute(DE.P_NAME, object.getAttribute(DE.A_NAME));
- addAttribute(DE.P_VALUE, object.getAttribute(DE.A_VALUE));
- addAttribute(DE.P_SOURCE, object.getAttribute(DE.A_SOURCE));
- addAttribute(DE.P_SOURCE_LOCATION, object.getAttribute(DE.A_SOURCE_LOCATION));
-
- addReferenceTypeAttribute(object);
-
- addAttribute(DE.P_DEPTH, "" + size); //$NON-NLS-1$
- addFile(bytes, size, true);
-
- endTag(tagType);
- }
- }
-
- /**
- * Serializes and sends a DataStore tree through the pipe
- *
- * @param object the root of the DataStore tree to send
- * @param depth the depth of the tree to send
- */
- public void generate(DataElement object, int depth)
- {
- if ((object != null) && (depth >= 0))
- {
- String tagType = XMLparser.STR_DATAELEMENT;
-
- if (object.isUpdated() && !object.isPendingTransfer())
- {
- }
- else
- {
- if (object.isDeleted() && _ignoreDeleted)
- {
- }
- else
- {
- object.setPendingTransfer(false);
-
- startTag(tagType);
- addAttribute(DE.P_TYPE, object.getAttribute(DE.A_TYPE));
- addAttribute(DE.P_ID, object.getAttribute(DE.A_ID));
- addAttribute(DE.P_NAME, object.getAttribute(DE.A_NAME));
- addAttribute(DE.P_VALUE, object.getAttribute(DE.A_VALUE));
- addAttribute(DE.P_SOURCE, object.getAttribute(DE.A_SOURCE));
- addAttribute(DE.P_SOURCE_LOCATION, object.getAttribute(DE.A_SOURCE_LOCATION));
-
- addReferenceTypeAttribute(object);
-
- addAttribute(DE.P_DEPTH, "" + object.depth()); //$NON-NLS-1$
- addData(object.getBuffer());
- object.setUpdated(true);
-
- if (!object.isReference() && depth >= 0)
- {
- for (int i = 0; i < object.getNestedSize(); i++)
- {
- generate(object.get(i), depth - 1);
- }
- }
-
- // end generation
- endTag(tagType);
- }
- }
- }
- }
-
- public void generateClassRequest(DataElement object)
- {
- String tagType = XMLparser.STR_REQUEST_CLASS;
- if (object != null)
- {
- startTag(tagType);
- addAttribute(DE.P_TYPE, object.getAttribute(DE.A_TYPE));
- addAttribute(DE.P_ID, object.getAttribute(DE.A_ID));
- addAttribute(DE.P_NAME, object.getAttribute(DE.A_NAME));
- addAttribute(DE.P_VALUE, object.getAttribute(DE.A_VALUE));
- addAttribute(DE.P_SOURCE, object.getAttribute(DE.A_SOURCE));
- addAttribute(DE.P_SOURCE_LOCATION, object.getAttribute(DE.A_SOURCE_LOCATION));
-
- addReferenceTypeAttribute(object);
- _state = BODY;
- endTag(tagType);
- }
-
- }
-
- public void generateSerializedObject(DataElement object, IRemoteClassInstance runnable)
- {
- String tagType = XMLparser.STR_SERIALIZED;
- if (object != null)
- {
- startTag(tagType);
- addAttribute(DE.P_TYPE, object.getAttribute(DE.A_TYPE));
- addAttribute(DE.P_ID, object.getAttribute(DE.A_ID));
- addAttribute(DE.P_NAME, object.getAttribute(DE.A_NAME));
- addAttribute(DE.P_VALUE, object.getAttribute(DE.A_VALUE));
- addAttribute(DE.P_SOURCE, object.getAttribute(DE.A_SOURCE));
- addAttribute(DE.P_SOURCE_LOCATION, object.getAttribute(DE.A_SOURCE_LOCATION));
-
- addReferenceTypeAttribute(object);
-
- try
- {
- PipedInputStream pin = new PipedInputStream();
- PipedOutputStream pout = new PipedOutputStream(pin);
- ObjectOutputStream outStream = new ObjectOutputStream(pout);
- outStream.writeObject(runnable);
-
-
- int size = pin.available();
- byte[] bytes = new byte[size];
- int nRead = pin.read(bytes, 0, size);
- addAttribute(DE.P_DEPTH, "" + nRead); //$NON-NLS-1$
- addFile(bytes, nRead, true);
-
- outStream.close();
- pin.close();
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- endTag(tagType);
- }
- }
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java
deleted file mode 100644
index e8208e339..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/XMLparser.java
+++ /dev/null
@@ -1,1115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2011 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) [221601][dstore] xmlparser needs to be able to handle very large attributes
- * David McKnight (IBM) [222163][dstore] Special characters from old server are not restored
- * David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
- * David McKnight (IBM) [246826][dstore] KeepAlive does not work correctly
- * David McKnight (IBM) [305218][dstore] problem reading double-byte characters through data socket layer
- * David McKnight (IBM) [307541][dstore] fix for Bug 305218 breaks RDz connections
- * David McKnight (IBM) [322407][dstore] Connection dropped automatically when idle
- * David McKnight (IBM) [350315][dstore] regress change made for bug 305218
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-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.DataStoreResources;
-
-/**
- * <p>
- * This class is used to deserialize data received from a file or a socket.
- * </p>
- * <p>
- * When tags indicate that data is being received, the byte stream is deserialized
- * as a DataStore tree. When deserialized data maps to existing DataElements in
- * the DataStore, those elements are updated directly. Any deserialized data
- * that maps to within an existing DataElement, that does not already exist, gets
- * created under the existing DataElement. When parsing DataElement XML, there is
- * no intermediate DOM - rather the DOM is the DataStore itself.
- * </p>
- * <p>
- * When tags indicate that a byte stream or file is being received, bytes are
- * sent the the current DataStore <code>ByteStreamHandler</code> to be saved on disk.
- * </p>
- */
-public class XMLparser
-{
- public static final String KEEPALIVE_RESPONSE_TIMEOUT_PREFERENCE = "DSTORE_KEEPALIVE_RESPONSE_TIMEOUT"; //$NON-NLS-1$
- public static final String IO_SOCKET_READ_TIMEOUT_PREFERENCE = "DSTORE_IO_SOCKET_READ_TIMEOUT"; //$NON-NLS-1$
- public static final String KEEPALIVE_ENABLED_PREFERENCE = "DSTORE_KEEPALIVE_ENABLED"; //$NON-NLS-1$
-
- public int IO_SOCKET_READ_TIMEOUT = 3600000;
- public long KEEPALIVE_RESPONSE_TIMEOUT = 60000;
-
- public static final boolean VERBOSE_KEEPALIVE = false;
-
- private DataStore _dataStore;
- private DataElement _rootDataElement;
- private Stack _tagStack;
- private Stack _objStack;
-
- private boolean _isFile;
- private boolean _isClass;
- private boolean _isRequestClass;
- private boolean _isKeepAlive;
- private boolean _isKeepAliveConfirm;
- private boolean _isSerialized;
-
- private String _tagType;
-
- private byte[] _byteBuffer;
- private byte[] _fileByteBuffer;
- private int _maxBuffer;
-
- private boolean _panic = false;
- private Throwable _panicException = null;
-
- private boolean _isKeepAliveCompatible = false;
- private boolean _isKeepAliveEnabled = true;
- private boolean _firstTime = true;
-
- private KeepAliveRequestThread _kart = null;
- private KeepAliveRequestThread _initialKart = null;
-
- public static String STR_DATAELEMENT = "DataElement"; //$NON-NLS-1$
-
- public static String STR_BUFFER_START = "<Buffer>"; //$NON-NLS-1$
- public static String STR_BUFFER_END = "</Buffer>"; //$NON-NLS-1$
- public static String STR_BUFFER = "Buffer"; //$NON-NLS-1$
-
- public static String STR_STATUS = "status"; //$NON-NLS-1$
- public static String STR_STATUS_DONE = "done"; //$NON-NLS-1$
- public static String STR_STATUS_ALMOST_DONE = "almost done"; //$NON-NLS-1$
-
- public static String STR_FILE = "File"; //$NON-NLS-1$
- public static String STR_CLASS = "Class"; //$NON-NLS-1$
- public static String STR_REQUEST_CLASS= "RequestClass"; //$NON-NLS-1$
- public static String STR_SERIALIZED = "Serialized"; //$NON-NLS-1$
-
- public static String STR_AMP = "&amp;"; //$NON-NLS-1$
- public static String STR_QUOTE = "&quot;"; //$NON-NLS-1$
- public static String STR_APOS = "&apos;"; //$NON-NLS-1$
- public static String STR_LT = "&lt;"; //$NON-NLS-1$
- public static String STR_GT = "&gt;"; //$NON-NLS-1$
- public static String STR_SEMI = "&#59;"; //$NON-NLS-1$
-
- public static String STR_NL = "&#92;&#110;"; //$NON-NLS-1$
- public static String STR_CR = "&#92;&#114;"; //$NON-NLS-1$
- public static String STR_EOL = "&#92;&#48;"; //$NON-NLS-1$
-
- /**
- * Constructor
- * @param dataStore the associated DataStore
- */
- public XMLparser(DataStore dataStore)
- {
- _dataStore = dataStore;
- _tagStack = new Stack();
- _objStack = new Stack();
- _maxBuffer = 100000;
- _byteBuffer = new byte[_maxBuffer];
-
- }
-
- /**
- * Set whether to enable keepalive
- * @param enable <code>true</code> to enable keepalive
- */
- public void setEnableKeepalive(boolean enable){
- // if false, we ignore the keepalive stuff
- _isKeepAliveCompatible = enable;
- _isKeepAliveEnabled = enable;
- }
-
- /**
- * Set the keepalive response timeout
- * @param timeout the time to wait for a response after
- * initiating a keepalive request
- */
- public void setKeepaliveResponseTimeout(int timeout){
- // the new value will be picked up on the next readLine() call
- KEEPALIVE_RESPONSE_TIMEOUT = timeout;
- }
-
- /**
- * Set the socket read timeout
- * @param timeout the time to wait before initiating a keepalive request
- */
- public void setIOSocketReadTimeout(int timeout){
- // the new value will be picked up on the next readLine() call
- IO_SOCKET_READ_TIMEOUT = timeout;
- }
-
- /**
- * Read a file from the pipe
- * @param reader the pipe reader
- * @param size the number of bytes to read
- * @param path the path of the file where the received bytes should be inserted
- */
- public void readFile(BufferedInputStream reader, int size, String path, String byteStreamHandlerId)
- {
- /*
- Runtime rt = Runtime.getRuntime();
- //long totalMem = rt.totalMemory();
- long freeMem = rt.freeMemory();
-
- if (size * 100 > freeMem)
- {
- rt.gc();
- }
- */
- if (_fileByteBuffer == null || _fileByteBuffer.length < size)
- {
- try
- {
- _fileByteBuffer = new byte[size];
- }
- catch (OutOfMemoryError e)
- {
- System.exit(-1);
- }
- }
-
- int written = 0;
- while (written < size)
- {
- try
- {
- int read = reader.read(_fileByteBuffer, written, size - written);
- written += read;
- }
- catch (SocketException se)
- {
- // DKM- socket exception means connection is gone
- // need bail now!
- _dataStore.trace(se);
- handlePanic(se);
- return;
- }
- catch (IOException e)
- {
- _dataStore.trace(e);
- handlePanic(e);
- }
- catch (Error err)
- {
- System.out.println("error!"); //$NON-NLS-1$
- handlePanic(err);
- }
- }
-
- if (_tagType.startsWith("File.Append")) //$NON-NLS-1$
- {
- boolean binary = _tagType.equals("File.Append.Binary"); //$NON-NLS-1$
- _dataStore.appendToFile(path, _fileByteBuffer, size, binary, byteStreamHandlerId);
- }
- else
- {
- boolean binary = _tagType.equals("File.Binary"); //$NON-NLS-1$
- _dataStore.saveFile(path, _fileByteBuffer, size, binary, byteStreamHandlerId);
- }
- }
-
- public boolean readInstance(BufferedInputStream reader, int size, String classbyteStreamHandlerId)
- {
- byte[] buffer = new byte[size];
- int written = 0;
-
- while (written < size)
- {
- try
- {
- int read = reader.read(buffer, written, size - written);
- written += read;
- }
- catch (SocketException se)
- {
- // DKM- socket exception means connection is gone
- // need bail now!
- _dataStore.trace(se);
- handlePanic(se);
- return false;
- }
- catch (IOException e)
- {
- _dataStore.trace(e);
- handlePanic(e);
- return false;
- }
- }
- _dataStore.saveClassInstance(buffer, size, classbyteStreamHandlerId);
- return true;
- }
-
- /**
- * Read a class file from the pipe
- * @param reader the pipe reader
- * @param size the number of bytes to read
- * @param className the name of the class defined by the byte array.
- * @param classbyteStreamHandlerId the name of the classByteStreamHandler that will receive the bytes of the file.
- * @return whether the operation is successful
- */
- public boolean readClass(BufferedInputStream reader, int size, String className, String classbyteStreamHandlerId)
- {
- byte[] buffer = new byte[size];
- int written = 0;
-
- while (written < size)
- {
- try
- {
- int read = reader.read(buffer, written, size - written);
- written += read;
- }
- catch (SocketException se)
- {
- // DKM- socket exception means connection is gone
- // need bail now!
- _dataStore.trace(se);
- handlePanic(se);
- return false;
- }
- catch (IOException e)
- {
- _dataStore.trace(e);
- handlePanic(e);
- return false;
- }
- }
- _dataStore.saveClass(className, buffer, size, classbyteStreamHandlerId);
- return true;
- }
-
- /**
- * Reads a line from the pipe
- *
- * @param reader the pipe reader
- * @return the line received
- */
- public String readLine(BufferedInputStream reader, Socket socket)
- {
- boolean done = false;
- int offset = 0;
-
- try
- {
- boolean inquotes = false;
- while (!done)
- {
- if (_isKeepAliveEnabled)
- {
- if (_firstTime)
- {
- _initialKart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, socket);
- _firstTime = false;
- if (VERBOSE_KEEPALIVE) System.out.println("Starting initial KeepAlive thread."); //$NON-NLS-1$
- _initialKart.start();
- continue;
- }
- else if (_initialKart != null)
- {
- if (_initialKart.isAlive()){
- int currentTimeout = socket.getSoTimeout();
- if (currentTimeout != IO_SOCKET_READ_TIMEOUT){
- if (VERBOSE_KEEPALIVE) System.out.println("Resetting timeout from " + currentTimeout + " to " + IO_SOCKET_READ_TIMEOUT); //$NON-NLS-1$ //$NON-NLS-2$
- socket.setSoTimeout(IO_SOCKET_READ_TIMEOUT);
- }
- }
-
- if (!_initialKart.isAlive()){
- if (!_initialKart.failed())
- {
- _isKeepAliveCompatible = true;
- if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive compatible."); //$NON-NLS-1$
- _initialKart = null;
- }
- else
- {
- _isKeepAliveCompatible = false;
- if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive incompatible."); //$NON-NLS-1$
- _initialKart = null;
- }
- }
- }
- }
-
- int in = -1;
-
- if (_isKeepAliveEnabled && _isKeepAliveCompatible)
- {
- if (_kart == null || !_kart.isAlive()){ // normal read wait
- socket.setSoTimeout(IO_SOCKET_READ_TIMEOUT);
- }
- /* the SoTimeout is set in the kart before sleeping
- else { // read wait time when awaking a keepalive response
- // otherwise, if IO_SOCKET_READ_TIMEOUT is bigger we don't get out of here until IO_SOCKET_READ_TIMEOUT is complete
- socket.setSoTimeout((int)KEEPALIVE_RESPONSE_TIMEOUT);
- }
- */
-
- try
- {
- in = reader.read();
- }
- catch (InterruptedIOException e)
- {
- if ((_kart != null) && _kart.failed())
- {
- done = true;
- if (_dataStore.isVirtual()) handlePanic(new Exception("KeepAlive request to server wasnt answered in time.")); //$NON-NLS-1$
- else handlePanic(new Exception("KeepAlive request to client wasnt answered in time.")); //$NON-NLS-1$
- return null;
- }
- else
- {
- if (_kart == null || !_kart.isAlive()){
- _kart = new KeepAliveRequestThread(KEEPALIVE_RESPONSE_TIMEOUT, socket);
- if (VERBOSE_KEEPALIVE) System.out.println("No activity on socket. KeepAlive thread started."); //$NON-NLS-1$
- _kart.start();
- continue;
- }
- }
- }
- }
- else // no keepalive
- {
- in = reader.read();
- }
-
- if (in == -1)
- {
- done = true;
- Exception e = new Exception("The connection to the server has been lost."); //$NON-NLS-1$
- handlePanic(e);
- }
- else
- {
- if (in <= 0)
- {
- done = true;
- }
- else
- {
- if (_kart != null) _kart.interrupt();
- }
- byte aByte = (byte) in;
- switch (aByte)
- {
- case '"':
- inquotes = !inquotes;
- break;
- case '\n':
- case '\r':
- case '\0':
- if (!inquotes)
- done = true;
- break;
- default:
- break;
- }
-
- if (offset >= _maxBuffer)
- {
- int newMaxBuffer = 2 * _maxBuffer;
- byte[] newBuffer = new byte[newMaxBuffer];
- System.arraycopy(_byteBuffer, 0, newBuffer, 0, _maxBuffer);
- _maxBuffer = newMaxBuffer;
- _byteBuffer = newBuffer;
- }
- _byteBuffer[offset] = aByte;
- offset++;
- }
- }
- }
- catch (IOException e)
- {
- _dataStore.trace(e);
- done = true;
-
- handlePanic(e);
-
- return null;
- }
-
- if (offset > 0)
- {
- String result = null;
-
- String encoding = DE.ENCODING_UTF_8;
-
- try
- {
- result = new String(_byteBuffer, 0, offset, encoding);
- }
- catch (IOException e)
- {
- _dataStore.trace(e);
- }
-
- return result;
- }
- else
- {
- return null;
- }
- }
-
- /**
- * Called if an exception occurs during reading of the pipe
- * @param e the Exception
- */
- private void handlePanic(Throwable e)
- {
- _panic = true;
- _panicException = e;
- }
-
- /**
- * Returns the communications exception if one occurred
- * @return a exception
- */
- public Throwable getPanicException()
- {
- return _panicException;
- }
-
- /**
- * This method gets called to receive data from the pipe. It deserializes
- * DataStore XML documents, creating the appropriate DataElements in appropriate
- * places in the DataStore tree. If files are being transmitted it creates
- * the appropriate files using the DataStore <code>ByteStreamHandler</code>.
- *
- * @param reader the pipe reader
- * @return the root DataElement of the parsed document
- * @throws IOException
- */
- public DataElement parseDocument(BufferedInputStream reader, Socket socket) throws IOException
- {
- _tagStack.clear();
- _objStack.clear();
-
- _rootDataElement = null;
- _isFile = false;
- _isClass = false;
- _isRequestClass = false;
- _isKeepAlive = false;
- _isKeepAliveConfirm = false;
- _isSerialized = false;
- _tagType = STR_DATAELEMENT;
-
- DataElement parent = null;
- String matchTag = null;
-
- boolean done = false;
- while (!done)
- {
- String xmlTag = readLine(reader, socket);
-
- if (xmlTag != null)
- {
- String trimmedTag = xmlTag.trim();
- if (trimmedTag.length() > 0){
-
- if (_dataStore.getReferenceTag() == null)
- {
- if (trimmedTag.indexOf(DE.P_ISREF + "=") > -1) _dataStore.setReferenceTag(DE.P_ISREF); //$NON-NLS-1$
- else if (trimmedTag.indexOf(DE.P_REF_TYPE + "=") > -1) _dataStore.setReferenceTag(DE.P_REF_TYPE); //$NON-NLS-1$
- }
-
- if (!_tagStack.empty())
- {
- matchTag = (String) _tagStack.peek();
- }
- if (trimmedTag.equals(STR_BUFFER_START))
- {
- _tagType = STR_BUFFER;
- _tagStack.push(STR_BUFFER_END);
- }
- else if (trimmedTag.equals(STR_BUFFER_END))
- {
- _tagType = STR_DATAELEMENT;
- _tagStack.pop();
- }
- else if (_tagType.equals(STR_BUFFER))
- {
- String buffer = convertStringFromXML(xmlTag);
- if (parent != null)
- parent.appendToBuffer(buffer);
- }
- else if ((matchTag != null) && trimmedTag.equals(matchTag))
- {
- if (parent != null && parent.getType().equals(STR_STATUS))
- {
- if (parent.getName().equals(STR_STATUS_ALMOST_DONE))
- {
-
- parent.setAttribute(DE.A_NAME, STR_STATUS_DONE);
- if (parent.getValue().equals(STR_STATUS_ALMOST_DONE))
- {
- parent.setAttribute(DE.A_VALUE,STR_STATUS_DONE);
- }
- if (_dataStore.isWaiting(parent))
- {
- _dataStore.stopWaiting(parent);
- parent.notifyUpdate();
- }
- }
- }
-
- if (parent != null && parent.getNestedSize() > 0 && _dataStore.isVirtual())
- {
- List toDelete = new ArrayList();
- List nested = parent.getNestedData();
- synchronized (nested)
- {
- for (int s= 0; s < nested.size(); s++)
- {
- DataElement element = (DataElement)nested.get(s);
- if (element.isSpirit())
- {
- boolean addedToDelete = false;
- String name = element.getName();
- String value = element.getValue();
-
- // delete this element if there's another one with the same name and value
- for (int n = 0; n < parent.getNestedSize() && !addedToDelete; n++)
- {
- if (n != s)
- {
- DataElement compare = parent.get(n);
- String cname = compare.getName();
- String cvalue = compare.getValue();
- if (!compare.isSpirit() && cname.equals(name) && cvalue.equals(value))
- {
- toDelete.add(element);
- addedToDelete = true;
- }
- }
- }
- }
- }
-
- // delete elements
- for (int d = 0; d < toDelete.size(); d++)
- {
- DataElement delement = (DataElement)toDelete.get(d);
- _dataStore.deleteObject(parent,delement);
- }
- }
- }
-
- _tagStack.pop();
- if (_tagStack.empty())
- {
- done = true;
- }
- else if (_tagStack.size() == 1)
- {
- parent = _rootDataElement;
- }
- else
- {
- parent = (DataElement) _objStack.pop();
- }
-
- }
- else
- {
- xmlTag = xmlTag.trim();
-
- if (xmlTag.length() > 3)
- {
-
- try
- {
- if (parent != null)
- {
- if (_objStack.contains(parent))
- {
- }
- else
- {
- _objStack.push(parent);
- }
- }
-
- DataElement result = parseTag(xmlTag, parent);
-
- if (_panic)
- {
- return null;
- }
-
- if (result != null)
- {
- result.setUpdated(true);
-
- if (parent == null && _rootDataElement == null)
- {
- _rootDataElement = result;
- _rootDataElement.setParent(null);
- }
-
- parent = result;
-
- if (_isFile)
- {
- int size = result.depth();
- String path = result.getSource();
-
- String byteStreamHandler = result.getName();
- if (path.equals(byteStreamHandler))
- {
- // older client or server, fall back to default
- byteStreamHandler = DataStoreResources.DEFAULT_BYTESTREAMHANDLER;
- }
- readFile(reader, size, path, byteStreamHandler);
-
- _isFile = false;
- //_dataStore.deleteObject(parent, result);
- }
- else if (_isClass)
- {
- int size = result.depth();
-
- String classbyteStreamHandler = result.getSource();
-
- if (result.getName() != null)
- {
- readClass(reader, size, result.getName(), classbyteStreamHandler);
- }
- _isClass = false;
- }
- else if (_isRequestClass)
- {
- result.getDataStore().sendClass(result.getName());
- _isRequestClass = false;
- }
- else if (_isKeepAlive)
- {
- if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive request received, sending confirmation."); //$NON-NLS-1$
- result.getDataStore().sendKeepAliveConfirmation();
- _isKeepAlive = false;
- }
- else if (_isKeepAliveConfirm )
- {
- if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive confirmation received."); //$NON-NLS-1$
- if (_initialKart != null) _initialKart.interrupt();
- _isKeepAliveConfirm = false;
- }
- else if (_isSerialized)
- {
- int size = result.depth();
- String classbyteStreamHandler = result.getSource();
- if (result.getName() != null)
- {
- readInstance(reader, size, classbyteStreamHandler);
- }
- _isSerialized = false;
- }
-
- StringBuffer endTag = new StringBuffer("</"); //$NON-NLS-1$
- endTag.append(_tagType);
- endTag.append('>');
- _tagStack.push(endTag.toString());
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- _dataStore.trace(e);
- return _rootDataElement;
- }
- }
- }
- }
- }
-
- if (_panic)
- return null;
- }
-
- DataElement result = _rootDataElement;
- _rootDataElement.setParent(null); // this root is transient
-
- _rootDataElement = null;
- return result;
- }
-
- /**
- * Deserializes a single DataElement from the XML stream.
- *
- * @param fullTag the DataElement XML tag
- * @param parent the DataElement that container for the deserialized DataElement
- * @return the parsed DataElement
- */
- protected synchronized DataElement parseTag(String fullTag, DataElement parent)
- {
- if (!fullTag.startsWith("<")) //$NON-NLS-1$
- return null;
-
- try
- {
- fullTag = fullTag.substring(1, fullTag.length() - 1);
- }
- catch (Exception e)
- {
- return null;
- }
-
- // get type
- int nextSpace = fullTag.indexOf(' ');
- if (nextSpace > 0)
- {
- String[] attributes = new String[DE.A_SIZE];
-
- // tag type
- String tagType = fullTag.substring(0, nextSpace);
- if (tagType.startsWith(STR_FILE))
- {
- _isFile = true;
- _tagType = tagType;
- }
- else if (tagType.startsWith(STR_CLASS))
- {
- _isClass = true;
- _tagType = tagType;
- }
- else if (tagType.startsWith(STR_REQUEST_CLASS))
- {
- _isRequestClass = true;
- _tagType = tagType;
- }
- else if (tagType.startsWith(STR_SERIALIZED))
- {
- _isSerialized = true;
- _tagType = tagType;
- }
-
- int index = 0;
- int nextQuote = 0;
- int nextnextQuote = nextSpace;
- while ((index < DE.A_SIZE) && (nextQuote >= 0))
- {
- nextQuote = fullTag.indexOf('\"', nextnextQuote + 1);
- nextnextQuote = fullTag.indexOf('\"', nextQuote + 1);
-
- if ((nextQuote >= 0) && (nextnextQuote > nextQuote) && (fullTag.length() > nextnextQuote))
- {
- String attribute = fullTag.substring(nextQuote + 1, nextnextQuote);
- attributes[index] = convertStringFromXML(attribute);
- index++;
- }
- }
-
- DataElement result = null;
- if (attributes.length == DE.A_SIZE)
- {
- String type = attributes[DE.A_TYPE];
- if (type.equals(DataStoreResources.KEEPALIVE_TYPE))
- {
- _isKeepAlive= true;
- result = _dataStore.createTransientObject(attributes);
- }
- else if (type.equals(DataStoreResources.KEEPALIVECONFIRM_TYPE))
- {
- _isKeepAliveConfirm = true;
- result = _dataStore.createTransientObject(attributes);
- }
-
- else if (type.equals(DataStoreResources.DOCUMENT_TYPE))
- {
- String id = attributes[DE.A_ID];
- if (_dataStore.contains(id))
- {
- result = _dataStore.find(id);
- result.removeNestedData();
- }
- else
- {
- result = _dataStore.createObject(null, attributes);
- }
- }
-
- else if (_isFile || _isClass || _isSerialized || parent == null)
- {
- result = _dataStore.createTransientObject(attributes);
- }
- else
- {
- String refType = attributes[DE.A_REF_TYPE];
- boolean isSpirit = false;
- if (refType != null) isSpirit = refType.equals(DataStoreResources.SPIRIT);
-
- if ((refType != null) && (refType.equals(DataStoreResources.TRUE) || refType.equals(DataStoreResources.REFERENCE)))
- {
- // new reference
- String origId = attributes[DE.A_NAME];
- if (_dataStore.contains(origId))
- {
-
- DataElement to = _dataStore.find(origId);
- result = _dataStore.createReference(parent, to, attributes[DE.A_TYPE], false);
- }
- else
- {
- // creating reference to unknown object
- result = _dataStore.createObject(parent, attributes);
- }
- }
- else
- {
- String id = attributes[DE.A_ID];
- if (id == null)
- {
- handlePanic(new Exception(fullTag));
- return null;
- }
-
- if (_dataStore.contains(id))
- {
- result = _dataStore.find(id);
-
- // treat status special test
- String name = attributes[DE.A_NAME];
- String value = attributes[DE.A_VALUE];
- if (type.equals(STR_STATUS) && name.equals(STR_STATUS_DONE))
- {
- attributes[DE.A_NAME] = STR_STATUS_ALMOST_DONE;
- if (value.equals(STR_STATUS_DONE))
- {
- attributes[DE.A_VALUE] = STR_STATUS_ALMOST_DONE;
- }
-
- result.setAttributes(attributes);
- }
- else
- {
- if (isSpirit)
- {
- if (!_dataStore.isVirtual()) attributes[DE.A_REF_TYPE] = DataStoreResources.VALUE;
- result.setSpirit(_dataStore.isVirtual());
- }
- else
- {
- result.setSpirit(false);
- }
- result.setAttributes(attributes);
- }
-
- if (parent == _rootDataElement)
- {
- DataElement rParent = result.getParent();
- parent = rParent;
-
- _rootDataElement.addNestedData(result, false);
- }
- else
- {
- if (result.getParent() == null)
- {
- if (result != _dataStore.getRoot())
- {
- result.setParent(parent);
- }
- }
- }
-
- if (parent != null)
- {
- parent.addNestedData(result, true);
- }
- else
- {
- if (result != _dataStore.getRoot())
- {
- _dataStore.trace("parent of " + result.getName() + " is NULL!"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else
- {
- result.setParent(null);
- }
- }
- if (result.isDeleted())
- //_dataStore.deleteObject(result.getParent(), result);
- result.delete();
- }
- else
- {
- // new object
- if (_dataStore.isVirtual())
- {
- result = _dataStore.find(parent, DE.A_NAME, attributes[DE.A_NAME], 1);
- }
- if (isSpirit)
- {
- if (!_dataStore.isVirtual()) attributes[DE.A_REF_TYPE] = DataStoreResources.VALUE;
- result = _dataStore.createObject(parent, attributes);
- result.setSpirit(_dataStore.isVirtual());
- }
- else
- {
- result = _dataStore.createObject(parent, attributes);
- result.setSpirit(false);
- }
-
-
- }
-
- }
- }
- }
-
- if (result != null && result.isDeleted())
- {
- _dataStore.deleteObject(parent, result);
- }
-
- return result;
- }
-
- return null;
- }
-
-
- public static String replaceSpecial(String input)
- {
- int indexOfAmp = input.indexOf('&');
- int indexOfSemi = input.indexOf(';');
- if (indexOfAmp >= 0 && indexOfSemi > indexOfAmp)
- {
- String converted = input.replaceAll(STR_AMP, "&") //$NON-NLS-1$
- .replaceAll(STR_SEMI, ";") //$NON-NLS-1$
- .replaceAll(STR_QUOTE, "\"") //$NON-NLS-1$
- .replaceAll(STR_APOS, "\'") //$NON-NLS-1$
- .replaceAll(STR_LT, "<") //$NON-NLS-1$
- .replaceAll(STR_GT, ">") //$NON-NLS-1$
- .replaceAll(STR_NL, "\n") //$NON-NLS-1$
- .replaceAll(STR_CR, "\r") //$NON-NLS-1$
- .replaceAll(STR_EOL, "\0"); //$NON-NLS-1$
- return converted;
- }
- else
- {
- return input;
- }
- }
-
- /**
- * Converts XML special character representations to the appropriate characters
- * @param input buffer to convert
- * @return the converted buffer
- */
- public static String convertStringFromXML(String input)
- {
- if (input.indexOf('&') > -1)
- {
- return replaceSpecial(input);
- /*
- StringBuffer result = new StringBuffer();
-
- String[] tokens = splitString(input);
- for (int i = 0; i < tokens.length; i++)
- {
- String token = tokens[i];
- if (token.equals(STR_AMP_TRIMMED))
- {
- result.append('&');
- }
- else if (token.equals(STR_SEMI_TRIMMED))
- {
- result.append(';');
- }
- else if (token.equals(STR_QUOTE_TRIMMED))
- {
- result.append('"');
- }
- else if (token.equals(STR_APOS_TRIMMED))
- {
- result.append('\'');
- }
- else if (token.equals(STR_LT_TRIMMED))
- {
- result.append('<');
- }
- else if (token.equals(STR_GT_TRIMMED))
- {
- result.append('>');
- }
- else
- result.append(token);
- }
-
-
- return result.toString();
- */
- }
- else
- {
- return input;
- }
- }
-
- public class KeepAliveRequestThread extends Thread
- {
- private long _timeout;
- private boolean _failed;
- private Socket _socket;
-
- public KeepAliveRequestThread(long timeout, Socket socket)
- {
- _timeout = timeout;
- _failed = false;
- _socket = socket;
- }
-
- public void run()
- {
- _dataStore.sendKeepAliveRequest();
- try
- {
- _socket.setSoTimeout((int)_timeout);
- sleep(_timeout);
- }
- catch (SocketException e){
- }
- catch (InterruptedException e)
- {
- if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread interrupted."); //$NON-NLS-1$
- return;
- }
- if (VERBOSE_KEEPALIVE) System.out.println("KeepAlive thread failed to be interrupted."); //$NON-NLS-1$
- _failed = true;
- }
-
- public boolean failed()
- {
- return _failed;
- }
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreKeyManager.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreKeyManager.java
deleted file mode 100644
index d96fc5a6f..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreKeyManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2009 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.
- *
- * Contributors:
- * David McKnight (IBM) - [264858][dstore] OpenRSE always picks the first trusted certificate
- ********************************************************************************/
-package org.eclipse.dstore.internal.core.util.ssl;
-
-import java.net.Socket;
-import java.security.Principal;
-import java.security.PrivateKey;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.X509KeyManager;
-
-public class DStoreKeyManager implements X509KeyManager {
-
- private X509KeyManager _keyManager;
- private String _defaultAlias;
-
- public DStoreKeyManager(X509KeyManager keyManager, String defaultAlias){
- _keyManager = keyManager;
- _defaultAlias = defaultAlias;
- }
-
- public String chooseClientAlias(String[] keyType, Principal[] issuers,
- Socket socket) {
- if (_defaultAlias != null){
- return _defaultAlias;
- }
- else {
- return _keyManager.chooseClientAlias(keyType, issuers, socket);
- }
- }
-
- public String chooseServerAlias(String keyType, Principal[] issuers,
- Socket socket) {
- if (_defaultAlias != null){
- return _defaultAlias;
- }
- else {
- return _keyManager.chooseServerAlias(keyType, issuers, socket);
- }
- }
-
- public X509Certificate[] getCertificateChain(String alias) {
- return _keyManager.getCertificateChain(alias);
- }
-
- public String[] getClientAliases(String keyType, Principal[] issuers) {
- return _keyManager.getClientAliases(keyType, issuers);
- }
-
- public PrivateKey getPrivateKey(String alias) {
- return _keyManager.getPrivateKey(alias);
- }
-
- public String[] getServerAliases(String keyType, Principal[] issuers) {
- return _keyManager.getServerAliases(keyType, issuers);
- }
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreSSLContext.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreSSLContext.java
deleted file mode 100644
index b794bc08c..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DStoreSSLContext.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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
- *
- * 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) - [225507][api][breaking] RSE dstore API leaks non-API types
- * Noriaki Takatsu (IBM) - [259905][api] Provide a facility to use its own keystore
- * David McKnight (IBM) - [259905][api] provide public API for getting/setting key managers for SSLContext
- * David McKnight (IBM) - [264858][dstore] OpenRSE always picks the first trusted certificate
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util.ssl;
-
-import java.security.KeyStore;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509KeyManager;
-
-import org.eclipse.dstore.core.util.ssl.BaseSSLContext;
-import org.eclipse.dstore.core.util.ssl.DStoreKeyStore;
-import org.eclipse.dstore.core.util.ssl.IDataStoreTrustManager;
-
-
-public class DStoreSSLContext
-{
-
- public static SSLContext getServerSSLContext(String filePath, String password)
- {
- SSLContext serverContext = null;
-
- try
- {
- KeyManager[] keyManagers = BaseSSLContext.getKeyManagers();
- if (keyManagers == null)
- {
- KeyStore ks = DStoreKeyStore.getKeyStore(filePath, password);
- String keymgrAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(keymgrAlgorithm);
- kmf.init(ks, password.toCharArray());
-
- serverContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$
-
- keyManagers = kmf.getKeyManagers();
-
- // read optional system property that indicates a default certificate alias
- String defaultAlias = System.getProperty("DSTORE_DEFAULT_CERTIFICATE_ALIAS"); //$NON-NLS-1$
- if (defaultAlias != null){
- KeyManager[] x509KeyManagers = new X509KeyManager[10];
-
- for(int i=0;i<keyManagers.length; i++){
- if(keyManagers[i] instanceof X509KeyManager){
- x509KeyManagers[i] = new DStoreKeyManager((X509KeyManager)keyManagers[i], defaultAlias);
- }
- }
- serverContext.init(x509KeyManagers, null, null);
- }
- else {
- serverContext.init(keyManagers, null, null);
- }
- }
- else
- {
- serverContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$
- serverContext.init(keyManagers, null, null);
- }
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- return serverContext;
- }
-
- public static SSLContext getClientSSLContext(String filePath, String password, IDataStoreTrustManager trustManager)
- {
- SSLContext clientContext = null;
-
- try
- {
- trustManager.setKeystore(filePath, password);
- clientContext = SSLContext.getInstance("SSL"); //$NON-NLS-1$
- TrustManager[] mgrs = new TrustManager[1];
- mgrs[0] = trustManager;
-
-
- KeyManager[] keyManagers = BaseSSLContext.getKeyManagers();
- clientContext.init(keyManagers, mgrs, null);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- return clientContext;
- }
-
-
-}
diff --git a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DataStoreTrustManager.java b/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DataStoreTrustManager.java
deleted file mode 100644
index 23b934638..000000000
--- a/rse/plugins/org.eclipse.dstore.core/src/org/eclipse/dstore/internal/core/util/ssl/DataStoreTrustManager.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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) - [225507][api][breaking] RSE dstore API leaks non-API types
- * David McKnight (IBM) - [264858] [dstore] OpenRSE always picks the first trusted certificate
- * Noriaki Takatsu (IBM) - [315333] [dstore] Correct Chained Certificates are rejected in the Client
- *******************************************************************************/
-
-package org.eclipse.dstore.internal.core.util.ssl;
-
-import java.security.KeyStore;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-import org.eclipse.dstore.core.util.ssl.DStoreKeyStore;
-import org.eclipse.dstore.core.util.ssl.IDataStoreTrustManager;
-
-public class DataStoreTrustManager implements IDataStoreTrustManager
-{
- private KeyStore _keystore;
- private List _untrustedCerts;
- private List _verifyExceptions;
-
- //private X509Certificate _untrustedCert;
- //private Exception _verifyException;
-
- private List _trustedCerts;
-
- public DataStoreTrustManager()
- {
- _trustedCerts = new ArrayList();
- _untrustedCerts = new ArrayList();
- _verifyExceptions = new ArrayList();
- }
-
-
- public void setKeystore(String filePath, String password)
- {
- try
- {
- KeyStore ks = DStoreKeyStore.getKeyStore(filePath, password);
- _keystore = ks;
- loadTrustedCertificates();
- }
- catch (Exception e)
- {
-
- }
- }
-
- private void loadTrustedCertificates()
- {
- _trustedCerts.clear();
- try
- {
- Enumeration aliases = _keystore.aliases();
-
- while (aliases.hasMoreElements())
- {
- String alias = (String) (aliases.nextElement());
-
- /* The alias may be either a key or a certificate */
- java.security.cert.Certificate cert = _keystore.getCertificate(alias);
- _trustedCerts.add(cert);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-
- public List getUntrustedCerts()
- {
- return _untrustedCerts;
- }
-
- public List getVerifyExceptions()
- {
- return _verifyExceptions;
- }
-
- private void checkTrusted(X509Certificate[] certs, String arg1) throws CertificateException
- {
- _untrustedCerts.clear();
- _verifyExceptions.clear();
-
-
- for (int i = 0; i < certs.length; i++)
- {
- X509Certificate cert = certs[i];
- boolean foundMatch = false;
- if (_trustedCerts.size() > 0)
- {
-
- for (int j = 0; j < _trustedCerts.size() && !foundMatch; j++)
- {
- X509Certificate tcert = (X509Certificate)_trustedCerts.get(j);
- try
- {
- cert.verify(tcert.getPublicKey());
- foundMatch = true;
- }
- catch (Exception e)
- {
- }
- }
- }
- if (!foundMatch)
- {
- _untrustedCerts.add(cert);
- }
- }
- if (_trustedCerts.size() == 0 || _untrustedCerts.size() > 0)
- {
- throw new CertificateException();
- }
- }
-
- public void checkClientTrusted(X509Certificate[] certs, String arg1) throws CertificateException
- {
- checkTrusted(certs, arg1);
-
- }
-
- public void checkServerTrusted(X509Certificate[] certs, String arg1) throws CertificateException
- {
- checkTrusted(certs,arg1);
- }
-
- public X509Certificate[] getAcceptedIssuers()
- {
- return null;
- }
-
-
-
-}

Back to the top