1
16
17 package org.apache.wsrp4j.consumer.driver;
18
19 import java.util.Hashtable;
20 import java.util.Iterator;
21
22 import org.apache.wsrp4j.consumer.GroupSessionMgr;
23 import org.apache.wsrp4j.consumer.PortletSession;
24 import org.apache.wsrp4j.exception.WSRPException;
25 import org.apache.wsrp4j.log.LogManager;
26 import org.apache.wsrp4j.log.Logger;
27
28
32 public abstract class GenericGroupSessionImpl extends InitCookieInfoImpl
33 implements GroupSessionMgr {
34
35 private String groupID = null;
37
38 protected Hashtable portletSessions = null;
40
41 private static final Logger logger = LogManager.getLogManager().getLogger(
43 GenericGroupSessionImpl.class);
44
45 public GenericGroupSessionImpl(String groupID, String markupInterfaceURL)
46 throws WSRPException {
47 super(markupInterfaceURL);
48
49 final String MN = "constructor";
50 if (logger.isLogging(Logger.TRACE_HIGH)) {
51 logger.entry(Logger.TRACE_HIGH, MN);
52 }
53
54 this.groupID = groupID;
55 this.portletSessions = new Hashtable();
56
57 if (logger.isLogging(Logger.TRACE_HIGH)) {
58 logger.exit(Logger.TRACE_HIGH, MN);
59 }
60 }
61
62 public String getGroupID() {
63 return this.groupID;
64 }
65
66 public void setGroupID(String groupID) {
67 if (groupID != null) {
68 this.groupID = groupID;
69 }
70 }
71
72 public void addPortletSession(PortletSession portletSession) {
73 final String MN = "addPortletSession";
74
75 if (portletSession != null) {
76 this.portletSessions.put(portletSession.getPortletHandle(),
77 portletSession);
78 if (logger.isLogging(Logger.TRACE_HIGH)) {
79 logger.text(Logger.TRACE_HIGH, MN,
80 "added PortletSession with handle: "
81 + portletSession.getPortletHandle()
82 + " to GroupSession with ID: " + groupID);
83 }
84 }
85 }
86
87 public abstract PortletSession getPortletSession(String portletHandle);
88
89 public Iterator getAllPortletSessions() {
90 return this.portletSessions.values().iterator();
91 }
92
93 public void removePortletSession(String portletHandle) {
94 final String MN = "removePortletSession";
95 if (portletHandle == null) {
96 this.portletSessions.remove(portletHandle);
97 if (logger.isLogging(Logger.TRACE_HIGH)) {
98 logger.text(Logger.TRACE_HIGH, MN,
99 "deleted PortletSession with handle: " + portletHandle
100 + " from GroupSession with ID: " + groupID);
101 }
102 }
103 }
104
105 public void removeAllPortletSessions() {
106 this.portletSessions.clear();
107 }
108
109 public boolean existsPortletSession(String portletHandle) {
110 if (portletHandle == null)
111 return false;
112 return this.portletSessions.containsKey(portletHandle);
113 }
114 }