You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2011/10/19 07:52:46 UTC
svn commit: r1185979 - in /axis/axis2/java/core/trunk/modules/transport/http:
src/org/apache/axis2/transport/http/server/SessionManager.java
test/org/apache/axis2/transport/server/
test/org/apache/axis2/transport/server/SessionManagerTest.java
Author: sagara
Date: Wed Oct 19 05:52:45 2011
New Revision: 1185979
URL: http://svn.apache.org/viewvc?rev=1185979&view=rev
Log:
Changed SessionManager to use Axiom UIDGenerator class instead of deprecated UUIDGenerator class and added proper generics.
Added SessionManagerTest.
Added:
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/server/
axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/server/SessionManagerTest.java (with props)
Modified:
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SessionManager.java
Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SessionManager.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SessionManager.java?rev=1185979&r1=1185978&r2=1185979&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SessionManager.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/server/SessionManager.java Wed Oct 19 05:52:45 2011
@@ -19,7 +19,7 @@
package org.apache.axis2.transport.http.server;
-import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.util.UIDGenerator;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.context.ServiceGroupContext;
import org.apache.axis2.context.SessionContext;
@@ -31,11 +31,11 @@ import java.util.Map;
public class SessionManager {
- private final Map sessionmap;
+ private final Map<String, SessionContext> sessionmap;
public SessionManager() {
super();
- this.sessionmap = new HashMap();
+ this.sessionmap = new HashMap<String, SessionContext>();
}
public synchronized SessionContext getSessionContext(String sessionKey) {
@@ -44,7 +44,7 @@ public class SessionManager {
sessionContext = (SessionContext) this.sessionmap.get(sessionKey);
}
if (sessionContext == null) {
- sessionKey = UUIDGenerator.getUUID();
+ sessionKey = UIDGenerator.generateUID();
sessionContext = new SessionContext(null);
sessionContext.setCookieID(sessionKey);
this.sessionmap.put(sessionKey, sessionContext);
@@ -56,13 +56,13 @@ public class SessionManager {
private void cleanupServiceGroupContexts() {
long currentTime = System.currentTimeMillis();
- for (Iterator it = this.sessionmap.keySet().iterator(); it.hasNext();) {
+ for (Iterator<String> it = this.sessionmap.keySet().iterator(); it.hasNext();) {
String cookieID = (String) it.next();
SessionContext sessionContext = (SessionContext) this.sessionmap.get(cookieID);
if ((currentTime - sessionContext.getLastTouchedTime()) >
sessionContext.sessionContextTimeoutInterval) {
it.remove();
- Iterator serviceGroupContext = sessionContext.getServiceGroupContext();
+ Iterator<ServiceGroupContext> serviceGroupContext = sessionContext.getServiceGroupContext();
if (serviceGroupContext != null) {
while (serviceGroupContext.hasNext()) {
ServiceGroupContext groupContext =
@@ -75,7 +75,7 @@ public class SessionManager {
}
private void cleanupServiceContexts(final ServiceGroupContext serviceGroupContext) {
- for (Iterator it = serviceGroupContext.getServiceContexts(); it.hasNext();) {
+ for (Iterator<ServiceContext> it = serviceGroupContext.getServiceContexts(); it.hasNext();) {
ServiceContext serviceContext = (ServiceContext) it.next();
DependencyManager.destroyServiceObject(serviceContext);
}
Added: axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/server/SessionManagerTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/server/SessionManagerTest.java?rev=1185979&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/server/SessionManagerTest.java (added)
+++ axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/server/SessionManagerTest.java Wed Oct 19 05:52:45 2011
@@ -0,0 +1,75 @@
+/*
+ * 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.axis2.transport.server;
+
+import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.transport.http.server.SessionManager;
+
+import junit.framework.TestCase;
+
+/**
+ * The Class SessionManagerTest.
+ */
+public class SessionManagerTest extends TestCase {
+
+ SessionManager manager;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ manager = new SessionManager();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ manager = null;
+ }
+
+ /**
+ * Test get session context.
+ */
+ public void testGetSessionContext() {
+ String sessionKey = null;
+ SessionContext ctx1 = manager.getSessionContext(sessionKey);
+ sessionKey = ctx1.getCookieID();
+ assertNotNull(ctx1);
+ assertNotNull(sessionKey);
+
+ SessionContext ctx2 = manager.getSessionContext(sessionKey);
+ assertNotNull(ctx2);
+ assertEquals(ctx1, ctx2);
+ assertEquals(sessionKey, ctx2.getCookieID());
+
+ SessionContext ctx3 = manager.getSessionContext(null);
+ assertNotNull(ctx3);
+ assertNotSame(ctx1, ctx3);
+ assertFalse(sessionKey.equals(ctx3.getCookieID()));
+ }
+
+}
Propchange: axis/axis2/java/core/trunk/modules/transport/http/test/org/apache/axis2/transport/server/SessionManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native