cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject [3/9] cayenne git commit: Assorted fixes to the new ROP mechanism resolving problems with session not being preserved between requests.
Date Tue, 01 Mar 2016 14:50:41 GMT
Assorted fixes to the new ROP mechanism resolving problems with session not being preserved
between requests.


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/c775dc49
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/c775dc49
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/c775dc49

Branch: refs/heads/master
Commit: c775dc495f42afa23887af5a0b55f7a13f59cc46
Parents: 7cfb4c7
Author: Dzmitry Kazimirchyk <dkazimirchyk@gmail.com>
Authored: Wed Jan 20 14:05:04 2016 +0300
Committer: Dzmitry Kazimirchyk <dkazimirchyk@gmail.com>
Committed: Tue Mar 1 14:10:14 2016 +0300

----------------------------------------------------------------------
 .../configuration/rop/client/ClientModule.java  |  2 -
 .../remote/hessian/HessianConnection.java       |  1 -
 .../cayenne/rop/DefaultClientConnection.java    |  4 ++
 .../rop/DefaultClientConnectionProvider.java    | 37 ++++++++++-
 .../apache/cayenne/rop/ProxyRemoteService.java  | 35 +++++-----
 .../cayenne/rop/http/HttpROPConnector.java      | 24 +++++++
 .../rop/http/HttpROPConnectorProvider.java      | 58 -----------------
 .../rop/HessianROPSerializationService.java     | 31 ++++-----
 .../cayenne/rop/ROPSerializationService.java    | 12 ++--
 .../java/org/apache/cayenne/rop/ROPServlet.java | 67 ++++++++++++--------
 10 files changed, 140 insertions(+), 131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientModule.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientModule.java
b/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientModule.java
index 041408a..a782ca3 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientModule.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/configuration/rop/client/ClientModule.java
@@ -35,7 +35,6 @@ import org.apache.cayenne.remote.ClientConnection;
 import org.apache.cayenne.remote.RemoteService;
 import org.apache.cayenne.rop.*;
 import org.apache.cayenne.rop.http.ClientHessianSerializationServiceProvider;
-import org.apache.cayenne.rop.http.HttpROPConnectorProvider;
 
 /**
  * A DI module containing all Cayenne ROP client runtime configurations.
@@ -61,7 +60,6 @@ public class ClientModule implements Module {
 
         binder.bind(ObjectContextFactory.class).to(CayenneContextFactory.class);
         binder.bind(ROPSerializationService.class).toProvider(ClientHessianSerializationServiceProvider.class);
-        binder.bind(ROPConnector.class).toProvider(HttpROPConnectorProvider.class);
         binder.bind(RemoteService.class).to(ProxyRemoteService.class);
         binder.bind(ClientConnection.class).toProvider(DefaultClientConnectionProvider.class);
         binder.bind(EventManager.class).to(DefaultEventManager.class);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-client/src/main/java/org/apache/cayenne/remote/hessian/HessianConnection.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/remote/hessian/HessianConnection.java
b/cayenne-client/src/main/java/org/apache/cayenne/remote/hessian/HessianConnection.java
index 3bea90d..372cfc7 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/remote/hessian/HessianConnection.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/remote/hessian/HessianConnection.java
@@ -226,7 +226,6 @@ public class HessianConnection extends BaseConnection {
         factory.setConnectionFactory(new HessianURLConnectionFactory(this));
         factory.setUser(userName);
         factory.setPassword(password);
-//        factory.setReadTimeout(getReadTimeout());
 
         this.serializerFactory = factory.getSerializerFactory();
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnection.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnection.java
b/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnection.java
index 2004c6e..00f21fc 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnection.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnection.java
@@ -38,6 +38,10 @@ public class DefaultClientConnection extends BaseConnection {
         this.sharedSessionName = sharedSession;
     }
 
+    public RemoteSession getSession() {
+        return session;
+    }
+
 	@Override
 	protected void beforeSendMessage(ClientMessage message) throws CayenneRuntimeException {
 		if (session == null) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnectionProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnectionProvider.java
b/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnectionProvider.java
index a6dc9e5..61ba2d4 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnectionProvider.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/rop/DefaultClientConnectionProvider.java
@@ -18,13 +18,14 @@
  ****************************************************************/
 package org.apache.cayenne.rop;
 
