[wsas-java-dev] svn commit r668 - in wsas/java/trunk/modules: core/src/org/wso2/wsas core/src/org/wso2/wsas/util distribution servlet-edition/src/org/wso2/wsas standalone-edition/src/org/wso2/wsas/transport/jetty www/extensions/core/js

svn at wso2.com svn at wso2.com
Thu Feb 1 04:16:32 PST 2007


Author: saminda
Date: Thu Feb  1 04:16:13 2007
New Revision: 668

Modified:
   wsas/java/trunk/modules/core/src/org/wso2/wsas/ServerConstants.java
   wsas/java/trunk/modules/core/src/org/wso2/wsas/util/FileDownloadUtil.java
   wsas/java/trunk/modules/distribution/pom.xml
   wsas/java/trunk/modules/servlet-edition/src/org/wso2/wsas/FileDownloadServlet.java
   wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2FileDownloadHandler.java
   wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2FileUploadHandler.java
   wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2Handler.java
   wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/JettyServer.java
   wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/ManagementConsoleRequestHandler.java
   wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/ServerHandler.java
   wsas/java/trunk/modules/www/extensions/core/js/wso2wsas.js
Log:
Changes to cope with cookie handling and cleaning up unnecessary methods. In some class there are SOUTS, they will be 
cleaned up eventually. 


Modified: wsas/java/trunk/modules/core/src/org/wso2/wsas/ServerConstants.java
==============================================================================
--- wsas/java/trunk/modules/core/src/org/wso2/wsas/ServerConstants.java	(original)
+++ wsas/java/trunk/modules/core/src/org/wso2/wsas/ServerConstants.java	Thu Feb  1 04:16:13 2007
@@ -109,5 +109,6 @@
     public static class Jetty {
         public static final String HTTP_SERVER = "jetty.http.server";
         public static final String HTTPS_SERVER = "jetty.https.server";
+        public static final String JSESSIONID = "JSESSIONID";
     }
 }

Modified: wsas/java/trunk/modules/core/src/org/wso2/wsas/util/FileDownloadUtil.java
==============================================================================
--- wsas/java/trunk/modules/core/src/org/wso2/wsas/util/FileDownloadUtil.java	(original)
+++ wsas/java/trunk/modules/core/src/org/wso2/wsas/util/FileDownloadUtil.java	Thu Feb  1 04:16:13 2007
@@ -1,23 +1,24 @@
-/*                                                                             
+/*
  * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
- *                                                                             
- * Licensed 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.                                              
+ *
+ * Licensed 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.wso2.wsas.util;
 
 import org.wso2.wsas.ServerConstants;
 import org.wso2.utils.ServerException;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -28,14 +29,14 @@
 import java.util.Map;
 
 /**
- * 
+ *
  */
 public class FileDownloadUtil {
 
     public FileDownloadUtil() {
     }
 
-    public synchronized boolean processPostRequest(MessageContext msgContext,
+    public synchronized boolean acquireResource(ConfigurationContext configurationContext,
                                          HttpServletRequest request,
                                          HttpServletResponse response) throws ServerException {
         OutputStream out;
@@ -46,7 +47,7 @@
         }
 
         Map fileResourcesMap =
-                (Map) msgContext.getConfigurationContext().
+                (Map) configurationContext.
                         getProperty(ServerConstants.FILE_RESOURCE_MAP);
         String filename = (String) fileResourcesMap.get(request.getParameter("id"));
         if (filename == null) {
@@ -79,10 +80,5 @@
         }
     }
 
-    public synchronized boolean processGetRequest(MessageContext msgContext,
-                                        HttpServletRequest request,
-                                        HttpServletResponse response) throws ServerException {
 
-        return processPostRequest(msgContext, request, response);
-    }
 }

Modified: wsas/java/trunk/modules/distribution/pom.xml
==============================================================================
--- wsas/java/trunk/modules/distribution/pom.xml	(original)
+++ wsas/java/trunk/modules/distribution/pom.xml	Thu Feb  1 04:16:13 2007
@@ -97,8 +97,8 @@
     <modules>
         <module>common</module>
         <module>standalone</module>
-        <module>webapp</module>
-        <module>release</module>
+        <!--<module>webapp</module>-->
+        <!--<module>release</module>-->
     </modules>
 
 </project>
\ No newline at end of file

