1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.catalina.session;
18
19 import java.util.Enumeration;
20
21 import javax.servlet.ServletContext;
22 import javax.servlet.http.HttpSession;
23
24 /**
25 * Facade for the StandardSession object.
26 *
27 * @author Remy Maucherat
28 */
29 public class StandardSessionFacade implements HttpSession {
30
31 // ----------------------------------------------------------- Constructors
32
33 /**
34 * Construct a new session facade.
35 *
36 * @param session The session instance to wrap
37 */
38 public StandardSessionFacade(HttpSession session) {
39 this.session = session;
40 }
41
42
43 // ----------------------------------------------------- Instance Variables
44
45 /**
46 * Wrapped session object.
47 */
48 private final HttpSession session;
49
50
51 // ---------------------------------------------------- HttpSession Methods
52
53 @Override
54 public long getCreationTime() {
55 return session.getCreationTime();
56 }
57
58
59 @Override
60 public String getId() {
61 return session.getId();
62 }
63
64
65 @Override
66 public long getLastAccessedTime() {
67 return session.getLastAccessedTime();
68 }
69
70
71 @Override
72 public ServletContext getServletContext() {
73 // FIXME : Facade this object ?
74 return session.getServletContext();
75 }
76
77
78 @Override
79 public void setMaxInactiveInterval(int interval) {
80 session.setMaxInactiveInterval(interval);
81 }
82
83
84 @Override
85 public int getMaxInactiveInterval() {
86 return session.getMaxInactiveInterval();
87 }
88
89
90 /**
91 * @deprecated As of Version 2.1, this method is deprecated and has no
92 * replacement.
93 */
94 @Override
95 @Deprecated
96 public javax.servlet.http.HttpSessionContext getSessionContext() {
97 return session.getSessionContext();
98 }
99
100
101 @Override
102 public Object getAttribute(String name) {
103 return session.getAttribute(name);
104 }
105
106
107 /**
108 * @deprecated As of Version 2.2, this method is replaced by
109 * {@link #getAttribute}.
110 */
111 @Override
112 @Deprecated
113 public Object getValue(String name) {
114 return session.getAttribute(name);
115 }
116
117
118 @Override
119 public Enumeration<String> getAttributeNames() {
120 return session.getAttributeNames();
121 }
122
123
124 /**
125 * @deprecated As of Version 2.2, this method is replaced by
126 * {@link #getAttributeNames}
127 */
128 @Override
129 @Deprecated
130 public String[] getValueNames() {
131 return session.getValueNames();
132 }
133
134
135 @Override
136 public void setAttribute(String name, Object value) {
137 session.setAttribute(name, value);
138 }
139
140
141 /**
142 * @deprecated As of Version 2.2, this method is replaced by
143 * {@link #setAttribute}
144 */
145 @Override
146 @Deprecated
147 public void putValue(String name, Object value) {
148 session.setAttribute(name, value);
149 }
150
151
152 @Override
153 public void removeAttribute(String name) {
154 session.removeAttribute(name);
155 }
156
157
158 /**
159 * @deprecated As of Version 2.2, this method is replaced by
160 * {@link #removeAttribute}
161 */
162 @Override
163 @Deprecated
164 public void removeValue(String name) {
165 session.removeAttribute(name);
166 }
167
168
169 @Override
170 public void invalidate() {
171 session.invalidate();
172 }
173
174
175 @Override
176 public boolean isNew() {
177 return session.isNew();
178 }
179 }
180