+import org.apache.cayenne.ConfigurationException;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.di.DIRuntimeException;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.di.Provider;
 import org.apache.cayenne.remote.ClientConnection;
-import org.apache.cayenne.remote.RemoteService;
+import org.apache.cayenne.rop.http.HttpROPConnector;
 
 public class DefaultClientConnectionProvider implements Provider<ClientConnection>
{
 
@@ -32,13 +33,43 @@ public class DefaultClientConnectionProvider implements Provider<ClientConnectio
     protected RuntimeProperties runtimeProperties;
     
     @Inject
-    protected RemoteService remoteService;
+    protected ROPSerializationService serializationService;
 
     @Override
     public ClientConnection get() throws DIRuntimeException {
         String sharedSession = runtimeProperties
                 .get(Constants.ROP_SERVICE_SHARED_SESSION_PROPERTY);
 
-        return new DefaultClientConnection(remoteService, sharedSession);
+        HttpROPConnector ropConnector = createHttpRopConnector();
+        ProxyRemoteService remoteService = new ProxyRemoteService(serializationService, ropConnector);
+
+        DefaultClientConnection clientConnection = new DefaultClientConnection(remoteService,
sharedSession);
+        ropConnector.setClientConnection(clientConnection);
+
+        return clientConnection;
+    }
+
+    protected HttpROPConnector createHttpRopConnector() {
+        String url = runtimeProperties.get(Constants.ROP_SERVICE_URL_PROPERTY);
+        if (url == null) {
+            throw new ConfigurationException(
+                    "No property defined for '%s', can't initialize HessianConnection",
+                    Constants.ROP_SERVICE_URL_PROPERTY);
+        }
+
+        String userName = runtimeProperties.get(Constants.ROP_SERVICE_USERNAME_PROPERTY);
+        String password = runtimeProperties.get(Constants.ROP_SERVICE_PASSWORD_PROPERTY);
+
+        long readTimeout = runtimeProperties.getLong(
+                Constants.ROP_SERVICE_TIMEOUT_PROPERTY,
+                -1L);
+
+        HttpROPConnector result = new HttpROPConnector(url, userName, password);
+
+        if (readTimeout > 0) {
+            result.setReadTimeout(readTimeout);
+        }
+
+        return result;
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-client/src/main/java/org/apache/cayenne/rop/ProxyRemoteService.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/rop/ProxyRemoteService.java b/cayenne-client/src/main/java/org/apache/cayenne/rop/ProxyRemoteService.java
index ecfb441..57d4650 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/rop/ProxyRemoteService.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/rop/ProxyRemoteService.java
@@ -28,32 +28,35 @@ import java.rmi.RemoteException;
 
 public class ProxyRemoteService implements RemoteService {
 
-	@Inject
-	protected ROPSerializationService serializationService;
-	
-	@Inject
-	protected ROPConnector ropConnector;
-	
-	@Override
-	public RemoteSession establishSession() throws RemoteException {
+    protected ROPSerializationService serializationService;
+
+    protected ROPConnector ropConnector;
+
+    public ProxyRemoteService(@Inject ROPSerializationService serializationService, @Inject
ROPConnector ropConnector) {
+        this.serializationService = serializationService;
+        this.ropConnector = ropConnector;
+    }
+
+    @Override
+    public RemoteSession establishSession() throws RemoteException {
         try {
             return serializationService.deserialize(ropConnector.establishSession(), RemoteSession.class);
         } catch (IOException e) {
             throw new RemoteException(e.getMessage());
         }
-	}
+    }
 
-	@Override
-	public RemoteSession establishSharedSession(String name) throws RemoteException {
+    @Override
+    public RemoteSession establishSharedSession(String name) throws RemoteException {
         try {
             return serializationService.deserialize(ropConnector.establishSharedSession(name),
RemoteSession.class);
         } catch (IOException e) {
             throw new RemoteException(e.getMessage());
         }
-	}
+    }
 
-	@Override
-	public Object processMessage(ClientMessage message) throws RemoteException, Throwable {
-		return serializationService.deserialize(ropConnector.sendMessage(serializationService.serialize(message)),
Object.class);
-	}
+    @Override
+    public Object processMessage(ClientMessage message) throws RemoteException, Throwable
{
+        return serializationService.deserialize(ropConnector.sendMessage(serializationService.serialize(message)),
Object.class);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnector.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnector.java
b/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnector.java
index 786add2..198ab19 100644
--- a/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnector.java
+++ b/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnector.java
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.cayenne.rop.http;
 
+import org.apache.cayenne.remote.RemoteSession;
+import org.apache.cayenne.rop.DefaultClientConnection;
 import org.apache.cayenne.rop.ROPConnector;
 import org.apache.cayenne.rop.ROPConstants;
 import org.apache.commons.logging.Log;
@@ -36,6 +38,10 @@ public class HttpROPConnector implements ROPConnector {
 
     private static Log logger = LogFactory.getLog(HttpROPConnector.class);
 
+    public static final String SESSION_COOKIE_NAME = "JSESSIONID";
+
+    private DefaultClientConnection clientConnection;
+
     private String url;
 
     private String username;
@@ -48,6 +54,10 @@ public class HttpROPConnector implements ROPConnector {
         this.username = username;
         this.password = password;
     }
+
+    public void setClientConnection(DefaultClientConnection clientConnection) {
+        this.clientConnection = clientConnection;
+    }
     
     public void setReadTimeout(Long readTimeout) {
         this.readTimeout = readTimeout;
@@ -111,6 +121,7 @@ public class HttpROPConnector implements ROPConnector {
 
 		try (OutputStream output = connection.getOutputStream()) {
 			output.write(urlParams.toString().getBytes(StandardCharsets.UTF_8));
+            output.flush();
 		}
 
 		return connection.getInputStream();
@@ -124,11 +135,15 @@ public class HttpROPConnector implements ROPConnector {
         }
 
         addAuthHeader(connection);
+        addSessionCookie(connection);
         connection.setDoOutput(true);
 
+        connection.setRequestProperty("Content-Type", "application/octet-stream");
+
         if (data != null) {
             try (OutputStream output = connection.getOutputStream()) {
                 output.write(data);
+                output.flush();
             }
         }
 
@@ -143,6 +158,15 @@ public class HttpROPConnector implements ROPConnector {
         }
     }
 
+    protected void addSessionCookie(URLConnection connection) {
+        RemoteSession session = clientConnection.getSession();
+        if (session != null && session.getSessionId() != null) {
+            connection.addRequestProperty("Cookie", SESSION_COOKIE_NAME
+                    + "="
+                    + session.getSessionId());
+        }
+    }
+
     public String getBasicAuth(String user, String password) {
         if (user != null && password != null) {
             return "Basic " + base64(user + ":" + password);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnectorProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnectorProvider.java
b/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnectorProvider.java
deleted file mode 100644
index 919a51f..0000000
--- a/cayenne-client/src/main/java/org/apache/cayenne/rop/http/HttpROPConnectorProvider.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.rop.http;
-
-import org.apache.cayenne.ConfigurationException;
-import org.apache.cayenne.configuration.Constants;
-import org.apache.cayenne.configuration.RuntimeProperties;
-import org.apache.cayenne.di.DIRuntimeException;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.di.Provider;
-import org.apache.cayenne.rop.ROPConnector;
-
-public class HttpROPConnectorProvider implements Provider<ROPConnector> {
-
-    @Inject
-    protected RuntimeProperties runtimeProperties;
-
-    @Override
-    public ROPConnector get() throws DIRuntimeException {
-        String url = runtimeProperties.get(Constants.ROP_SERVICE_URL_PROPERTY);
-        if (url == null) {
-            throw new ConfigurationException(
-                    "No property defined for '%s', can't initialize HessianConnection",
-                    Constants.ROP_SERVICE_URL_PROPERTY);
-        }
-
-        String userName = runtimeProperties.get(Constants.ROP_SERVICE_USERNAME_PROPERTY);
-        String password = runtimeProperties.get(Constants.ROP_SERVICE_PASSWORD_PROPERTY);
-
-        long readTimeout = runtimeProperties.getLong(
-                Constants.ROP_SERVICE_TIMEOUT_PROPERTY,
-                -1L);
-
-        HttpROPConnector result = new HttpROPConnector(url, userName, password);
-
-        if (readTimeout > 0) {
-            result.setReadTimeout(readTimeout);
-        }
-
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-server/src/main/java/org/apache/cayenne/rop/HessianROPSerializationService.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/rop/HessianROPSerializationService.java
b/cayenne-server/src/main/java/org/apache/cayenne/rop/HessianROPSerializationService.java
index 31825ce..af3c656 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/rop/HessianROPSerializationService.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/rop/HessianROPSerializationService.java
@@ -18,51 +18,48 @@
  ****************************************************************/
 package org.apache.cayenne.rop;
 
-import com.caucho.hessian.io.Hessian2Output;
 import com.caucho.hessian.io.HessianInput;
 import com.caucho.hessian.io.HessianOutput;
 import com.caucho.hessian.io.SerializerFactory;
-import org.apache.cayenne.DataChannel;
-import org.apache.cayenne.di.Inject;
-import org.apache.cayenne.remote.hessian.HessianConfig;
-import org.apache.cayenne.remote.hessian.service.HessianService;
 
 import java.io.*;
 
 public class HessianROPSerializationService implements ROPSerializationService {
 
     protected SerializerFactory serializerFactory;
-    
+
     public HessianROPSerializationService(SerializerFactory serializerFactory) {
         this.serializerFactory = serializerFactory;
     }
-    
+
     @Override
     public byte[] serialize(Object object) throws IOException {
         ByteArrayOutputStream bytes = new ByteArrayOutputStream();
         HessianOutput out = new HessianOutput(bytes);
         out.setSerializerFactory(serializerFactory);
         out.writeObject(object);
+        out.flush();
 
         return bytes.toByteArray();
     }
 
-	@Override
-	public void serialize(Object object, OutputStream outputStream) throws IOException {
-		Hessian2Output out = new Hessian2Output(outputStream);
-		out.setSerializerFactory(serializerFactory);
-		out.writeObject(object);
-	}
+    @Override
+    public void serialize(Object object, OutputStream outputStream) throws IOException {
+        HessianOutput out = new HessianOutput(outputStream);
+        out.setSerializerFactory(serializerFactory);
+        out.writeObject(object);
+        out.flush();
+    }
 
-	@Override
-	public <T> T deserialize(byte[] serializedObject, Class<T> objectClass) throws
IOException {
+    @Override
+    public <T> T deserialize(byte[] serializedObject, Class<T> objectClass) throws
IOException {
         HessianInput in = new HessianInput(new ByteArrayInputStream(serializedObject));
         in.setSerializerFactory(serializerFactory);
 
         return objectClass.cast(in.readObject());
-	}
+    }
 
-	@Override
+    @Override
     public <T> T deserialize(InputStream input, Class<T> objectClass) throws
IOException {
         HessianInput in = new HessianInput(input);
         in.setSerializerFactory(serializerFactory);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPSerializationService.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPSerializationService.java
b/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPSerializationService.java
index 18c8cdb..486b0e9 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPSerializationService.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPSerializationService.java
@@ -23,12 +23,12 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 public interface ROPSerializationService {
-    
+
     byte[] serialize(Object object) throws IOException;
-	
-	void serialize(Object object, OutputStream outputStream) throws IOException;
-    
+
+    void serialize(Object object, OutputStream outputStream) throws IOException;
+
     <T> T deserialize(InputStream inputStream, Class<T> objectClass) throws IOException;
-	
-	<T> T deserialize(byte[] serializedObject, Class<T> objectClass) throws IOException;
+
+    <T> T deserialize(byte[] serializedObject, Class<T> objectClass) throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/c775dc49/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPServlet.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPServlet.java b/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPServlet.java
index db8d5fb..8c12baf 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPServlet.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/rop/ROPServlet.java
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.rop;
 
+import com.caucho.services.server.ServiceContext;
 import org.apache.cayenne.configuration.CayenneRuntime;
 import org.apache.cayenne.configuration.rop.server.ROPServerModule;
 import org.apache.cayenne.configuration.server.ServerRuntime;
@@ -90,33 +91,43 @@ public class ROPServlet extends HttpServlet {
     @Override
     protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
 		try {
-			String operation = req.getParameter(ROPConstants.OPERATION_PARAMETER);
-
-			if (operation != null) {
-				switch (operation) {
-					case ROPConstants.ESTABLISH_SESSION_OPERATION:
-						RemoteSession session = remoteService.establishSession();
-						serializationService.serialize(session, resp.getOutputStream());
-						break;
-					case ROPConstants.ESTABLISH_SHARED_SESSION_OPERATION:
-						String sessionName = req.getParameter(ROPConstants.SESSION_NAME_PARAMETER);
-						RemoteSession sharedSession = remoteService.establishSharedSession(sessionName);
-
-						serializationService.serialize(sharedSession, resp.getOutputStream());
-						break;
-					default:
-						throw new ServletException("Unknown operation: " + operation);
-				}
-			} else {
-					Object response = remoteService.processMessage(
-							serializationService.deserialize(req.getInputStream(), ClientMessage.class));
-
-					serializationService.serialize(response, resp.getOutputStream());
-			}
-		} catch (RuntimeException | ServletException e) {
-			throw e;
-		} catch (Throwable e) {
-			throw new ServletException(e);
-		}
+            String serviceId = req.getPathInfo();
+            String objectId = req.getParameter("id");
+
+            if (objectId == null) {
+                objectId = req.getParameter("ejbid");
+            }
+
+            // TODO: need to untangle HttpRemoteService from dependence on Hessian's ServiceContext
thread local setup
+            ServiceContext.begin(req, resp, serviceId, objectId);
+
+            String operation = req.getParameter(ROPConstants.OPERATION_PARAMETER);
+
+            if (operation != null) {
+                switch (operation) {
+                    case ROPConstants.ESTABLISH_SESSION_OPERATION:
+                        RemoteSession session = remoteService.establishSession();
+                        serializationService.serialize(session, resp.getOutputStream());
+                        break;
+                    case ROPConstants.ESTABLISH_SHARED_SESSION_OPERATION:
+                        String sessionName = req.getParameter(ROPConstants.SESSION_NAME_PARAMETER);
+                        RemoteSession sharedSession = remoteService.establishSharedSession(sessionName);
+
+                        serializationService.serialize(sharedSession, resp.getOutputStream());
+                        break;
+                    default:
+                        throw new ServletException("Unknown operation: " + operation);
+                }
+            } else {
+                Object response = remoteService.processMessage(
+                        serializationService.deserialize(req.getInputStream(), ClientMessage.class));
+
+                serializationService.serialize(response, resp.getOutputStream());
+            }
+        } catch (RuntimeException | ServletException e) {
+            throw e;
+        } catch (Throwable e) {
+            throw new ServletException(e);
+        }
     }
 }


Mime
View raw message