Modified: wsas/java/trunk/modules/servlet-edition/src/org/wso2/wsas/FileDownloadServlet.java
==============================================================================
--- wsas/java/trunk/modules/servlet-edition/src/org/wso2/wsas/FileDownloadServlet.java	(original)
+++ wsas/java/trunk/modules/servlet-edition/src/org/wso2/wsas/FileDownloadServlet.java	Thu Feb  1 04:16:13 2007
@@ -1,17 +1,17 @@
-/*                                                                             
+/*
  * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
- *                                                                             
- * Licensed 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.                                              
+ *
+ * Licensed 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.wso2.wsas;
 
@@ -20,18 +20,16 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.transport.http.AxisServlet;
 import org.apache.log4j.Logger;
+import org.wso2.utils.ServerException;
+import org.wso2.wsas.util.FileDownloadUtil;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
 import java.io.IOException;
 
-import org.wso2.wsas.util.FileDownloadUtil;
-import org.wso2.utils.ServerException;
-
 public class FileDownloadServlet extends AxisServlet {
 
     private static final long serialVersionUID = 6074514253507510250L;
@@ -45,9 +43,7 @@
         MessageContext msgCtx = null;
         try {
             msgCtx = createMessageContext(req, res);
-            fileDownloadUtil.processPostRequest(msgCtx,
-                                                req,
-                                                res);
+            fileDownloadUtil.acquireResource(configContext, req, res);
         } catch (ServerException e) {
             String msg = "Cannot download file";
             log.error(msg, e);
@@ -66,9 +62,7 @@
         MessageContext msgCtx = null;
         try {
             msgCtx = createMessageContext(req, res);
-            fileDownloadUtil.processGetRequest(msgCtx,
-                                               req,
-                                               res);
+            fileDownloadUtil.acquireResource(configContext,req,res);
         } catch (ServerException e) {
             String msg = "Cannot download file";
             log.error(msg, e);

Modified: wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2FileDownloadHandler.java
==============================================================================
--- wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2FileDownloadHandler.java	(original)
+++ wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2FileDownloadHandler.java	Thu Feb  1 04:16:13 2007
@@ -1,17 +1,17 @@
-/*                                                                             
+/*
  * Copyright 2005,2006 WSO2, Inc. http://www.wso2.org
- *                                                                             
- * Licensed 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.                                              
+ *
+ * Licensed 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.wso2.wsas.transport.jetty;
 
@@ -20,45 +20,44 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.AxisFault;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.HttpConnection;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
 
 /**
- * 
+ *
  */
