You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2007/06/15 04:40:02 UTC
svn commit: r547499 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry/internal/services/
main/java/org/apache/tapestry/internal/test/
main/java/org/apache/tapestry/services/
test/java/org/apache/tapestry/integration/app1/p...
Author: hlship
Date: Thu Jun 14 19:40:01 2007
New Revision: 547499
URL: http://svn.apache.org/viewvc?view=rev&rev=547499
Log:
TAPESTRY-1492: The Session interface needs methods for getting and setting the session timeout
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestImplTest.java
- copied, changed from r547486, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebRequestImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SessionImplTest.java
- copied, changed from r547486, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebSessionImplTest.java
Removed:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebRequestImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebSessionImplTest.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClassResultProcessor.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Session.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClassResultProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClassResultProcessor.java?view=diff&rev=547499&r1=547498&r2=547499
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClassResultProcessor.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClassResultProcessor.java Thu Jun 14 19:40:01 2007
@@ -1,17 +1,17 @@
-// Copyright 2007 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 2007 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.apache.tapestry.internal.services;
import org.apache.tapestry.Link;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionImpl.java?view=diff&rev=547499&r1=547498&r2=547499
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionImpl.java Thu Jun 14 19:40:01 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -32,7 +32,7 @@
{
private final HttpSession _session;
- public SessionImpl(final HttpSession session)
+ public SessionImpl(HttpSession session)
{
_session = session;
}
@@ -61,13 +61,27 @@
{
String name = (String) e.nextElement();
- if (name.startsWith(prefix))
- result.add(name);
+ if (name.startsWith(prefix)) result.add(name);
}
Collections.sort(result);
return result;
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ return _session.getMaxInactiveInterval();
+ }
+
+ public void invalidate()
+ {
+ _session.invalidate();
+ }
+
+ public void setMaxInactiveInterval(int seconds)
+ {
+ _session.setMaxInactiveInterval(seconds);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java?view=diff&rev=547499&r1=547498&r2=547499
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java Thu Jun 14 19:40:01 2007
@@ -60,4 +60,27 @@
}
+ private void nyi(String name)
+ {
+ throw new IllegalStateException(String.format("%s.%s() is not yet implemented.", getClass()
+ .getName(), name));
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ nyi("getMaxInativeInterval");
+
+ return 0;
+ }
+
+ public void invalidate()
+ {
+ nyi("invalidate");
+ }
+
+ public void setMaxInactiveInterval(int seconds)
+ {
+ nyi("setMaxInactiveInterval");
+ }
+
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Session.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Session.java?view=diff&rev=547499&r1=547498&r2=547499
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Session.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Session.java Thu Jun 14 19:40:01 2007
@@ -41,4 +41,26 @@
/** Sets the value of an attribute. If the value is null, then the attribute is deleted. */
void setAttribute(String name, Object value);
+
+ /**
+ * Returns the maximum time interval, in seconds, that the servlet container will keep this
+ * session open between client accesses. After this interval, the servlet container will
+ * invalidate the session. The maximum time interval can be set with the setMaxInactiveInterval
+ * method. A negative time indicates the session should never timeout.
+ */
+ int getMaxInactiveInterval();
+
+ /**
+ * Specifies the time, in seconds, between client requests before the servlet container will
+ * invalidate this session. A negative time indicates the session should never timeout.
+ */
+ void setMaxInactiveInterval(int seconds);
+
+ /**
+ * Invalidates this session then unbinds any objects bound to it.
+ *
+ * @throws IllegalStateException
+ * if this method is called on an already invalidated session
+ */
+ void invalidate();
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java?view=diff&rev=547499&r1=547498&r2=547499
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/ReturnTypes.java Thu Jun 14 19:40:01 2007
@@ -1,17 +1,17 @@
-// Copyright 2007 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 2007 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.apache.tapestry.integration.app1.pages;
import org.apache.tapestry.ComponentResources;
Copied: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestImplTest.java (from r547486, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebRequestImplTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestImplTest.java?view=diff&rev=547499&p1=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebRequestImplTest.java&r1=547486&p2=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestImplTest.java&r2=547499
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebRequestImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/RequestImplTest.java Thu Jun 14 19:40:01 2007
@@ -22,7 +22,7 @@
import org.apache.tapestry.services.Session;
import org.testng.annotations.Test;
-public class WebRequestImplTest extends InternalBaseTestCase
+public class RequestImplTest extends InternalBaseTestCase
{
@Test
public void get_session_doesnt_exist()
Copied: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SessionImplTest.java (from r547486, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebSessionImplTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SessionImplTest.java?view=diff&rev=547499&p1=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebSessionImplTest.java&r1=547486&p2=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SessionImplTest.java&r2=547499
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/WebSessionImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SessionImplTest.java Thu Jun 14 19:40:01 2007
@@ -24,7 +24,7 @@
import org.apache.tapestry.services.Session;
import org.testng.annotations.Test;
-public class WebSessionImplTest extends InternalBaseTestCase
+public class SessionImplTest extends InternalBaseTestCase
{
@Test
public void get_attribute_names()
@@ -56,6 +56,56 @@
Session session = new SessionImpl(hs);
assertEquals(session.getAttributeNames("f"), Arrays.asList("fanny", "fred"));
+
+ verify();
+ }
+
+ @Test
+ public void invalidate()
+ {
+ HttpSession hs = mockHttpSession();
+
+ hs.invalidate();
+
+ replay();
+
+ Session session = new SessionImpl(hs);
+
+ session.invalidate();
+
+ verify();
+ }
+
+ @Test
+ public void set_max_inactive()
+ {
+ HttpSession hs = mockHttpSession();
+ int seconds = 999;
+
+ hs.setMaxInactiveInterval(seconds);
+
+ replay();
+
+ Session session = new SessionImpl(hs);
+
+ session.setMaxInactiveInterval(seconds);
+
+ verify();
+ }
+
+ @Test
+ public void get_max_inactive()
+ {
+ HttpSession hs = mockHttpSession();
+ int seconds = 999;
+
+ expect(hs.getMaxInactiveInterval()).andReturn(seconds);
+
+ replay();
+
+ Session session = new SessionImpl(hs);
+
+ assertEquals(session.getMaxInactiveInterval(), seconds);
verify();
}