[wsas-java-dev] svn commit r536 -
wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty
svn at wso2.com
svn at wso2.com
Mon Jan 22 04:29:36 PST 2007
Author: saminda
Date: Mon Jan 22 04:29:26 2007
New Revision: 536
Modified:
wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty/Axis2Handler.java
wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty/JettyServer.java
Log:
Embedded server works when the session is transport. //TODO AXIS2-2009 and fixes to SessionHandling in Axis2 kernel
Modified: wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty/Axis2Handler.java
==============================================================================
--- wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty/Axis2Handler.java (original)
+++ wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty/Axis2Handler.java Mon Jan 22 04:29:26 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
- *
+ *
+ * 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.
+ * 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;
@@ -41,6 +41,7 @@
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;
@@ -53,6 +54,7 @@
protected static final Log log = LogFactory.getLog(Axis2Handler.class);
protected ConfigurationContext configurationContext;
+
public Axis2Handler(ConfigurationContext configurationContext) {
this.configurationContext = configurationContext;
@@ -145,10 +147,7 @@
//TODO Session management for admin services.
//TODO if needed use a switch here
- Object sessionObject = manageSessionContext(request);
- msgContext.setSessionContext((SessionContext)sessionObject);
- msgContext.setProperty("SessionId",request.getSession().getId());
-
+ manageSessionContext(request, response, msgContext);
String method = request.getMethod();
try {
@@ -236,14 +235,33 @@
}
}
- protected Object manageSessionContext(HttpServletRequest request) {
+ protected void manageSessionContext(HttpServletRequest request, HttpServletResponse response,
+ MessageContext msgContext) {
+
+ //TODO due instance dispatcher depends on httpServletRequest.
+
HttpSession httpSession = request.getSession(true);
- Object sessionContext = httpSession.getAttribute(Constants.SESSION_CONTEXT_PROPERTY);
- if (sessionContext == null) {
- sessionContext = new SessionContext(null);
- httpSession.setAttribute(Constants.SESSION_CONTEXT_PROPERTY,sessionContext);
+
+ 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 :: ");
+ String cookieValueString = Long.toString(System.currentTimeMillis());
+ Cookie userCookie = new Cookie("__WSAS_SESSION_COOKIE__", cookieValueString);
+ userCookie.setMaxAge(-1); // When the browse exists cookie will die.
+ response.addCookie(userCookie);
+ 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());
+ }
+
}
- return sessionContext;
}
Modified: wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty/JettyServer.java
==============================================================================
--- wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty/JettyServer.java (original)
+++ wsas/java/trunk/modules/core/src/org/wso2/wsas/transport/jetty/JettyServer.java Mon Jan 22 04:29:26 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
- *
+ *
+ * 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.
+ * 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;
@@ -25,6 +25,7 @@
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.NCSARequestLog;
import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.SessionHandler;
import org.mortbay.jetty.handler.*;
import java.text.SimpleDateFormat;
@@ -68,94 +69,199 @@
HandlerCollection httpHandlers = new HandlerCollection();
HandlerCollection httpsHandlers = new HandlerCollection();
+ {
+ // Hold HTTP related Contexts
+ ContextHandler context1 = new ContextHandler();
+ context1.setContextPath(jettyConfig.docsWebCtx);
+ SessionHandler sessionHandler1 = new SessionHandler();
+ ResourceHandler docsResourceHandler = new ResourceHandler();
+ docsResourceHandler.setResourceBase(jettyConfig.docsWebResourceBase);
+ sessionHandler1.addHandler(docsResourceHandler);
+ context1.addHandler(sessionHandler1);
+
+ ContextHandler context2 = new ContextHandler();
+ context2.setContextPath(initializeServiceUrlContextPath(configurationContext));
+ SessionHandler sessionHandler2 = new SessionHandler();
+ Handler axis2SOAPHander = new Axis2SOAPHandler(configurationContext);
+ sessionHandler2.addHandler(axis2SOAPHander);
+ context2.addHandler(sessionHandler2);
+
+ ContextHandler context3 = new ContextHandler();
+ context3.setContextPath(initializeServiceUrlRestPath(configurationContext));
+ SessionHandler sessionHandler3 = new SessionHandler();
+ Handler axis2RESTHandler = new Axis2RestHandler(configurationContext);
+ sessionHandler3.addHandler(axis2RESTHandler);
+ context3.addHandler(sessionHandler3);
+
+ ContextHandler context4 = new ContextHandler();
+ context4.setContextPath(jettyConfig.serviceUiWebCtx);
+ ResourceHandler serviceUiResourceHandler = new ResourceHandler();
+ SessionHandler sessionHandler4 = new SessionHandler();
+ serviceUiResourceHandler.setResourceBase(jettyConfig.serviceUiResourceBase);
+ sessionHandler4.addHandler(serviceUiResourceHandler);
+ context4.addHandler(sessionHandler4);
+
+ ContextHandler context5 = new ContextHandler();
+ context5.setContextPath(jettyConfig.feedsWebCtx);
+ ResourceHandler feedsWebResourceHandler = new ResourceHandler();
+ SessionHandler sessionHandler5 = new SessionHandler();
+ feedsWebResourceHandler.setResourceBase(jettyConfig.feedsWebResourceBase);
+ sessionHandler5.addHandler(feedsWebResourceHandler);
+ context5.addHandler(sessionHandler5);
+
+ ContextHandler context6 = new ContextHandler();
+ context6.setContextPath(jettyConfig.stylesWebCtx);
+ ResourceHandler schemaWebResourceHandler = new ResourceHandler();
+ SessionHandler sessionHandler6 = new SessionHandler();
+ schemaWebResourceHandler.setResourceBase(jettyConfig.stylesWebResourceBase);
+ sessionHandler6.addHandler(schemaWebResourceHandler);
+ context6.addHandler(sessionHandler6);
+
+ //File upload context for Http. Used in tools mainly.
+ ContextHandler context11 = new ContextHandler();
+ context11.setContextPath(ServerConstants.ContextPaths.UPLOAD_PATH);
+ SessionHandler sessionHandler11 = new SessionHandler();
+ Handler axis2FileUploadHandler0 = new Axis2FileUploadHandler(configurationContext);
+ sessionHandler11.addHandler(axis2FileUploadHandler0);
+ context11.addHandler(sessionHandler11);
+
+ //File download context for Http. Used in tools mainly.
+ ContextHandler context12 = new ContextHandler();
+ context12.setContextPath(ServerConstants.ContextPaths.DOWNLOAD_PATH);
+ SessionHandler sessionHandler12 = new SessionHandler();
+ Handler axis2FileDownloadHandler0 =
+ new Axis2FileDownloadHandler(configurationContext);
+ sessionHandler12.addHandler(axis2FileDownloadHandler0);
+ context12.addHandler(sessionHandler12);
+
+ //For Extra Documents
+ ContextHandler context17 = new ContextHandler();
+ context17.setContextPath(jettyConfig.samplesWebCtx);
+ ResourceHandler extraDocsResourceHandler = new ResourceHandler();
+ SessionHandler sessionHandler17 = new SessionHandler();
+ extraDocsResourceHandler.setResourceBase(jettyConfig.samplesWebResourceBase);
+ sessionHandler17.addHandler(extraDocsResourceHandler);
+ context17.addHandler(sessionHandler17);
+
+ /////////////////////////////////////////////////////////////////////////////////
+ //TODO Temprarly
+ ContextHandler context14 = new ContextHandler();
+ context14.setContextPath(jettyConfig.adminWebCtx);
+ context14.setResourceBase(jettyConfig.adminWebResourceBase);
+ SessionHandler sessionHandler14 = new SessionHandler();
+ Handler managementConsoleRequestHandler =
+ new ManagementConsoleRequestHandler(configurationContext);
+ sessionHandler14.addHandler(managementConsoleRequestHandler);
+ context14.addHandler(sessionHandler14);
+
+ //////////////////////////////////////////////////////////////////////////////////
+
+ httpContext
+ .setHandlers(new Handler[]{context1, context2, context3, context4, context5,
+ context6, context11, context12, context17,
+/*temp*/context14});
+
+
+ }
+
+ {
+ //Hold HTTPS related contexts
+ ContextHandler context5 = new ContextHandler();
+ context5.setContextPath(jettyConfig.feedsWebCtx);
+ ResourceHandler feedsWebResourceHandler = new ResourceHandler();
+ SessionHandler sessionHandler5 = new SessionHandler();
+ feedsWebResourceHandler.setResourceBase(jettyConfig.feedsWebResourceBase);
+ sessionHandler5.addHandler(feedsWebResourceHandler);
+ context5.addHandler(sessionHandler5);
+
+ ContextHandler context6 = new ContextHandler();
+ context6.setContextPath(jettyConfig.stylesWebCtx);
+ ResourceHandler schemaWebResourceHandler = new ResourceHandler();
+ SessionHandler sessionHandler6 = new SessionHandler();
+ schemaWebResourceHandler.setResourceBase(jettyConfig.stylesWebResourceBase);
+ sessionHandler6.addHandler(schemaWebResourceHandler);
+ context6.addHandler(sessionHandler6);
+
+ /* Web admin related code */
+ ContextHandler context7 = new ContextHandler();
+ context7.setContextPath(initializeServiceUrlContextPath(configurationContext));
+ SessionHandler sessionHandler7 = new SessionHandler();
+ Handler axis2SOAPHander0 = new Axis2SOAPHandler(configurationContext);
+ sessionHandler7.addHandler(axis2SOAPHander0);
+ context7.addHandler(sessionHandler7);
+
+ ContextHandler context8 = new ContextHandler();
+ context8.setContextPath(initializeServiceUrlRestPath(configurationContext));
+ SessionHandler sessionHandler8 = new SessionHandler();
+ Handler axis2RESTHandler0 = new Axis2RestHandler(configurationContext);
+ sessionHandler8.addHandler(axis2RESTHandler0);
+ context8.addHandler(sessionHandler8);
+
+ //File upload context
+ ContextHandler context9 = new ContextHandler();
+ context9.setContextPath(ServerConstants.ContextPaths.UPLOAD_PATH);
+ SessionHandler sessionHandler9 = new SessionHandler();
+ Handler axis2FileUploadHandler = new Axis2FileUploadHandler(configurationContext);
+ sessionHandler9.addHandler(axis2FileUploadHandler);
+ context9.addHandler(sessionHandler9);
+
+ //File download context
+ ContextHandler context10 = new ContextHandler();
+ context10.setContextPath(ServerConstants.ContextPaths.DOWNLOAD_PATH);
+ SessionHandler sessionHandler10 = new SessionHandler();
+ Handler axis2FileDownloadHandler =
+ new Axis2FileDownloadHandler(configurationContext);
+ sessionHandler10.addHandler(axis2FileDownloadHandler);
+ context10.addHandler(sessionHandler10);
+
+ //Server startServer/restartServer
+ ContextHandler context13 = new ContextHandler();
+ context13.setContextPath(ServerConstants.ContextPaths.SERVER_PATH);
+ SessionHandler sessionHandler13 = new SessionHandler();
+ Handler serverHandler = new ServerHandler(configurationContext);
+ sessionHandler13.addHandler(serverHandler);
+ context13.addHandler(sessionHandler13);
+
+ ContextHandler context14 = new ContextHandler();
+ context14.setContextPath(jettyConfig.adminWebCtx);
+ context14.setResourceBase(jettyConfig.adminWebResourceBase);
+ SessionHandler sessionHandler14 = new SessionHandler();
+ Handler managementConsoleRequestHandler =
+ new ManagementConsoleRequestHandler(configurationContext);
+ sessionHandler14.addHandler(managementConsoleRequestHandler);
+ context14.addHandler(sessionHandler14);
+
+ ContextHandler context15 = new ContextHandler();
+ context15.setContextPath(jettyConfig.serviceUiWebCtx);
+ SessionHandler sessionHandler15 = new SessionHandler();
+ ResourceHandler serviceUiResourceHandler = new ResourceHandler();
+ sessionHandler15.addHandler(serviceUiResourceHandler);
+ context15.addHandler(sessionHandler15);
+
+ ContextHandler context16 = new ContextHandler();
+ context16.setContextPath(jettyConfig.docsWebCtx);
+ ResourceHandler httpsDocsResourceHandler = new ResourceHandler();
+ SessionHandler sessionHandler16 = new SessionHandler();
+ httpsDocsResourceHandler.setResourceBase(jettyConfig.docsWebResourceBase);
+ sessionHandler16.addHandler(httpsDocsResourceHandler);
+ context16.addHandler(sessionHandler16);
+
+ //For Extra Documents
+ ContextHandler context17 = new ContextHandler();
+ context17.setContextPath(jettyConfig.samplesWebCtx);
+ ResourceHandler extraDocsResourceHandler = new ResourceHandler();
+ SessionHandler sessionHandler17 = new SessionHandler();
+ extraDocsResourceHandler.setResourceBase(jettyConfig.samplesWebResourceBase);
+ sessionHandler17.addHandler(extraDocsResourceHandler);
+ context17.addHandler(sessionHandler17);
+
+ httpsContext
+ .setHandlers(new Handler[]{context5, context6, context7, context8, context9,
+ context10, context13, context14, context15,
+ context16, context17});
+
+ }
- ContextHandler context1 = new ContextHandler();
- context1.setContextPath(jettyConfig.docsWebCtx);
- ResourceHandler docsResourceHandler = new ResourceHandler();
- docsResourceHandler.setResourceBase(jettyConfig.docsWebResourceBase);
- context1.addHandler(docsResourceHandler);
-
- ContextHandler context2 = new ContextHandler();
- context2.setContextPath(initializeServiceUrlContextPath(configurationContext));
- context2.addHandler(new Axis2SOAPHandler(configurationContext));
-
- ContextHandler context3 = new ContextHandler();
- context3.setContextPath(initializeServiceUrlRestPath(configurationContext));
- context3.addHandler(new Axis2RestHandler(configurationContext));
-
- ContextHandler context4 = new ContextHandler();
- context4.setContextPath(jettyConfig.serviceUiWebCtx);
- ResourceHandler serviceUiResourceHandler = new ResourceHandler();
- serviceUiResourceHandler.setResourceBase(jettyConfig.serviceUiResourceBase);
- context4.addHandler(serviceUiResourceHandler);
-
- ContextHandler context5 = new ContextHandler();
- context5.setContextPath(jettyConfig.feedsWebCtx);
- ResourceHandler feedsWebResourceHandler = new ResourceHandler();
- feedsWebResourceHandler.setResourceBase(jettyConfig.feedsWebResourceBase);
- context5.addHandler(feedsWebResourceHandler);
-
- ContextHandler context6 = new ContextHandler();
- context6.setContextPath(jettyConfig.stylesWebCtx);
- ResourceHandler schemaWebResourceHandler = new ResourceHandler();
- schemaWebResourceHandler.setResourceBase(jettyConfig.stylesWebResourceBase);
- context6.addHandler(schemaWebResourceHandler);
-
- /* Web admin related code */
- ContextHandler context7 = new ContextHandler();
- context7.setContextPath(initializeServiceUrlContextPath(configurationContext));
- context7.addHandler(new Axis2SOAPHandler(configurationContext));
-
- ContextHandler context8 = new ContextHandler();
- context8.setContextPath(initializeServiceUrlRestPath(configurationContext));
- context8.addHandler(new Axis2RestHandler(configurationContext));
-
- //File upload context
- ContextHandler context9 = new ContextHandler();
- context9.setContextPath(ServerConstants.ContextPaths.UPLOAD_PATH);
- context9.addHandler(new Axis2FileUploadHandler(configurationContext));
-
- //File download context
- ContextHandler context10 = new ContextHandler();
- context10.setContextPath(ServerConstants.ContextPaths.DOWNLOAD_PATH);
- context10.addHandler(new Axis2FileDownloadHandler(configurationContext));
-
- //File upload context for Http. Used in tools mainly.
- ContextHandler context11 = new ContextHandler();
- context11.setContextPath(ServerConstants.ContextPaths.UPLOAD_PATH);
- context11.addHandler(new Axis2FileUploadHandler(configurationContext));
-
- //File download context for Http. Used in tools mainly.
- ContextHandler context12 = new ContextHandler();
- context12.setContextPath(ServerConstants.ContextPaths.DOWNLOAD_PATH);
- context12.addHandler(new Axis2FileDownloadHandler(configurationContext));
-
- //Server startServer/restartServer
- ContextHandler context13 = new ContextHandler();
- context13.setContextPath(ServerConstants.ContextPaths.SERVER_PATH);
- context13.addHandler(new ServerHandler(configurationContext));
-
- ContextHandler context14 = new ContextHandler();
- context14.setContextPath(jettyConfig.adminWebCtx);
- context14.setResourceBase(jettyConfig.adminWebResourceBase);
- context14.addHandler(new ManagementConsoleRequestHandler(configurationContext));
-
- ContextHandler context15 = new ContextHandler();
- context15.setContextPath(jettyConfig.serviceUiWebCtx);
- context15.addHandler(serviceUiResourceHandler);
-
- ContextHandler context16 = new ContextHandler();
- context16.setContextPath(jettyConfig.docsWebCtx);
- ResourceHandler httpsDocsResourceHandler = new ResourceHandler();
- httpsDocsResourceHandler.setResourceBase(jettyConfig.docsWebResourceBase);
- context16.addHandler(httpsDocsResourceHandler);
-
- //For Extra Documents
- ContextHandler context17 = new ContextHandler();
- context17.setContextPath(jettyConfig.samplesWebCtx);
- ResourceHandler extraDocsResourceHandler = new ResourceHandler();
- extraDocsResourceHandler.setResourceBase(jettyConfig.samplesWebResourceBase);
- context17.addHandler(extraDocsResourceHandler);
RequestLogHandler requestLogHandler = new RequestLogHandler();
if (!isTestMode) {
@@ -169,12 +275,6 @@
requestLogHandler.setRequestLog(requestLog);
}
- httpContext.setHandlers(new Handler[]{context1, context2, context3, context4, context5,
- context6, context11, context12, context17});
- httpsContext.setHandlers(new Handler[]{context5, context6, context7, context8, context9,
- context10, context13, context14, context15,
- context16, context17});
-
httpHandlers.setHandlers(
new Handler[]{httpContext, new ServerDefaultHandler(), requestLogHandler});
httpsHandlers.setHandlers(
More information about the Wsas-java-dev
mailing list