-public class Axis2FileDownloadHandler extends Axis2Handler {
-    
+public class Axis2FileDownloadHandler extends AbstractHandler {
+
     private FileDownloadUtil fileDownloadUtil;
+    private ConfigurationContext configurationContext;
 
     public Axis2FileDownloadHandler(ConfigurationContext configurationContext) {
-        super(configurationContext);
+        this.configurationContext = configurationContext;
         fileDownloadUtil = new FileDownloadUtil();
     }
 
-    protected boolean processPostRequest(MessageContext msgContext,
+    private  void downloadFile(ConfigurationContext configurationContext,
                                          HttpServletRequest request,
                                          HttpServletResponse response) throws AxisFault {
 
         try {
-            return fileDownloadUtil.processPostRequest(msgContext,
-                                                       request,
-                                                       response);
+            fileDownloadUtil.acquireResource(configurationContext, request, response);
         } catch (ServerException e) {
             throw new AxisFault(e);
         }
     }
 
-    protected boolean processGetRequest(MessageContext msgContext,
-                                        HttpServletRequest request,
-                                        HttpServletResponse response) throws AxisFault {
-
-        try {
-            return fileDownloadUtil.processGetRequest(msgContext,
-                                                      request,
-                                                      response);
-        } catch (ServerException e) {
-            throw new AxisFault(e);
-        }
+    public void handle(String target, HttpServletRequest request, HttpServletResponse response,
+                       int dispatch) throws IOException, ServletException {
+        Request baseRequest = (request instanceof Request) ? (Request) request :
+                              HttpConnection.getCurrentConnection().getRequest();
+        baseRequest.setHandled(true);
+        downloadFile(configurationContext,request,response);
     }
 }

Modified: wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2FileUploadHandler.java
==============================================================================
--- wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2FileUploadHandler.java	(original)
+++ wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2FileUploadHandler.java	Thu Feb  1 04:16:13 2007
@@ -17,29 +17,28 @@
 */
 package org.wso2.wsas.transport.jetty;
 
-import org.wso2.utils.ServerException;
-import org.wso2.wsas.transport.fileupload.FileUploadExecutorManager;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.mortbay.jetty.HttpConnection;
 import org.mortbay.jetty.Request;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.wso2.utils.ServerException;
+import org.wso2.wsas.transport.fileupload.FileUploadExecutorManager;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
-public class Axis2FileUploadHandler extends Axis2Handler {
+public class Axis2FileUploadHandler extends AbstractHandler {
 
     private static Log log = LogFactory.getLog(Axis2FileUploadHandler.class);
 
-    FileUploadExecutorManager fileUploadExecutorManager;
+    private FileUploadExecutorManager fileUploadExecutorManager;
 
     public Axis2FileUploadHandler(ConfigurationContext configurationContext) {
-        super(configurationContext);
         try {
             fileUploadExecutorManager = new FileUploadExecutorManager(configurationContext);
         } catch (ServerException e) {
@@ -48,13 +47,10 @@
     }
 
 
-    protected boolean processPostRequest(MessageContext msgContext,
-                                         HttpServletRequest request,
-                                         HttpServletResponse response) throws AxisFault {
+    private void uploadFile(HttpServletRequest request, HttpServletResponse response) throws AxisFault {
 
-//        return fileUploadUtil.processPostRequest(msgContext, request, response);
         try {
-            return fileUploadExecutorManager.execute(request, response);
+            fileUploadExecutorManager.execute(request, response);
         } catch (IOException e) {
             throw new AxisFault(e);
         } catch (ServerException e) {
@@ -62,12 +58,7 @@
         }
     }
 
-    protected boolean processGetRequest(MessageContext msgContext,
-                                        HttpServletRequest request,
-                                        HttpServletResponse response) throws AxisFault {
-        //no need to implement this
-        return false;
-    }
+
 
     public void handle(String target, HttpServletRequest request, HttpServletResponse response,
                        int dispatch) throws IOException, ServletException {
@@ -77,7 +68,7 @@
         try {
             String method = request.getMethod();
             if (org.wso2.wsas.ServerConstants.HTTPConstants.HTTP_METHOD_POST.equals(method)) {
-                processPostRequest(null, request, response);
+                uploadFile(request, response);
             }
         } catch (AxisFault e) {
             throw new ServletException(e);

Modified: wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2Handler.java
==============================================================================
--- wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2Handler.java	(original)
+++ wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/Axis2Handler.java	Thu Feb  1 04:16:13 2007
@@ -15,7 +15,9 @@
  */
 package org.wso2.wsas.transport.jetty;
 
-import org.wso2.utils.ServerConfiguration;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPFaultCode;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
@@ -30,21 +32,22 @@
 import org.apache.axis2.util.UUIDGenerator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.axiom.soap.SOAPFaultCode;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.om.OMElement;
-import org.mortbay.jetty.handler.AbstractHandler;
-import org.mortbay.jetty.Request;
 import org.mortbay.jetty.HttpConnection;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.wso2.utils.NetworkUtils;
+import org.wso2.utils.ServerConfiguration;
+import org.wso2.wsas.ServerConstants;
 
 import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
-import javax.servlet.http.Cookie;
 import javax.xml.namespace.QName;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.net.SocketException;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -236,52 +239,66 @@
     }
 
     protected void manageSessionContext(HttpServletRequest request, HttpServletResponse response,
-                                        MessageContext msgContext) {
+                                        MessageContext msgContext) throws ServletException {
 
         //TODO due instance dispatcher depends on httpServletRequest.
 
+        ////////////////////////////////////////////////////////////
+        Cookie[] cookies = request.getCookies();
+        if (cookies != null) {
+            for (int i = 0; i < cookies.length; i++) {
+                Cookie cookie = cookies[i];
+                System.out.print("## Cookie value  :: " + cookie.getValue() +
+                                 "## cookie name :: " + cookie.getName() + " ### cookie path :: " + cookie.getPath() +" ##");
+            }
+        }
+        if (cookies != null)
+            System.out.print(" ### Cookie length  :: " + cookies.length + "\n");
+
+        ///////////////////////////////////////////////////////////
         HttpSession httpSession = request.getSession(true);
 
         if (httpSession != null) {
             // session manangement is ON for handlers
             SessionContext sessionContext =
                     (SessionContext) httpSession.getAttribute(Constants.SESSION_CONTEXT_PROPERTY);
-            if (sessionContext == null) {
-                System.out.println("### Created New SessionContext :: context root :: " +
-                                   request.getContextPath() + " :: Request URI :: " +
-                                   request.getRequestURI());
-                String cookieValueString = createSessionCookie(response);
-                sessionContext = new SessionContext(null);
-                sessionContext.setCookieID(cookieValueString);
-                httpSession.setAttribute(Constants.SESSION_CONTEXT_PROPERTY, sessionContext);
-                msgContext.setSessionContext(sessionContext);
+            if (sessionContext == null && httpSession.isNew()) {
+                if (!explicitlyIngnorePaths(request)) {
+                    System.out.print(" ### Created New SessionContext Request URI :: " +
+                                     request.getRequestURI());
+//                    String cookieValueString = createSessionCookie(response);
+                    String cookieValueString = httpSession.getId();
+                    System.out.print(" \n### new Cookie Id :: " + cookieValueString + "\n");
+                    sessionContext = new SessionContext(null);
+                    sessionContext.setCookieID(cookieValueString);
+                    httpSession.setAttribute(Constants.SESSION_CONTEXT_PROPERTY, sessionContext);
+                    msgContext.setSessionContext(sessionContext);
+                }
             } else {
-                System.out.println(
-                        "#### Uesed Exising SessionContet ::  " + sessionContext.getCookieID() +
-                        "  Context Path :: " + request.getContextPath() + " :: Request URI " +
-                        request.getRequestURI());
+//                response.addCookie(createCookieForSession(ServerConstants.Jetty.JSESSIONID,
+//                                                          sessionContext.getCookieID()));
+                System.out
+                        .println("##### Using existing session :: " + sessionContext.getCookieID());
             }
 
         }
 
     }
+    
+    /**
+     * This is a temp method; that will used to temporary supress creation of SessionContexts
+     *
+     * @param request
+     * @return bolean
+     * @depricate
+     */
+    private boolean explicitlyIngnorePaths(HttpServletRequest request) {
+        String matchingString = "statistics";
+        return request.getRequestURI().indexOf(matchingString) > -1;
 
-    private String createSessionCookie(HttpServletResponse response) {
-        String cookieValueString = Long.toString(System.currentTimeMillis());
-        Cookie userCookie = new Cookie("__WSAS_SESSION_COOKIE__", cookieValueString);
-        userCookie.setMaxAge(-1); // When the browse exists cookie will die.
-        userCookie.setPath("/");
-        userCookie.setSecure(true);
-        response.addCookie(userCookie);
-        /*This is to handle anything from Axis2 client*/
-        Cookie axis2Cookie = new Cookie(Constants.SESSION_COOKIE,cookieValueString);
-        axis2Cookie.setMaxAge(-1); // When the browse exists cookie will die.
-        axis2Cookie.setPath("/");
-        axis2Cookie.setSecure(true);
-        response.addCookie(axis2Cookie);
-        return cookieValueString;
     }
 
+
     protected abstract boolean processPostRequest(MessageContext msgContext,
                                                   HttpServletRequest request,
                                                   HttpServletResponse response)

Modified: wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/JettyServer.java
==============================================================================
--- wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/JettyServer.java	(original)
+++ wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/JettyServer.java	Thu Feb  1 04:16:13 2007
@@ -33,7 +33,7 @@
 
 /**
  * This is an implementation of a transport listener based on MortBay Jetty
- * 6.0.1 distribution.
+ * 6.1.1 distribution.
  */
 public class JettyServer {
 
@@ -73,11 +73,11 @@
                 // Hold HTTP related Contexts
                 ContextHandler context1 = new ContextHandler();
                 context1.setContextPath(jettyConfig.docsWebCtx);
-                SessionHandler sessionHandler1 = new SessionHandler();
+//                SessionHandler sessionHandler1 = new SessionHandler();
                 ResourceHandler docsResourceHandler = new ResourceHandler();
                 docsResourceHandler.setResourceBase(jettyConfig.docsWebResourceBase);
-                sessionHandler1.addHandler(docsResourceHandler);
-                context1.addHandler(sessionHandler1);
+//                sessionHandler1.addHandler(docsResourceHandler);
+                context1.addHandler(docsResourceHandler);
 
                 ContextHandler context2 = new ContextHandler();
                 context2.setContextPath(initializeServiceUrlContextPath(configurationContext));
@@ -96,52 +96,52 @@
                 ContextHandler context4 = new ContextHandler();
                 context4.setContextPath(jettyConfig.serviceUiWebCtx);
                 ResourceHandler serviceUiResourceHandler = new ResourceHandler();
-                SessionHandler sessionHandler4 = new SessionHandler();
+//                SessionHandler sessionHandler4 = new SessionHandler();
                 serviceUiResourceHandler.setResourceBase(jettyConfig.serviceUiResourceBase);
-                sessionHandler4.addHandler(serviceUiResourceHandler);
-                context4.addHandler(sessionHandler4);
+//                sessionHandler4.addHandler(serviceUiResourceHandler);
+                context4.addHandler(serviceUiResourceHandler);
 
                 ContextHandler context5 = new ContextHandler();
                 context5.setContextPath(jettyConfig.feedsWebCtx);
                 ResourceHandler feedsWebResourceHandler = new ResourceHandler();
-                SessionHandler sessionHandler5 = new SessionHandler();
+//                SessionHandler sessionHandler5 = new SessionHandler();
                 feedsWebResourceHandler.setResourceBase(jettyConfig.feedsWebResourceBase);
-                sessionHandler5.addHandler(feedsWebResourceHandler);
-                context5.addHandler(sessionHandler5);
+//                sessionHandler5.addHandler(feedsWebResourceHandler);
+                context5.addHandler(feedsWebResourceHandler);
 
                 ContextHandler context6 = new ContextHandler();
                 context6.setContextPath(jettyConfig.stylesWebCtx);
                 ResourceHandler schemaWebResourceHandler = new ResourceHandler();
-                SessionHandler sessionHandler6 = new SessionHandler();
+//                SessionHandler sessionHandler6 = new SessionHandler();
                 schemaWebResourceHandler.setResourceBase(jettyConfig.stylesWebResourceBase);
-                sessionHandler6.addHandler(schemaWebResourceHandler);
-                context6.addHandler(sessionHandler6);
+//                sessionHandler6.addHandler(schemaWebResourceHandler);
+                context6.addHandler(schemaWebResourceHandler);
 
                 //File upload context for Http. Used in tools mainly.
                 ContextHandler context11 = new ContextHandler();
                 context11.setContextPath(ServerConstants.ContextPaths.UPLOAD_PATH);
-                SessionHandler sessionHandler11 = new SessionHandler();
+//                SessionHandler sessionHandler11 = new SessionHandler();
                 Handler axis2FileUploadHandler0 = new Axis2FileUploadHandler(configurationContext);
-                sessionHandler11.addHandler(axis2FileUploadHandler0);
-                context11.addHandler(sessionHandler11);
+//                sessionHandler11.addHandler(axis2FileUploadHandler0);
+                context11.addHandler(axis2FileUploadHandler0);
 
                 //File download context for Http. Used in tools mainly.
                 ContextHandler context12 = new ContextHandler();
                 context12.setContextPath(ServerConstants.ContextPaths.DOWNLOAD_PATH);
-                SessionHandler sessionHandler12 = new SessionHandler();
+//                SessionHandler sessionHandler12 = new SessionHandler();
                 Handler axis2FileDownloadHandler0 =
                         new Axis2FileDownloadHandler(configurationContext);
-                sessionHandler12.addHandler(axis2FileDownloadHandler0);
-                context12.addHandler(sessionHandler12);
+//                sessionHandler12.addHandler(axis2FileDownloadHandler0);
+                context12.addHandler(axis2FileDownloadHandler0);
 
                 //For Extra Documents
                 ContextHandler context17 = new ContextHandler();
                 context17.setContextPath(jettyConfig.samplesWebCtx);
                 ResourceHandler extraDocsResourceHandler = new ResourceHandler();
-                SessionHandler sessionHandler17 = new SessionHandler();
+//                SessionHandler sessionHandler17 = new SessionHandler();
                 extraDocsResourceHandler.setResourceBase(jettyConfig.samplesWebResourceBase);
-                sessionHandler17.addHandler(extraDocsResourceHandler);
-                context17.addHandler(sessionHandler17);
+//                sessionHandler17.addHandler(extraDocsResourceHandler);
+                context17.addHandler(extraDocsResourceHandler);
 
                 httpContext
                         .setHandlers(new Handler[]{context1, context2, context3, context4, context5,
@@ -155,18 +155,18 @@
                 ContextHandler context5 = new ContextHandler();
                 context5.setContextPath(jettyConfig.feedsWebCtx);
                 ResourceHandler feedsWebResourceHandler = new ResourceHandler();
-                SessionHandler sessionHandler5 = new SessionHandler();
+//                SessionHandler sessionHandler5 = new SessionHandler();
                 feedsWebResourceHandler.setResourceBase(jettyConfig.feedsWebResourceBase);
-                sessionHandler5.addHandler(feedsWebResourceHandler);
-                context5.addHandler(sessionHandler5);
+//                sessionHandler5.addHandler(feedsWebResourceHandler);
+                context5.addHandler(feedsWebResourceHandler);
 
                 ContextHandler context6 = new ContextHandler();
                 context6.setContextPath(jettyConfig.stylesWebCtx);
                 ResourceHandler schemaWebResourceHandler = new ResourceHandler();
-                SessionHandler sessionHandler6 = new SessionHandler();
+//                SessionHandler sessionHandler6 = new SessionHandler();
                 schemaWebResourceHandler.setResourceBase(jettyConfig.stylesWebResourceBase);
-                sessionHandler6.addHandler(schemaWebResourceHandler);
-                context6.addHandler(sessionHandler6);
+//                sessionHandler6.addHandler(schemaWebResourceHandler);
+                context6.addHandler(schemaWebResourceHandler);
 
                 /* Web admin related code */
                 ContextHandler context7 = new ContextHandler();
@@ -186,60 +186,60 @@
                 //File upload context
                 ContextHandler context9 = new ContextHandler();
                 context9.setContextPath(ServerConstants.ContextPaths.UPLOAD_PATH);
-                SessionHandler sessionHandler9 = new SessionHandler();
+//                SessionHandler sessionHandler9 = new SessionHandler();
                 Handler axis2FileUploadHandler = new Axis2FileUploadHandler(configurationContext);
-                sessionHandler9.addHandler(axis2FileUploadHandler);
-                context9.addHandler(sessionHandler9);
+//                sessionHandler9.addHandler(axis2FileUploadHandler);
+                context9.addHandler(axis2FileUploadHandler);
 
                 //File download context
                 ContextHandler context10 = new ContextHandler();
                 context10.setContextPath(ServerConstants.ContextPaths.DOWNLOAD_PATH);
-                SessionHandler sessionHandler10 = new SessionHandler();
+//                SessionHandler sessionHandler10 = new SessionHandler();
                 Handler axis2FileDownloadHandler =
                         new Axis2FileDownloadHandler(configurationContext);
-                sessionHandler10.addHandler(axis2FileDownloadHandler);
-                context10.addHandler(sessionHandler10);
+//                sessionHandler10.addHandler(axis2FileDownloadHandler);
+                context10.addHandler(axis2FileDownloadHandler);
 
                 //Server startServer/restartServer
                 ContextHandler context13 = new ContextHandler();
                 context13.setContextPath(ServerConstants.ContextPaths.SERVER_PATH);
-                SessionHandler sessionHandler13 = new SessionHandler();
+//                SessionHandler sessionHandler13 = new SessionHandler();
                 Handler serverHandler = new ServerHandler(configurationContext);
-                sessionHandler13.addHandler(serverHandler);
-                context13.addHandler(sessionHandler13);
+//                sessionHandler13.addHandler(serverHandler);
+                context13.addHandler(serverHandler);
 
                 ContextHandler context14 = new ContextHandler();
                 context14.setContextPath(jettyConfig.adminWebCtx);
                 context14.setResourceBase(jettyConfig.adminWebResourceBase);
-                SessionHandler sessionHandler14 = new SessionHandler();
+//                SessionHandler sessionHandler14 = new SessionHandler();
                 Handler managementConsoleRequestHandler =
                         new ManagementConsoleRequestHandler(configurationContext);
-                sessionHandler14.addHandler(managementConsoleRequestHandler);
-                context14.addHandler(sessionHandler14);
+//                sessionHandler14.addHandler(managementConsoleRequestHandler);
+                context14.addHandler(managementConsoleRequestHandler);
 
                 ContextHandler context15 = new ContextHandler();
                 context15.setContextPath(jettyConfig.serviceUiWebCtx);
-                SessionHandler sessionHandler15 = new SessionHandler();
+//                SessionHandler sessionHandler15 = new SessionHandler();
                 ResourceHandler serviceUiResourceHandler = new ResourceHandler();
-                sessionHandler15.addHandler(serviceUiResourceHandler);
-                context15.addHandler(sessionHandler15);
+//                sessionHandler15.addHandler(serviceUiResourceHandler);
+                context15.addHandler(serviceUiResourceHandler);
 
                 ContextHandler context16 = new ContextHandler();
                 context16.setContextPath(jettyConfig.docsWebCtx);
                 ResourceHandler httpsDocsResourceHandler = new ResourceHandler();
-                SessionHandler sessionHandler16 = new SessionHandler();
+//                SessionHandler sessionHandler16 = new SessionHandler();
                 httpsDocsResourceHandler.setResourceBase(jettyConfig.docsWebResourceBase);
-                sessionHandler16.addHandler(httpsDocsResourceHandler);
-                context16.addHandler(sessionHandler16);
+//                sessionHandler16.addHandler(httpsDocsResourceHandler);
+                context16.addHandler(httpsDocsResourceHandler);
 
                 //For Extra Documents
                 ContextHandler context17 = new ContextHandler();
                 context17.setContextPath(jettyConfig.samplesWebCtx);
                 ResourceHandler extraDocsResourceHandler = new ResourceHandler();
-                SessionHandler sessionHandler17 = new SessionHandler();
+//                SessionHandler sessionHandler17 = new SessionHandler();
                 extraDocsResourceHandler.setResourceBase(jettyConfig.samplesWebResourceBase);
-                sessionHandler17.addHandler(extraDocsResourceHandler);
-                context17.addHandler(sessionHandler17);
+//                sessionHandler17.addHandler(extraDocsResourceHandler);
+                context17.addHandler(extraDocsResourceHandler);
 
                 httpsContext
                         .setHandlers(new Handler[]{context5, context6, context7, context8, context9,

Modified: wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/ManagementConsoleRequestHandler.java
==============================================================================
--- wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/ManagementConsoleRequestHandler.java	(original)
+++ wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/ManagementConsoleRequestHandler.java	Thu Feb  1 04:16:13 2007
@@ -1,32 +1,35 @@
-/*                                                                             
- * Copyright 2004,2005 The Apache Software Foundation.                         
- *                                                                             
- * Licensed 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.                                              
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.wso2.wsas.transport.jetty;
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.mortbay.jetty.HttpConnection;
+import org.mortbay.jetty.Request;
+import org.mortbay.jetty.handler.AbstractHandler;
+import org.wso2.utils.transport.http.FaviconProvider;
+import org.wso2.utils.NetworkUtils;
 import org.wso2.wsas.ServerConstants;
 import org.wso2.wsas.ServerManager;
 import org.wso2.wsas.util.JettyWebConfiguration;
 import org.wso2.wsas.util.MIMEType2FileExtensionMap;
-import org.wso2.utils.transport.http.FaviconProvider;
-import org.wso2.utils.NetworkUtils;
 
+import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -37,17 +40,18 @@
 import java.util.Map;
 
 /**
- * 
+ *
  */
-public class ManagementConsoleRequestHandler extends Axis2Handler {
+public class ManagementConsoleRequestHandler extends AbstractHandler {
 
     protected static final Log log = LogFactory.getLog(ManagementConsoleRequestHandler.class);
     private static JettyWebConfiguration jettyConfig = JettyWebConfiguration.getInstance();
 
     private FaviconProvider faviconProvider;
+    private ConfigurationContext configurationContext;
 
     public ManagementConsoleRequestHandler(ConfigurationContext configurationContext) {
-        super(configurationContext);
+        this.configurationContext = configurationContext;
         try {
             faviconProvider = new FaviconProvider();
             faviconProvider.setFavIconFromResource("org/wso2/wsas/transport/jetty/favicon.ico");
@@ -56,18 +60,12 @@
         }
     }
 
-    protected boolean processPostRequest(MessageContext msgContext,
-                                         HttpServletRequest request,
-                                         HttpServletResponse response) throws AxisFault {
+    private void generateWelcomePages(HttpServletRequest request, HttpServletResponse response) throws AxisFault {
 
         try {
 
             if (faviconProvider.provideFavIcon(request, response)) {
-                return true;
-            }
-
-            if (hostResolver(request, response)){
-                return true;
+                return;
             }
 
             String requestURI = request.getRequestURI();
@@ -108,7 +106,7 @@
                     if (!file.exists()) {
                         op.write(("Requested resource " + requestURI + " not found").getBytes());
                         op.flush();
-                        return false;
+                        return;
                     }
                     if (!file.isDirectory()) {
                         FileInputStream fis = new FileInputStream(file);
@@ -123,12 +121,10 @@
                         op.write(fileBytes);
                         fis.close();
                         op.close();
-                        return true;
                     } else {
                         //TOdO Fix this
 //                        op.write("Directory listing is forbidden".getBytes());
 //                        return false;
-                        return true;
                     }
                 }
             }
@@ -141,15 +137,30 @@
             log.error(msg, e);
             throw new AxisFault(msg, e);
         }
-        return true;
     }
 
-    protected boolean processGetRequest(MessageContext msgContext,
-                                        HttpServletRequest request,
-                                        HttpServletResponse response) throws AxisFault {
-        return processPostRequest(msgContext, request, response);
+
+    public void handle(String target, HttpServletRequest request, HttpServletResponse response,
+                       int dispatch) throws IOException, ServletException {
+        Request baseRequest = (request instanceof Request) ? (Request) request :
+                              HttpConnection.getCurrentConnection().getRequest();
+        baseRequest.setHandled(true);
+
+        if (hostResolver(request, response)) {
+            return;
+        }
+
+        generateWelcomePages(request,response);
+
     }
 
+    /**
+     * This will redirect the request first before doing anything else
+     * @param request
+     * @param response
+     * @return boolean
+     * @throws IOException
+     */
     private boolean hostResolver(HttpServletRequest request,
                               HttpServletResponse response) throws IOException {
         String contextRoot = configurationContext.getContextRoot();

Modified: wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/ServerHandler.java
==============================================================================
--- wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/ServerHandler.java	(original)
+++ wsas/java/trunk/modules/standalone-edition/src/org/wso2/wsas/transport/jetty/ServerHandler.java	Thu Feb  1 04:16:13 2007
@@ -24,6 +24,7 @@
 import org.apache.axis2.AxisFault;
 import org.mortbay.jetty.Request;
 import org.mortbay.jetty.HttpConnection;
+import org.mortbay.jetty.handler.AbstractHandler;
 
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
@@ -31,15 +32,15 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
-public class ServerHandler extends Axis2Handler {
+public class ServerHandler extends AbstractHandler {
+
+    private ConfigurationContext configurationContext;
 
     public ServerHandler(ConfigurationContext configurationContext) {
-        super(configurationContext);
+        this.configurationContext = configurationContext;
     }
 
-    protected boolean processPostRequest(MessageContext msgContext,
-                                         HttpServletRequest request,
-                                         HttpServletResponse response) throws AxisFault {
+    private void processRequest(HttpServletResponse response) {
         try {
             ServletOutputStream outputStream = response.getOutputStream();
             outputStream.flush();
@@ -48,19 +49,11 @@
                     (Main) configurationContext
                             .getProperty(ServerConstants.WSO2WSAS_INSTANCE);
             main.restartServer();
-            return false;
         } catch (IOException ignored) {
             // TODO Fill me
         } catch (ServerException e) {
             // TODO Fill me
         }
-        return false;
-    }
-
-    protected boolean processGetRequest(MessageContext msgContext,
-                                        HttpServletRequest request,
-                                        HttpServletResponse response) throws AxisFault {
-        return false;
     }
 
     public void handle(String target, HttpServletRequest request, HttpServletResponse response,
@@ -68,13 +61,9 @@
         Request base_request = (request instanceof Request) ? (Request) request :
                                HttpConnection.getCurrentConnection().getRequest();
         base_request.setHandled(true);
-        try {
-            String method = request.getMethod();
-            if (org.wso2.wsas.ServerConstants.HTTPConstants.HTTP_METHOD_POST.equals(method)) {
-                processPostRequest(null, request, response);
-            }
-        } catch (AxisFault e) {
-            //
+        String method = request.getMethod();
+        if (ServerConstants.HTTPConstants.HTTP_METHOD_POST.equals(method)) {
+            processRequest(response);
         }
     }
 }

Modified: wsas/java/trunk/modules/www/extensions/core/js/wso2wsas.js
==============================================================================
--- wsas/java/trunk/modules/www/extensions/core/js/wso2wsas.js	(original)
+++ wsas/java/trunk/modules/www/extensions/core/js/wso2wsas.js	Thu Feb  1 04:16:13 2007
@@ -21,13 +21,18 @@
 var SERVICE_CONTEXT = "/soap";
 
 var COOKIE_SESSION_MANAGEMENT = true;
-var SESSION_COOKIE_NAME = "__WSAS_SESSION_COOKIE__";
+var SESSION_COOKIE_NAME = "JSESSIONID";
+var cookieObject;
 
 function init() {
     URL = locationString.substring(0, locationString.lastIndexOf('/'));
 
     defaultURL = URL;
 
+    cookieObject = new Cookie(document,SESSION_COOKIE_NAME);
+    //alert(cookieObject.load());
+
+
     if (URL.indexOf('https') == -1) {
         //	alert("You can only access the management console through https. \n The default https port for @server_short_name@ is " + httpsPort + ".");
         var newURL = "https" + URL.substring(URL.indexOf('://'), URL.lastIndexOf(':') + 1) +




More information about the Wsas-java-dev mailing list