geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r774775 - in /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src: main/java/org/apache/geronimo/tomcat/cluster/ main/java/org/apache/geronimo/tomcat/cluster/wadi/ test/java/org/apache/geronimo/tomcat/cluster/
Date Thu, 14 May 2009 14:15:11 GMT
Author: gdamour
Date: Thu May 14 14:15:11 2009
New Revision: 774775

URL: http://svn.apache.org/viewvc?rev=774775&view=rev
Log:
Strips and augments requested session IDs with a jvmRoute sets to the name of the processing
node. Integration tests with mod_jk are yet to be conducted.

This fixes GERONIMO-4626 - Tomcat Clustering with WADI - JSESSIONID with jvmRoute to support
mod_jk routing

Added:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/JkRouter.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/NoOpRouter.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/Router.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/JkRouterTest.java
Modified:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/AbstractClusteredValve.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValve.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValveRetriever.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/AnAbstractClusteredValveTest.java

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/AbstractClusteredValve.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/AbstractClusteredValve.java?rev=774775&r1=774774&r2=774775&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/AbstractClusteredValve.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/AbstractClusteredValve.java
Thu May 14 14:15:11 2009
@@ -34,9 +34,29 @@
  * @version $Rev:$ $Date:$
  */
 public abstract class AbstractClusteredValve extends ValveBase {
+    private final String nodeName;
+    private final Router router;
+    
+    public AbstractClusteredValve(String nodeName) {
+        if (null == nodeName) {
+            throw new IllegalArgumentException("nodeName is required");
+        }
+        this.nodeName = nodeName;
+        
+        router = newRouter();
+    }
+
+    protected JkRouter newRouter() {
+        return new JkRouter();
+    }
 
     @Override
     public void invoke(Request request, Response response) throws IOException, ServletException
{
+        if (null == request) {
+            next.invoke(request, response);
+            return;
+        }
+        
         ClusteredInvocation invocation = newClusteredInvocation(request, response);
         try {
             invocation.invoke();
@@ -64,13 +84,18 @@
         }
 
         protected void invokeLocally() throws ClusteredInvocationException {
+            String oldRequestedSessionId = router.stripRoutingInfoFromRequestedSessionId(request);
             try {
                 next.invoke(request, response);
             } catch (IOException e) {
                 throw new ClusteredInvocationException(e);
             } catch (ServletException e) {
                 throw new ClusteredInvocationException(e);
+            } finally {
+                request.setRequestedSessionId(oldRequestedSessionId);
             }
+            
+            router.writeSessionIdWithRoutingInfo(request, response, nodeName);
         }
 
         public String getRequestedSessionId() {

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/JkRouter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/JkRouter.java?rev=774775&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/JkRouter.java
(added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/JkRouter.java
Thu May 14 14:15:11 2009
@@ -0,0 +1,102 @@
+/*
+ * 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.geronimo.tomcat.cluster;
+
+import javax.servlet.http.Cookie;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Globals;
+import org.apache.catalina.Session;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ * setNewSessionCookie contains code copied from
+ * org.apache.catalina.ha.session.JvmRouteBinderValve.setNewSessionCookie contributed by
Peter Rossbach.
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class JkRouter implements Router {
+
+    public String stripRoutingInfoFromRequestedSessionId(Request request) {
+        String requestedSessionId = request.getRequestedSessionId();
+        if (null != requestedSessionId) {
+            int index = requestedSessionId.indexOf(".");
+            if (0 < index) {
+                String newRequestedSessionId = requestedSessionId.substring(0, index);
+                request.setRequestedSessionId(newRequestedSessionId);
+            }
+        }
+        return requestedSessionId;
+    }
+
+    public void writeSessionIdWithRoutingInfo(Request request, Response response, String
nodeName) {
+        String augmentedSessionID = buildAugmentedSessionId(request, nodeName);
+        if (null == augmentedSessionID) {
+            return;
+        }
+        
+        setNewSessionCookie(request, response, augmentedSessionID);
+    }
+
+    protected void setNewSessionCookie(Request request, Response response, String augmentedSessionID)
{
+        Context context = request.getContext();
+        if (context.getCookies()) {
+            Cookie newCookie = new Cookie(Globals.SESSION_COOKIE_NAME, augmentedSessionID);
+            newCookie.setMaxAge(-1);
+            String contextPath = null;
+            if (!response.getConnector().getEmptySessionPath() && (context != null))
{
+                contextPath = context.getEncodedPath();
+            }
+            if ((contextPath != null) && (contextPath.length() > 0)) {
+                newCookie.setPath(contextPath);
+            } else {
+                newCookie.setPath("/");
+            }
+            if (request.isSecure()) {
+                newCookie.setSecure(true);
+            }
+            response.addCookie(newCookie);
+        }
+    }
+
+    protected String buildAugmentedSessionId(Request request, String nodeName) {
+        Session sessionInternal = request.getSessionInternal();
+        if (null == sessionInternal) {
+            return null;
+        }
+
+        String internalSessionID = sessionInternal.getId();
+        String actualSessionId = request.getRequestedSessionId();
+        if (null == actualSessionId || !actualSessionId.startsWith(internalSessionID)) {
+            actualSessionId = internalSessionID;
+        }
+        
+        int index = actualSessionId.indexOf(".");
+        if (0 < index) {
+            String embeddedNodeName = actualSessionId.substring(index + 1);
+            if (embeddedNodeName.equals(nodeName)) {
+                return null;
+            }
+            actualSessionId = actualSessionId.substring(0, index);
+        }
+        return actualSessionId + "." + nodeName;
+    }
+}
\ No newline at end of file

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/NoOpRouter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/NoOpRouter.java?rev=774775&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/NoOpRouter.java
(added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/NoOpRouter.java
Thu May 14 14:15:11 2009
@@ -0,0 +1,38 @@
+/*
+ * 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.geronimo.tomcat.cluster;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class NoOpRouter implements Router {
+    
+    public String stripRoutingInfoFromRequestedSessionId(Request request) {
+        return request.getRequestedSessionId();
+    }
+
+    public void writeSessionIdWithRoutingInfo(Request request, Response response, String
nodeName) {
+    }
+
+}

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/Router.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/Router.java?rev=774775&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/Router.java
(added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/Router.java
Thu May 14 14:15:11 2009
@@ -0,0 +1,33 @@
+/*
+ * 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.geronimo.tomcat.cluster;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface Router {
+    String stripRoutingInfoFromRequestedSessionId(Request request);
+    
+    void writeSessionIdWithRoutingInfo(Request request, Response response, String nodeName);
+}
\ No newline at end of file

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValve.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValve.java?rev=774775&r1=774774&r2=774775&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValve.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValve.java
Thu May 14 14:15:11 2009
@@ -19,29 +19,18 @@
 
 package org.apache.geronimo.tomcat.cluster.wadi;
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.Principal;
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.Map;
 
 import javax.servlet.FilterChain;
-import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
-import javax.servlet.ServletContext;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
 
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.geronimo.clustering.ClusteredInvocation;
 import org.apache.geronimo.clustering.ClusteredInvocationException;
+import org.apache.geronimo.clustering.wadi.WADISessionManager;
 import org.apache.geronimo.tomcat.cluster.AbstractClusteredValve;
 import org.codehaus.wadi.core.contextualiser.InvocationException;
 import org.codehaus.wadi.core.manager.Manager;
@@ -55,8 +44,9 @@
 public class WADIClusteredValve extends AbstractClusteredValve {
     private final Manager wadiManager;
 
-    public WADIClusteredValve(Manager wadiManager) {
-        this.wadiManager = wadiManager;
+    public WADIClusteredValve(WADISessionManager sessionManager) {
+        super(sessionManager.getNode().getName());
+        this.wadiManager = sessionManager.getManager();
     }
     
     protected ClusteredInvocation newClusteredInvocation(Request request, Response response)
{
@@ -80,7 +70,7 @@
                     }
                 }
             };
-            invocation.init(null == request? NoOpHttpServletRequest.SINGLETON: request, response,
chainAdapter);
+            invocation.init(request, response, chainAdapter);
             try {
                 wadiManager.contextualise(invocation);
             } catch (InvocationException e) {
@@ -95,324 +85,5 @@
             }
         }
     }
-
-    protected static class NoOpHttpServletRequest implements HttpServletRequest {
-        public static final NoOpHttpServletRequest SINGLETON = new NoOpHttpServletRequest();
-
-        public String getAuthType() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getContextPath() {
-            throw new UnsupportedOperationException();
-        }
-
-        public Cookie[] getCookies() {
-            throw new UnsupportedOperationException();
-        }
-
-        public long getDateHeader(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getHeader(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public Enumeration getHeaderNames() {
-            throw new UnsupportedOperationException();
-        }
-
-        public Enumeration getHeaders(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public int getIntHeader(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getMethod() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getPathInfo() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getPathTranslated() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getQueryString() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getRemoteUser() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getRequestURI() {
-            throw new UnsupportedOperationException();
-        }
-
-        public StringBuffer getRequestURL() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getRequestedSessionId() {
-            return null;
-        }
-
-        public String getServletPath() {
-            throw new UnsupportedOperationException();
-        }
-
-        public HttpSession getSession() {
-            throw new UnsupportedOperationException();
-        }
-
-        public HttpSession getSession(boolean arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public Principal getUserPrincipal() {
-            throw new UnsupportedOperationException();
-        }
-
-        public boolean isRequestedSessionIdFromCookie() {
-            throw new UnsupportedOperationException();
-        }
-
-        public boolean isRequestedSessionIdFromURL() {
-            throw new UnsupportedOperationException();
-        }
-
-        public boolean isRequestedSessionIdFromUrl() {
-            throw new UnsupportedOperationException();
-        }
-
-        public boolean isRequestedSessionIdValid() {
-            throw new UnsupportedOperationException();
-        }
-
-        public boolean isUserInRole(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public Object getAttribute(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public Enumeration getAttributeNames() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getCharacterEncoding() {
-            throw new UnsupportedOperationException();
-        }
-
-        public int getContentLength() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getContentType() {
-            throw new UnsupportedOperationException();
-        }
-
-        public ServletInputStream getInputStream() throws IOException {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getLocalAddr() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getLocalName() {
-            throw new UnsupportedOperationException();
-        }
-
-        public int getLocalPort() {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * Get the servlet context the request-response pair was last dispatched through.
-         *
-         * @return the latest ServletContext on the dispatch chain.
-         * @since 3.0
-         */
-        public ServletContext getServletContext() {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * Gets the associated servlet response.
-         *
-         * @return the ServletResponse associated with this request.
-         * @since 3.0
-         */
-        public ServletResponse getServletResponse() {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * complete a suspended request.
-         *
-         * @throws IllegalStateException
-         * @since 3.0
-         */
-        public void complete() throws IllegalStateException {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * Suspend request processing.  Must be called by a thread that is processing this
request.
-         *
-         * @param timeoutMilliseconds new timeout period, in milliseconds
-         * @throws IllegalStateException if called by a thread not processing this request
or after error dispatch
-         * @see #complete
-         * @see #resume
-         * @since 3.0
-         */
-        public void suspend(long timeoutMilliseconds) throws IllegalStateException {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * Similar to suspend(timeoutMilliseconds) but with a container supplied timeout
period.
-         *
-         * @throws IllegalStateException
-         * @see #complete
-         * @see #resume
-         * @since 3.0
-         */
-        public void suspend() throws IllegalStateException {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * Resume a suspended request
-         *
-         * @throws IllegalStateException if the request is not suspended
-         * @see #suspend
-         * @since 3.0
-         */
-        public void resume() throws IllegalStateException {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * @return if the request is suspended
-         * @since 3.0
-         */
-        public boolean isSuspended() {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * @return if the request is resumed
-         * @since 3.0
-         */
-        public boolean isResumed() {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * @return if the request is timed out
-         * @since 3.0
-         */
-        public boolean isTimeout() {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * @return if the request has never been suspended (or resumed)
-         * @since 3.0
-         */
-        public boolean isInitial() {
-            throw new UnsupportedOperationException();
-        }
-
-        public Locale getLocale() {
-            throw new UnsupportedOperationException();
-        }
-
-        public Enumeration getLocales() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getParameter(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public Map getParameterMap() {
-            throw new UnsupportedOperationException();
-        }
-
-        public Enumeration getParameterNames() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String[] getParameterValues(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getProtocol() {
-            throw new UnsupportedOperationException();
-        }
-
-        public BufferedReader getReader() throws IOException {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getRealPath(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getRemoteAddr() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getRemoteHost() {
-            throw new UnsupportedOperationException();
-        }
-
-        public int getRemotePort() {
-            throw new UnsupportedOperationException();
-        }
-
-        public RequestDispatcher getRequestDispatcher(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getScheme() {
-            throw new UnsupportedOperationException();
-        }
-
-        public String getServerName() {
-            throw new UnsupportedOperationException();
-        }
-
-        public int getServerPort() {
-            throw new UnsupportedOperationException();
-        }
-
-        public boolean isSecure() {
-            throw new UnsupportedOperationException();
-        }
-
-        public void removeAttribute(String arg0) {
-            throw new UnsupportedOperationException();
-        }
-
-        public void setAttribute(String arg0, Object arg1) {
-            throw new UnsupportedOperationException();
-        }
-
-        public void setCharacterEncoding(String arg0) throws UnsupportedEncodingException
{
-            throw new UnsupportedOperationException();
-        }
-        
-    }
     
 }

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValveRetriever.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValveRetriever.java?rev=774775&r1=774774&r2=774775&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValveRetriever.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/WADIClusteredValveRetriever.java
Thu May 14 14:15:11 2009
@@ -23,7 +23,6 @@
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.tomcat.ObjectRetriever;
-import org.codehaus.wadi.core.manager.Manager;
 
 
 /**
@@ -32,18 +31,16 @@
  */
 public class WADIClusteredValveRetriever implements ObjectRetriever, GBeanLifecycle {
     private final WADISessionManager sessionManager;
-    private Manager wadiManager;
 
     public WADIClusteredValveRetriever(@ParamReference(name=GBEAN_REF_WADI_SESSION_MANAGER)
WADISessionManager sessionManager) {
         this.sessionManager = sessionManager;
     }
     
     public Object getInternalObject() {
-        return new WADIClusteredValve(wadiManager);
+        return new WADIClusteredValve(sessionManager);
     }
 
     public void doStart() throws Exception {
-        wadiManager = sessionManager.getManager();
     }
     
     public void doStop() throws Exception {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/AnAbstractClusteredValveTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/AnAbstractClusteredValveTest.java?rev=774775&r1=774774&r2=774775&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/AnAbstractClusteredValveTest.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/AnAbstractClusteredValveTest.java
Thu May 14 14:15:11 2009
@@ -44,7 +44,7 @@
 
     @Override
     protected void setUp() throws Exception {
-        valve = new AbstractClusteredValve() {
+        valve = new AbstractClusteredValve("NODE") {
             @Override
             protected ClusteredInvocation newClusteredInvocation(Request request, Response
response) {
                 return new WebClusteredInvocation(request, response) {
@@ -100,7 +100,7 @@
     
     public void testCIEIsWrappedAsIOE() throws Exception {
         final ClusteredInvocationException expected = new ClusteredInvocationException();
-        valve = new AbstractClusteredValve() {
+        valve = new AbstractClusteredValve("NODE") {
             @Override
             protected ClusteredInvocation newClusteredInvocation(Request request, Response
response) {
                 return new WebClusteredInvocation(request, response) {

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/JkRouterTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/JkRouterTest.java?rev=774775&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/JkRouterTest.java
(added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6-clustering-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/JkRouterTest.java
Thu May 14 14:15:11 2009
@@ -0,0 +1,94 @@
+/*
+ * 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.geronimo.tomcat.cluster;
+
+import org.apache.catalina.Session;
+import org.apache.catalina.connector.Request;
+
+import com.agical.rmock.extension.junit.RMockTestCase;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class JkRouterTest extends RMockTestCase {
+
+    private JkRouter router;
+    private Request request;
+    private Session mockSession;
+    private String sessionId;
+    private String nodeName;
+    private String requestedSessionId;
+
+    @Override
+    protected void setUp() throws Exception {
+        router = new JkRouter();
+        
+        mockSession = (Session) mock(Session.class);
+        request = new Request() {
+            @Override
+            public Session getSessionInternal() {
+                return mockSession;
+            }
+        };
+
+        sessionId = "ID";
+        nodeName = "NODE";
+        requestedSessionId = sessionId + "." + nodeName;
+    }
+    
+    public void testStripRountingInfo() throws Exception {
+        request.setRequestedSessionId(requestedSessionId);
+        
+        assertEquals(requestedSessionId, router.stripRoutingInfoFromRequestedSessionId(request));
+        assertEquals(sessionId, request.getRequestedSessionId());
+    }
+
+    public void testBuildAugmentedSessionIdWhenNewSession() throws Exception {
+        request.setRequestedSessionId("OLDSession");
+        mockSession.getId();
+        modify().returnValue(sessionId);
+
+        startVerification();
+        
+        assertEquals(requestedSessionId, router.buildAugmentedSessionId(request, nodeName));
+    }
+    
+    public void testBuildAugmentedSessionIdReturnsNullWhenNoSession() throws Exception {
+        request = new Request() {
+            @Override
+            public Session getSessionInternal() {
+                return null;
+            }
+        };
+        assertNull(router.buildAugmentedSessionId(request, "NODE"));
+    }
+    
+    public void testBuildAugmentedSessionIdReturnsNullWhenNoAugmentationIsRequired() throws
Exception {
+        request.setRequestedSessionId(requestedSessionId);
+        mockSession.getId();
+        modify().returnValue(sessionId);
+
+        startVerification();
+        
+        assertNull(router.buildAugmentedSessionId(request, nodeName));
+    }
+    
+}



Mime
View raw message