01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.romaframework.module.admin.view.domain.activesession.http;
17:
18: import java.util.Enumeration;
19: import java.util.HashMap;
20:
21: import javax.servlet.http.HttpSession;
22:
23: import org.romaframework.aspect.session.SessionInfo;
24: import org.romaframework.core.flow.ObjectContext;
25: import org.romaframework.module.admin.view.domain.activesession.ActiveSessionInstance;
26: import org.romaframework.module.admin.view.domain.activesession.SessionAttributeInfo;
27:
28: public class HttpActiveSessionInstance extends ActiveSessionInstance {
29: public HttpActiveSessionInstance(SessionInfo iEntity, Object iBack) {
30: super (iEntity, iBack);
31:
32: HttpSession sess = (HttpSession) entity.getSystemSession();
33:
34: // FILL ATTRIBUTES
35: String attrName;
36: attributes = new HashMap<String, SessionAttributeInfo>();
37: Enumeration e = sess.getAttributeNames();
38: while (e.hasMoreElements()) {
39: attrName = (String) e.nextElement();
40: attributes.put(attrName, new HttpSessionAttributeInfo(sess,
41: attrName));
42: }
43:
44: ObjectContext.getInstance().refresh(this , "attributes");
45: }
46:
47: public void onAttributesAdd() {
48: HttpSession session = (HttpSession) entity.getSystemSession();
49:
50: HttpSessionAttributeInfo instance = new HttpSessionAttributeInfo(
51: session, "");
52:
53: ObjectContext.getInstance().show(
54: new HttpSessionAttributeInfoInstance(instance));
55: }
56:
57: public void onAttributesView() {
58: onAttributesUpdate();
59: }
60:
61: public void onAttributesUpdate() {
62: if (attributeSelected == null)
63: return;
64:
65: ObjectContext.getInstance().show(
66: new HttpSessionAttributeInfoInstance(
67: (HttpSessionAttributeInfo) attributeSelected));
68: }
69:
70: public void onAttributesRemove() {
71: if (attributeSelected == null)
72: return;
73:
74: HttpSession session = (HttpSession) entity.getSystemSession();
75: session.removeAttribute(attributeSelected.getName());
76: }
77: }
|