1
16
17 package org.apache.wsrp4j.consumer.driver;
18
19 import java.util.HashMap;
20 import java.util.Iterator;
21 import java.util.Map;
22
23 import oasis.names.tc.wsrp.v1.types.SessionContext;
24
25 import org.apache.wsrp4j.consumer.PortletSession;
26 import org.apache.wsrp4j.consumer.PortletWindowSession;
27 import org.apache.wsrp4j.log.LogManager;
28 import org.apache.wsrp4j.log.Logger;
29
30 public abstract class GenericPortletSessionImpl implements PortletSession {
31 private SessionContext sessionCtx = null;
33
34 private String handle = null;
36
37 protected final Map windowSessions;
39
40 private static final Logger logger = LogManager.getLogManager().getLogger(
42 GenericPortletSessionImpl.class);
43
44 public GenericPortletSessionImpl(String handle) {
45 final String MN = "constructor";
46 if (logger.isLogging(Logger.TRACE_HIGH)) {
47 logger.entry(Logger.TRACE_HIGH, MN);
48 }
49
50 this.windowSessions = new HashMap();
51 this.handle = handle;
52
53 if (logger.isLogging(Logger.TRACE_HIGH)) {
54 logger.exit(Logger.TRACE_HIGH, MN);
55 }
56 }
57
58 public String getPortletHandle() {
59 return handle;
60 }
61
62 public void setPortletHandle(String handle) {
63 if (handle != null) {
64 this.handle = handle;
65 }
66 }
67
68 public SessionContext getSessionContext() {
69 return sessionCtx;
70 }
71
72 public void setSessionContext(SessionContext ctx) {
73 this.sessionCtx = ctx;
74 }
75
76
82 public abstract PortletWindowSession getPortletWindowSession(String windowID);
83
84
89 public Iterator getAllPorletWindowSessions() {
90
91 return this.windowSessions.entrySet().iterator();
92 }
93
94
100 public PortletWindowSession removePortletWindowSession(String windowID) {
101 final String MN = "getPortletWindowSession";
102
103 PortletWindowSession winSession = (PortletWindowSession) this.windowSessions
104 .remove(windowID);
105
106 if (logger.isLogging(Logger.TRACE_HIGH) && winSession != null) {
107 logger.text(Logger.TRACE_HIGH, MN,
108 "removed PortletWindowSession with ID: " + windowID);
109 }
110
111 return winSession;
112 }
113
114
117 public void removeAllPortletWindowSessions() {
118 this.windowSessions.clear();
119 }
120 }