|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ServletWebSession.java | 100% | 100% | 100% | 100% |
|
1 | // Copyright 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.web; | |
16 | ||
17 | import java.util.List; | |
18 | ||
19 | import javax.servlet.http.HttpSession; | |
20 | ||
21 | import org.apache.hivemind.util.Defense; | |
22 | import org.apache.tapestry.describe.DescriptionReceiver; | |
23 | ||
24 | /** | |
25 | * Adapts {@link javax.servlet.http.HttpSession} as | |
26 | * {@link org.apache.tapestry.web.WebSession}. | |
27 | * | |
28 | * @author Howard M. Lewis Ship | |
29 | * @since 4.0 | |
30 | */ | |
31 | public class ServletWebSession implements WebSession | |
32 | { | |
33 | private final HttpSession _httpSession; | |
34 | ||
35 | 42 | public ServletWebSession(HttpSession session) |
36 | { | |
37 | 42 | Defense.notNull(session, "session"); |
38 | ||
39 | 42 | _httpSession = session; |
40 | } | |
41 | ||
42 | 5 | public void describeTo(DescriptionReceiver receiver) |
43 | { | |
44 | 5 | receiver.describeAlternate(_httpSession); |
45 | } | |
46 | ||
47 | 46 | public List getAttributeNames() |
48 | { | |
49 | 46 | return WebUtils.toSortedList(_httpSession.getAttributeNames()); |
50 | } | |
51 | ||
52 | 14 | public Object getAttribute(String name) |
53 | { | |
54 | 14 | return _httpSession.getAttribute(name); |
55 | } | |
56 | ||
57 | 24 | public void setAttribute(String name, Object attribute) |
58 | { | |
59 | 24 | if (attribute == null) |
60 | 3 | _httpSession.removeAttribute(name); |
61 | else | |
62 | 21 | _httpSession.setAttribute(name, attribute); |
63 | } | |
64 | ||
65 | 1 | public String getId() |
66 | { | |
67 | 1 | return _httpSession.getId(); |
68 | } | |
69 | ||
70 | 9 | public boolean isNew() |
71 | { | |
72 | 9 | return _httpSession.isNew(); |
73 | } | |
74 | } |
|