KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > server > session > SessionManagerAdmin


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30
31 package com.caucho.server.session;
32
33 import com.caucho.management.server.AbstractManagedObject;
34 import com.caucho.management.server.PersistentStoreMXBean;
35 import com.caucho.management.server.SessionManagerMXBean;
36 import com.caucho.management.server.WebAppMXBean;
37 import com.caucho.server.cluster.Store;
38
39 import java.util.logging.Logger JavaDoc;
40
41 /**
42  * Implementation of the SessionManager's administration mbean.
43  */

44 public class SessionManagerAdmin extends AbstractManagedObject
45   implements SessionManagerMXBean
46 {
47   private static final Logger JavaDoc log
48     = Logger.getLogger(SessionManagerAdmin.class.getName());
49   
50   private final SessionManager _manager;
51
52   public SessionManagerAdmin(SessionManager manager)
53   {
54     _manager = manager;
55
56     registerSelf();
57   }
58
59   /**
60    * The SessionManager doesn't have a name.
61    */

62   public String JavaDoc getName()
63   {
64     return null;
65   }
66
67   /**
68    * Returns the owning web-app's
69    */

70   public WebAppMXBean getWebApp()
71   {
72     return _manager.getWebApp().getAdmin();
73   }
74
75   //
76
// Configuration attributes
77
//
78

79   /**
80    * True if the session should be serialized for storage, even if
81    * no attributes in the session have been set.
82    */

83   public boolean isAlwaysSaveSession()
84   {
85     return _manager.getAlwaysSaveSession();
86   }
87
88   /**
89    * If true, the server's cluster index is appended to the cookie value.
90    */

91   public boolean isCookieAppendServerIndex()
92   {
93     return _manager.isCookieAppendServerIndex();
94   }
95
96   /**
97    * The host domain used for session cookies
98    */

99   public String JavaDoc getCookieDomain()
100   {
101     return _manager.getCookieDomain();
102   }
103
104   /**
105    * True if the cookie should only be used for non-secure sessions.
106    */

107   public boolean isCookieHttpOnly()
108   {
109     return _manager.isCookieHttpOnly();
110   }
111
112   /**
113    * The length of the generated cookie
114    */

115   public long getCookieLength()
116   {
117     return _manager.getCookieLength();
118   }
119
120   /**
121    * The cookie max-age sent to the browser.
122    */

123   public long getCookieMaxAge()
124   {
125     return _manager.getCookieMaxAge();
126   }
127
128   /**
129    * Returns the cookie name for sessions.
130    */

131   public String JavaDoc getCookieName()
132   {
133     return _manager.getCookieName();
134   }
135
136   /**
137    * Returns the cookie port for sessions.
138    */

139   public String JavaDoc getCookiePort()
140   {
141     return _manager.getCookiePort();
142   }
143
144   /**
145    * True if the cookie should only be used for secure sessions.
146    */

147   public boolean isCookieSecure()
148   {
149     return _manager.getCookieSecure();
150   }
151
152   /**
153    * Returns the cookie version number.
154    */

155   public int getCookieVersion()
156   {
157     return _manager.getCookieVersion();
158   }
159
160   /**
161    * Returns true if cookies are enabled.
162    */

163   public boolean isEnableCookies()
164   {
165     return _manager.enableSessionCookies();
166   }
167
168   /**
169    * Returns true if url-rewriting is enabled.
170    */

171   public boolean isEnableURLRewriting()
172   {
173     return _manager.enableSessionUrls();
174   }
175
176   /**
177    * Returns true if persistent sessions should ignore serialization errors
178    */

179   public boolean isIgnoreSerializationErrors()
180   {
181     return _manager.getIgnoreSerializationErrors();
182   }
183
184   /**
185    * True if sessions should invalidate only after calling listeners.
186    */

187   public boolean isInvalidateAfterListener()
188   {
189     return _manager.isInvalidateAfterListener();
190   }
191
192   /**
193    * True if sessions should reuse available session cookie values.
194    */

195   public boolean isReuseSessionId()
196   {
197     return _manager.getReuseSessionId() != 0;
198   }
199   
200   /**
201    * Returns the save mode.
202    */

203   public String JavaDoc getSaveMode()
204   {
205     return _manager.getSaveMode();
206   }
207   
208   /**
209    * Returns the maximum number of sessions.
210    */

211   public int getSessionMax()
212   {
213     return _manager.getSessionMax();
214   }
215
216   /**
217    * Returns session timeout (in ms)
218    */

219   public long getSessionTimeout()
220   {
221     return _manager.getSessionTimeout();
222   }
223
224   /**
225    * Returns the object name for the persistent store
226    */

227   public PersistentStoreMXBean getPersistentStore()
228   {
229     return null;
230   }
231
232   /**
233    * Returns the active sessions.
234    */

235   public int getActiveSessionCount()
236   {
237     return _manager.getActiveSessionCount();
238   }
239
240   /**
241    * Returns the active sessions.
242    */

243   public long getSessionActiveCount()
244   {
245     return _manager.getSessionActiveCount();
246   }
247
248   /**
249    * Returns the session create count
250    */

251   public long getSessionCreateCountTotal()
252   {
253     return _manager.getSessionCreateCount();
254   }
255
256   /**
257    * Returns the session invalidate count
258    */

259   public long getSessionInvalidateCountTotal()
260   {
261     return _manager.getSessionInvalidateCount();
262   }
263
264   /**
265    * Returns the session timeout count
266    */

267   public long getSessionTimeoutCountTotal()
268   {
269     return _manager.getSessionTimeoutCount();
270   }
271
272   /**
273    * Returns the session store type
274    */

275   public String JavaDoc getSessionStoreType()
276   {
277     Store store = _manager.getSessionStore();
278
279     if (store == null)
280       return null;
281
282     String JavaDoc className = store.getStoreManager().getClass().getName();
283
284     int p = className.lastIndexOf('.');
285
286     return className.substring(p + 1);
287   }
288   
289   /**
290    * Unregisters the object with JMX.
291    */

292   public void unregister()
293   {
294     unregisterSelf();
295   }
296
297   public String JavaDoc toString()
298   {
299     return "SessionManagerAdmin[" + getObjectName() + "]";
300   }
301 }
302
Popular Tags