| author | Otto | 2011-08-01 09:24:37 (EDT) |
|---|---|---|
| committer | Otto | 2011-08-01 09:24:37 (EDT) |
| commit | bca569600206352535bca6e2c184d1281c06ec54 (patch) (side-by-side diff) | |
| tree | edb3f83081b158603a0233cb3f9fc793768c073f | |
| parent | 4a6a2db89c45fb48b3eecfbfb83f5de0b8e58bd2 (diff) | |
| download | org.eclipse.emf.emfstore.other-bca569600206352535bca6e2c184d1281c06ec54.zip org.eclipse.emf.emfstore.other-bca569600206352535bca6e2c184d1281c06ec54.tar.gz org.eclipse.emf.emfstore.other-bca569600206352535bca6e2c184d1281c06ec54.tar.bz2 | |
replaced RMI backchannel with xmlrpc polling implemetation.refs/for/master
Change-Id: I3f4f0f7cf76568575b7e9deffebea50ee81672a6
14 files changed, 221 insertions, 704 deletions
diff --git a/org.eclipse.emf.emfstore.client.backchannel.example/src/org/unicase/backchannel/example/client/DemoBackchannelClient.java b/org.eclipse.emf.emfstore.client.backchannel.example/src/org/unicase/backchannel/example/client/DemoBackchannelClient.java index 54b403d..eabf3e3 100644 --- a/org.eclipse.emf.emfstore.client.backchannel.example/src/org/unicase/backchannel/example/client/DemoBackchannelClient.java +++ b/org.eclipse.emf.emfstore.client.backchannel.example/src/org/unicase/backchannel/example/client/DemoBackchannelClient.java @@ -51,9 +51,6 @@ public class DemoBackchannelClient extends ProxyClient { } private ServerInfo getBackChannelServerInfo() { - ServerInfo serverInfo = ModelFactory.eINSTANCE.createServerInfo(); - serverInfo.setPort(3000); - serverInfo.setUrl("localhost"); - return serverInfo; + return getServerInfo("localhost", KeyStoreManager.DEFAULT_CERTIFICATE, 8080); } } diff --git a/org.eclipse.emf.emfstore.client.backchannel/src/org/eclipse/emf/emfstore/client/backchannel/BackchannelConnectionManager.java b/org.eclipse.emf.emfstore.client.backchannel/src/org/eclipse/emf/emfstore/client/backchannel/BackchannelConnectionManager.java index 3741ee4..59f6a9e 100644 --- a/org.eclipse.emf.emfstore.client.backchannel/src/org/eclipse/emf/emfstore/client/backchannel/BackchannelConnectionManager.java +++ b/org.eclipse.emf.emfstore.client.backchannel/src/org/eclipse/emf/emfstore/client/backchannel/BackchannelConnectionManager.java @@ -5,83 +5,80 @@ */ package org.eclipse.emf.emfstore.client.backchannel; -import java.rmi.NotBoundException; -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; - import org.eclipse.emf.emfstore.client.model.ServerInfo; import org.eclipse.emf.emfstore.client.model.connectionmanager.AbstractConnectionManager; +import org.eclipse.emf.emfstore.client.model.connectionmanager.xmlrpc.XmlRpcClientManager; import org.eclipse.emf.emfstore.common.model.util.ModelUtil; -import org.eclipse.emf.emfstore.common.model.util.SerializationException; import org.eclipse.emf.emfstore.server.backchannel.BackchannelInterface; -import org.eclipse.emf.emfstore.server.backchannel.connection.client.RMIBackchannelCallbackImpl; -import org.eclipse.emf.emfstore.server.backchannel.connection.server.RMIBackchannelConnectionHandler; -import org.eclipse.emf.emfstore.server.backchannel.connection.server.RMIBackchannelInterface; +import org.eclipse.emf.emfstore.server.backchannel.connection.server.XmlRpcBackchannelConnectionHandler; import org.eclipse.emf.emfstore.server.eventmanager.EMFStoreEventListener; import org.eclipse.emf.emfstore.server.exceptions.ConnectionException; import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; +import org.eclipse.emf.emfstore.server.exceptions.UnknownSessionException; import org.eclipse.emf.emfstore.server.model.ProjectId; import org.eclipse.emf.emfstore.server.model.SessionId; import org.eclipse.emf.emfstore.server.model.versioning.events.server.ServerEvent; /** - * Clientside connection manager for the backchannel in order to register as listener on the server. + * Clientside connection manager for the backchannel in order to register as + * listener on the server. * * @author wesendon */ -public class BackchannelConnectionManager extends AbstractConnectionManager<RMIBackchannelInterface> implements - BackchannelInterface { +public class BackchannelConnectionManager extends + AbstractConnectionManager<XmlRpcClientManager> implements + BackchannelInterface { /** - * Initiates the connection to the server. - * - * @param serverInfo serverinfo - * @param id sessionid - * @throws ConnectionException in case of failure + * {@inheritDoc} */ - public void initConnection(ServerInfo serverInfo, SessionId id) throws ConnectionException { - Registry registry; - RMIBackchannelInterface facade; - try { - registry = LocateRegistry.getRegistry(serverInfo.getUrl(), serverInfo.getPort()); - facade = (RMIBackchannelInterface) registry.lookup(RMIBackchannelConnectionHandler.RMI_NAME); - } catch (RemoteException e) { - throw new ConnectionException("Connection related problem.", e); - } catch (NotBoundException e) { - throw new ConnectionException("Registry not available.", e); - } - addConnectionProxy(id, facade); + public void initConnection(ServerInfo serverInfo, SessionId id) + throws ConnectionException { + XmlRpcClientManager clientManager = new XmlRpcClientManager( + XmlRpcBackchannelConnectionHandler.BACKCHANNEL); + clientManager.initConnection(serverInfo); + addConnectionProxy(id, clientManager); } /** * {@inheritDoc} + * + * TODO: More fault tolerant implementation would be better. And it + * should be allowed to unregister. SessionTimeOut should be handled. */ - public void registerRemoteListener(SessionId sessionId, EMFStoreEventListener listener, ProjectId projectId) - throws EmfStoreException { - try { - RMIBackchannelCallbackImpl callback = new RMIBackchannelCallbackImpl(listener); - getConnectionProxy(sessionId).registerRemoteListener(ModelUtil.eObjectToString(sessionId), callback, - ModelUtil.eObjectToString(projectId)); - } catch (RemoteException e) { - throw new ConnectionException("Connection related problem.", e); - } catch (SerializationException e) { - throw new ConnectionException("Connection related problem.", e); - } + public void registerRemoteListener(final SessionId sessionId, + final EMFStoreEventListener listener, final ProjectId projectId) + throws EmfStoreException { + + Runnable runnable = new Runnable() { + public void run() { + try { + while (true) { + ServerEvent event; + event = getConnectionProxy(sessionId).callWithResult( + "getEvent", ServerEvent.class, sessionId, + projectId); + if (event != null) { + listener.handleEvent(event); + } + } + } catch (UnknownSessionException e) { + ModelUtil.logException(e); + } catch (EmfStoreException e) { + ModelUtil.logException(e); + } + } + }; + new Thread(runnable).start(); } /** * {@inheritDoc} */ - public void sendEvent(SessionId sessionId, ServerEvent event, ProjectId projectId) throws EmfStoreException { - try { - getConnectionProxy(sessionId).sendEvent(ModelUtil.eObjectToString(sessionId), - ModelUtil.eObjectToString(event), ModelUtil.eObjectToString(projectId)); - } catch (RemoteException e) { - throw new ConnectionException("Connection related problem.", e); - } catch (SerializationException e) { - throw new ConnectionException("Connection related problem.", e); - } + public void sendEvent(SessionId sessionId, ServerEvent event, + ProjectId projectId) throws EmfStoreException { + getConnectionProxy(sessionId).call("sendEvent", sessionId, event, + projectId); } } diff --git a/org.eclipse.emf.emfstore.server.backchannel/META-INF/MANIFEST.MF b/org.eclipse.emf.emfstore.server.backchannel/META-INF/MANIFEST.MF index cfddc11..7f11101 100644 --- a/org.eclipse.emf.emfstore.server.backchannel/META-INF/MANIFEST.MF +++ b/org.eclipse.emf.emfstore.server.backchannel/META-INF/MANIFEST.MF @@ -8,7 +8,6 @@ Require-Bundle: org.eclipse.emf.emfstore.server;bundle-version="0.8.7" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.emf.emfstore.server.backchannel, - org.eclipse.emf.emfstore.server.backchannel.connection.client, org.eclipse.emf.emfstore.server.backchannel.connection.server Bundle-Vendor: Eclipse Modeling Project Bundle-ClassPath: bin/ diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/BachchannelInitiator.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/BachchannelInitiator.java index b937bb2..e71c87e 100644 --- a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/BachchannelInitiator.java +++ b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/BachchannelInitiator.java @@ -5,9 +5,8 @@ import java.util.Set; import org.eclipse.emf.emfstore.common.model.util.ModelUtil; import org.eclipse.emf.emfstore.server.EmfStoreInterface; import org.eclipse.emf.emfstore.server.accesscontrol.AccessControlImpl; -import org.eclipse.emf.emfstore.server.backchannel.connection.server.RMIBackchannelConnectionHandler; +import org.eclipse.emf.emfstore.server.backchannel.connection.server.XmlRpcBackchannelConnectionHandler; import org.eclipse.emf.emfstore.server.connection.ConnectionHandler; -import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; import org.eclipse.emf.emfstore.server.exceptions.FatalEmfStoreException; import org.eclipse.emf.emfstore.server.model.ServerSpace; import org.eclipse.emf.emfstore.server.startup.PostStartupListener; @@ -34,7 +33,7 @@ public class BachchannelInitiator implements PostStartupListener { try { BackchannelInterface backchannelImpl = new BackchannelImpl(serverspace, accessControl); - RMIBackchannelConnectionHandler connectionHandler = new RMIBackchannelConnectionHandler(); + XmlRpcBackchannelConnectionHandler connectionHandler = new XmlRpcBackchannelConnectionHandler(); connectionHandler.init(backchannelImpl, accessControl); connectionHandlers.add(connectionHandler); @@ -43,8 +42,6 @@ public class BachchannelInitiator implements PostStartupListener { } catch (FatalEmfStoreException e) { ModelUtil.logException("Couldn't initiate bachchannel.", e); - } catch (EmfStoreException e) { - ModelUtil.logException("Couldn't initiate bachchannel.", e); } } diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/client/RMIBackchannelCallback.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/client/RMIBackchannelCallback.java deleted file mode 100644 index e9ef20c..0000000 --- a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/client/RMIBackchannelCallback.java +++ b/dev/null @@ -1,31 +0,0 @@ -/** - * <copyright> Copyright (c) 2008-2009 Jonas Helming, Maximilian Koegel. 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 </copyright> - */ -package org.eclipse.emf.emfstore.server.backchannel.connection.client; - -import java.rmi.Remote; -import java.rmi.RemoteException; - -import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; - -/** - * RMI callback object. This class will be sent to the server and be used from - * the server to send back events. - * - * @author wesendon * - */ -public interface RMIBackchannelCallback extends Remote { - - /** - * Recieves events from the server. - * - * @param event event from server - * @return true if listener wants to stay connected - * @throws RemoteException in case of connection error - * @throws EmfStoreException in case of other failure - */ - boolean handleEvent(String event) throws RemoteException, EmfStoreException; - -} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/client/RMIBackchannelCallbackImpl.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/client/RMIBackchannelCallbackImpl.java deleted file mode 100644 index 3eef702..0000000 --- a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/client/RMIBackchannelCallbackImpl.java +++ b/dev/null @@ -1,52 +0,0 @@ -/** - * <copyright> Copyright (c) 2008-2009 Jonas Helming, Maximilian Koegel. 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 </copyright> - */ -package org.eclipse.emf.emfstore.server.backchannel.connection.client; - -import java.rmi.RemoteException; -import java.rmi.server.UnicastRemoteObject; - -import org.eclipse.emf.emfstore.common.model.util.ModelUtil; -import org.eclipse.emf.emfstore.common.model.util.SerializationException; -import org.eclipse.emf.emfstore.server.backchannel.BackchannelConfiguration; -import org.eclipse.emf.emfstore.server.eventmanager.EMFStoreEventListener; -import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; -import org.eclipse.emf.emfstore.server.model.versioning.events.server.ServerEvent; - -/** - * Implementation of {@link RMIBackchannelCallback}. - * - * @author wesendon - */ -public class RMIBackchannelCallbackImpl extends UnicastRemoteObject implements RMIBackchannelCallback { - - private static final long serialVersionUID = 6877646068571055517L; - - private transient EMFStoreEventListener listener; - - /** - * Default constructor. - * - * @param listener client side listener which will be notified - * @throws RemoteException in case of failure - */ - public RMIBackchannelCallbackImpl(EMFStoreEventListener listener) throws RemoteException { - super(BackchannelConfiguration.getNumberProperty(BackchannelConfiguration.BACKCHANNEL_RMI_PORT, - BackchannelConfiguration.BACKCHANNEL_RMI_PORT_DEFAULT) + 2); - this.listener = listener; - } - - /** - * {@inheritDoc} - */ - public boolean handleEvent(String event) throws RemoteException, EmfStoreException { - try { - return listener.handleEvent((ServerEvent) ModelUtil.stringToEObject(event)); - } catch (SerializationException e) { - throw new EmfStoreException(e); - } - } - -} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/EMFStoreSecurityManager.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/EMFStoreSecurityManager.java deleted file mode 100644 index ac7168f..0000000 --- a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/EMFStoreSecurityManager.java +++ b/dev/null @@ -1,325 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2011 Chair for Applied Software Engineering, - * Technische Universitaet Muenchen. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - ******************************************************************************/ -package org.eclipse.emf.emfstore.server.backchannel.connection.server; - -import java.io.FileDescriptor; -import java.net.InetAddress; -import java.security.Permission; - -/** - * This SecurityManager will make no restrictions at all to get RMI running. - * - * @author koegel - */ -// MK: make some restrictions -public class EMFStoreSecurityManager extends SecurityManager { - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkAccept(java.lang.String, int) - */ - @Override - public void checkAccept(String host, int port) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkAccess(java.lang.Thread) - */ - @Override - public void checkAccess(Thread t) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkAccess(java.lang.ThreadGroup) - */ - @Override - public void checkAccess(ThreadGroup g) { - // do nothing - } - - /** - * @see java.lang.SecurityManager#checkAwtEventQueueAccess() - * @generated NOT - */ - - @Override - public void checkAwtEventQueueAccess() { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkConnect(java.lang.String, int, java.lang.Object) - */ - @Override - public void checkConnect(String host, int port, Object context) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkConnect(java.lang.String, int) - */ - @Override - public void checkConnect(String host, int port) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkCreateClassLoader() - */ - @Override - public void checkCreateClassLoader() { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkDelete(java.lang.String) - */ - @Override - public void checkDelete(String file) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkExec(java.lang.String) - */ - @Override - public void checkExec(String cmd) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkExit(int) - */ - @Override - public void checkExit(int status) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkLink(java.lang.String) - */ - @Override - public void checkLink(String lib) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkListen(int) - */ - @Override - public void checkListen(int port) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkMemberAccess(java.lang.Class, int) - */ - @Override - public void checkMemberAccess(Class<?> clazz, int which) { - // do nothing; - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkMulticast(java.net.InetAddress, byte) - */ - @Override - public void checkMulticast(InetAddress maddr, byte ttl) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkMulticast(java.net.InetAddress) - */ - @Override - public void checkMulticast(InetAddress maddr) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkPackageAccess(java.lang.String) - */ - @Override - public void checkPackageAccess(String pkg) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkPackageDefinition(java.lang.String) - */ - @Override - public void checkPackageDefinition(String pkg) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkPermission(java.security.Permission, java.lang.Object) - */ - @Override - public void checkPermission(Permission perm, Object context) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkPermission(java.security.Permission) - */ - @Override - public void checkPermission(Permission perm) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkPrintJobAccess() - */ - @Override - public void checkPrintJobAccess() { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkPropertiesAccess() - */ - @Override - public void checkPropertiesAccess() { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String) - */ - @Override - public void checkPropertyAccess(String key) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkRead(java.io.FileDescriptor) - */ - @Override - public void checkRead(FileDescriptor fd) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkRead(java.lang.String, java.lang.Object) - */ - @Override - public void checkRead(String file, Object context) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkRead(java.lang.String) - */ - @Override - public void checkRead(String file) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkSecurityAccess(java.lang.String) - */ - @Override - public void checkSecurityAccess(String target) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkSetFactory() - */ - @Override - public void checkSetFactory() { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkSystemClipboardAccess() - */ - @Override - public void checkSystemClipboardAccess() { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor) - */ - @Override - public void checkWrite(FileDescriptor fd) { - // do nothing - } - - /** - * {@inheritDoc} - * - * @see java.lang.SecurityManager#checkWrite(java.lang.String) - */ - @Override - public void checkWrite(String file) { - // do nothing - } - -} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelConnectionHandler.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelConnectionHandler.java deleted file mode 100644 index cafe3f4..0000000 --- a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelConnectionHandler.java +++ b/dev/null @@ -1,70 +0,0 @@ -package org.eclipse.emf.emfstore.server.backchannel.connection.server; - -import java.net.URL; -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import java.rmi.server.RemoteServer; - -import org.eclipse.emf.emfstore.server.accesscontrol.AuthenticationControl; -import org.eclipse.emf.emfstore.server.backchannel.Activator; -import org.eclipse.emf.emfstore.server.backchannel.BackchannelConfiguration; -import org.eclipse.emf.emfstore.server.backchannel.BackchannelInterface; -import org.eclipse.emf.emfstore.server.connection.ConnectionHandler; -import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; -import org.eclipse.emf.emfstore.server.exceptions.FatalEmfStoreException; - -/** - * Connection handler for the backchannel. This handler initiates an own RMI registry. - * - * @author wesendon - */ -public class RMIBackchannelConnectionHandler implements ConnectionHandler<BackchannelInterface> { - - /** - * Interface name. - */ - public static final String RMI_NAME = "RMIBackchannelInterface"; - - private RMIBackchannelInterface stub; - - /** - * {@inheritDoc} - */ - public String getName() { - return "Backchannel RMI ConnectionHandler"; - } - - /** - * {@inheritDoc} - */ - public void init(BackchannelInterface backchannel, AuthenticationControl accessControl) - throws FatalEmfStoreException, EmfStoreException { - try { - stub = new RMIBackchannelImpl(backchannel); - - String property = "java.rmi.server.codebase"; - URL url = Activator.getDefault().getBundle().getEntry("/bin/"); - System.setProperty(property, System.getProperty(property) + " " + url.toExternalForm()); - - System.setSecurityManager(new EMFStoreSecurityManager()); - Registry registry = LocateRegistry.createRegistry(BackchannelConfiguration.getNumberProperty( - BackchannelConfiguration.BACKCHANNEL_RMI_PORT, BackchannelConfiguration.BACKCHANNEL_RMI_PORT_DEFAULT)); - RemoteServer.setLog(System.out); - - registry.rebind(RMI_NAME, stub); - } catch (RemoteException e) { - String message = "RMI initialisation failed!"; - throw new FatalEmfStoreException(message, e); - } - - } - - /** - * {@inheritDoc} - */ - public void stop(boolean force) { - // OW: todo - } - -} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelImpl.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelImpl.java deleted file mode 100644 index 8c6d83e..0000000 --- a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelImpl.java +++ b/dev/null @@ -1,64 +0,0 @@ -package org.eclipse.emf.emfstore.server.backchannel.connection.server; - -import java.rmi.RemoteException; -import java.rmi.server.UnicastRemoteObject; - -import org.eclipse.emf.emfstore.common.model.util.ModelUtil; -import org.eclipse.emf.emfstore.common.model.util.SerializationException; -import org.eclipse.emf.emfstore.server.backchannel.BackchannelConfiguration; -import org.eclipse.emf.emfstore.server.backchannel.BackchannelInterface; -import org.eclipse.emf.emfstore.server.backchannel.connection.client.RMIBackchannelCallback; -import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; -import org.eclipse.emf.emfstore.server.model.ProjectId; -import org.eclipse.emf.emfstore.server.model.SessionId; -import org.eclipse.emf.emfstore.server.model.versioning.events.server.ServerEvent; - -/** - * Implementation of rmi interface. - * - * @author wesendon - */ -public class RMIBackchannelImpl extends UnicastRemoteObject implements RMIBackchannelInterface { - - private final BackchannelInterface backchannel; - - /** - * Default constructor. - * - * @param backchannel backchannel interface - * @throws RemoteException in case of failure - */ - protected RMIBackchannelImpl(BackchannelInterface backchannel) throws RemoteException { - super(BackchannelConfiguration.getNumberProperty(BackchannelConfiguration.BACKCHANNEL_RMI_PORT, - BackchannelConfiguration.BACKCHANNEL_RMI_PORT_DEFAULT) + 1); - this.backchannel = backchannel; - } - - private static final long serialVersionUID = 2220637232248810383L; - - /** - * {@inheritDoc} - */ - public void registerRemoteListener(String sessionId, RMIBackchannelCallback listener, String projectId) - throws RemoteException, EmfStoreException { - try { - backchannel.registerRemoteListener((SessionId) ModelUtil.stringToEObject(sessionId), - new RemoteEmfstoreListener(listener), (ProjectId) ModelUtil.stringToEObject(projectId)); - } catch (SerializationException e) { - throw new EmfStoreException(e); - } - } - - /** - * {@inheritDoc} - */ - public void sendEvent(String sessionId, String event, String projectId) throws RemoteException, EmfStoreException { - try { - backchannel.sendEvent((SessionId) ModelUtil.stringToEObject(sessionId), - (ServerEvent) ModelUtil.stringToEObject(event), (ProjectId) ModelUtil.stringToEObject(projectId)); - } catch (SerializationException e) { - throw new EmfStoreException(e); - } - } - -} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelInterface.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelInterface.java deleted file mode 100644 index e8e1b0b..0000000 --- a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RMIBackchannelInterface.java +++ b/dev/null @@ -1,52 +0,0 @@ -package org.eclipse.emf.emfstore.server.backchannel.connection.server; - -import java.rmi.Remote; -import java.rmi.RemoteException; - -import org.eclipse.emf.emfstore.server.backchannel.connection.client.RMIBackchannelCallback; -import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; - -/** - * RMI interface for the backchannel. - * - * @author wesendon - */ -public interface RMIBackchannelInterface extends Remote { - - /** - * @see org.unicase.backchannel.server.BackchannelInterface#registerRemoteListener(org.eclipse.emf.emfstore.server.model.SessionId, - * org.unicase.emfstore.eventmanager.EMFStoreEventListener, org.eclipse.emf.emfstore.server.model.ProjectId) - * - * @param sessionId - * as string - * @param listener - * rmi call back object - * @param projectId - * as string - * @throws RemoteException - * in case of connection failure - * @throws EmfStoreException - * in case of failure - */ - void registerRemoteListener(String sessionId, RMIBackchannelCallback listener, String projectId) - throws RemoteException, EmfStoreException; - - /** - * @see org.unicase.backchannel.server.BackchannelInterface#sendEvent(org.eclipse.emf.emfstore.server.model.SessionId, - * org.eclipse.emf.emfstore.server.model.versioning.events.server.ServerEvent, - * org.eclipse.emf.emfstore.server.model.ProjectId) - * - * @param sessionId - * as string - * @param event - * as string - * @param projectId - * as string - * @throws RemoteException - * in case of connection failure - * @throws EmfStoreException - * in case of failure - */ - void sendEvent(String sessionId, String event, String projectId) throws RemoteException, EmfStoreException; - -} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RemoteEmfstoreListener.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RemoteEmfstoreListener.java deleted file mode 100644 index 8ca7bfc..0000000 --- a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/RemoteEmfstoreListener.java +++ b/dev/null @@ -1,51 +0,0 @@ -package org.eclipse.emf.emfstore.server.backchannel.connection.server; - -import java.rmi.RemoteException; - -import org.eclipse.emf.emfstore.common.model.util.ModelUtil; -import org.eclipse.emf.emfstore.common.model.util.SerializationException; -import org.eclipse.emf.emfstore.server.backchannel.connection.client.RMIBackchannelCallback; -import org.eclipse.emf.emfstore.server.eventmanager.EMFStoreEventListener; -import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; -import org.eclipse.emf.emfstore.server.model.versioning.events.server.ServerEvent; - -/** - * This is an event listener adapter for the rmi call back object. - * - * @author wesendon - */ -public class RemoteEmfstoreListener implements EMFStoreEventListener { - - private RMIBackchannelCallback listener; - - /** - * Default constructor. - * - * @param listener rmi call back object - * - */ - public RemoteEmfstoreListener(RMIBackchannelCallback listener) { - this.listener = listener; - } - - /** - * {@inheritDoc} - */ - public boolean handleEvent(ServerEvent event) { - if (listener == null) { - return false; - } - try { - return listener.handleEvent(ModelUtil.eObjectToString(event)); - } catch (RemoteException e) { - listener = null; - return false; - } catch (EmfStoreException e) { - listener = null; - return false; - } catch (SerializationException e) { - listener = null; - return false; - } - } -} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelConnectionHandler.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelConnectionHandler.java new file mode 100644 index 0000000..c56d6d2 --- a/dev/null +++ b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelConnectionHandler.java @@ -0,0 +1,77 @@ +package org.eclipse.emf.emfstore.server.backchannel.connection.server; + +import org.eclipse.emf.emfstore.server.accesscontrol.AuthenticationControl; +import org.eclipse.emf.emfstore.server.backchannel.BackchannelInterface; +import org.eclipse.emf.emfstore.server.connection.ConnectionHandler; +import org.eclipse.emf.emfstore.server.connection.xmlrpc.XmlRpcWebserverManager; +import org.eclipse.emf.emfstore.server.exceptions.FatalEmfStoreException; + +/** + * Connection Handler for XML RPC Emfstore interface. + * + * @author wesendon + */ +public class XmlRpcBackchannelConnectionHandler implements + ConnectionHandler<BackchannelInterface> { + + /** + * String interface identifier. + */ + public static final String BACKCHANNEL = "Backchannel"; + + private static final String NAME = "XML RPC Connection Handler for the Backchannel"; + + private static AuthenticationControl accessControl; + + private static BackchannelInterface backchannelImpl; + + + /** + * {@inheritDoc} + */ + public String getName() { + return NAME; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("static-access") + public void init(BackchannelInterface backchannel, + AuthenticationControl accessControl) throws FatalEmfStoreException { + backchannelImpl = backchannel; + XmlRpcBackchannelConnectionHandler.accessControl = accessControl; + XmlRpcWebserverManager webServer = XmlRpcWebserverManager.getInstance(); + webServer.initServer(); + webServer.addHandler(BACKCHANNEL, XmlRpcBackchannelImpl.class); + } + + /** + * Returns Emfstore. + * + * @return emfstore + */ + public static BackchannelInterface getBackChannel() { + return backchannelImpl; + } + + /** + * Returns AccessControl. + * + * @return access control + */ + public static AuthenticationControl getAccessControl() { + return accessControl; + } + + /** + * {@inheritDoc} + */ + public void stop(boolean force) { + XmlRpcWebserverManager webserverManager = XmlRpcWebserverManager + .getInstance(); + if (!webserverManager.removeHandler(BACKCHANNEL)) { + } + } + +} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelImpl.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelImpl.java new file mode 100644 index 0000000..0235ecd --- a/dev/null +++ b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelImpl.java @@ -0,0 +1,76 @@ +package org.eclipse.emf.emfstore.server.backchannel.connection.server; + +import org.eclipse.emf.emfstore.server.backchannel.BackchannelInterface; +import org.eclipse.emf.emfstore.server.eventmanager.EMFStoreEventListener; +import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; +import org.eclipse.emf.emfstore.server.model.ProjectId; +import org.eclipse.emf.emfstore.server.model.SessionId; +import org.eclipse.emf.emfstore.server.model.versioning.events.server.ServerEvent; + +/** + * Implementation of xml rpc interface. + * + * @author wesendon + */ +public class XmlRpcBackchannelImpl implements XmlRpcBackchannelInterface { + + private static final long serialVersionUID = 2220637232248810383L; + + /** + * @return the backchannel + */ + private BackchannelInterface getBackchannel() { + return XmlRpcBackchannelConnectionHandler.getBackChannel(); + } + + /** + * {@inheritDoc} + */ + public ServerEvent getEvent(SessionId sessionId, ProjectId projectId) + throws EmfStoreException { + AsyncListener listener = new AsyncListener(); + getBackchannel().registerRemoteListener(sessionId, listener, projectId); + return listener.getEvent(AsyncListener.NOTIMEOUT); + } + + /** + * {@inheritDoc} + */ + public void sendEvent(SessionId sessionId, ServerEvent serverEvent, + ProjectId projectId) throws EmfStoreException { + getBackchannel().sendEvent(sessionId, serverEvent, projectId); + } + + // TODO add event buffer in order to handle events while the polling client + // isn't connected + private final class AsyncListener implements EMFStoreEventListener { + + private static final int NOTIMEOUT = -1; + private ServerEvent event; + + public boolean handleEvent(ServerEvent event) { + this.event = event; + synchronized (this) { + this.notifyAll(); + } + return false; + } + + public ServerEvent getEvent(long timeout) { + synchronized (this) { + try { + if (timeout == NOTIMEOUT) { + this.wait(); + } else { + this.wait(timeout); + } + ServerEvent tmp = event; + event = null; + return tmp; + } catch (InterruptedException e) { + return null; + } + } + } + } +} diff --git a/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelInterface.java b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelInterface.java new file mode 100644 index 0000000..1b7de9f --- a/dev/null +++ b/org.eclipse.emf.emfstore.server.backchannel/src/org/eclipse/emf/emfstore/server/backchannel/connection/server/XmlRpcBackchannelInterface.java @@ -0,0 +1,19 @@ +package org.eclipse.emf.emfstore.server.backchannel.connection.server; + +import org.eclipse.emf.emfstore.server.exceptions.EmfStoreException; +import org.eclipse.emf.emfstore.server.model.ProjectId; +import org.eclipse.emf.emfstore.server.model.SessionId; +import org.eclipse.emf.emfstore.server.model.versioning.events.server.ServerEvent; + +/** + * xmlrpc interface for the backchannel. + * + * @author wesendon + */ +public interface XmlRpcBackchannelInterface { + + ServerEvent getEvent(SessionId sessionId, ProjectId projectId) throws EmfStoreException; + + void sendEvent(SessionId sessionId, ServerEvent event, ProjectId projectId) throws EmfStoreException; + +} |

