001: package weblogic.servlet.internal;
002:
003: import java.util.List;
004:
005: import javax.servlet.http.HttpSessionAttributeListener;
006: import javax.servlet.http.HttpSessionListener;
007:
008: import weblogic.servlet.internal.session.SessionContext;
009:
010: /**
011: * This is a dummy class representing a real Weblogic class. It actually is being
012: * used as a dummy for both the Weblogic 8 AND 9 versions, which have different
013: * methods and fields.
014: *
015: * This class also has a bunch of methods that will be generated by ASM into the
016: * actual WL 8/9 class. All of these methods start with "__tc_". These methods
017: * are here so we can use the bytecode plugin to generate and maintain the
018: * necessary ASM code in WebAppServletContextAdapter.
019: */
020: public class WebAppServletContext {
021: // type stub only
022:
023: // === Dummy methods simulating real methods ===
024:
025: // Weblogic 8 only
026: private List sessAttrListeners;
027: private List sessListeners;
028: private String sessionCookieComment;
029: private String sessionCookieDomain;
030: private int sessionCookieMaxAgeSecs;
031: private String sessionCookieName;
032: private String sessionCookiePath;
033: private boolean sessionCookieSecure;
034: private boolean sessionCookiesEnabled;
035: private int sessionIDLength;
036: private int sessionTimeoutSecs;
037: private boolean sessionTrackingEnabled;
038: private boolean sessionURLRewritingEnabled;
039:
040: // Weblogic 8 and 9
041: private HttpServer httpServer;
042:
043: // Weblogic 9 only
044: private SessionContext sessionContext;
045:
046: public String getName() {
047: throw new AssertionError();
048: }
049:
050: public String getContextPath() {
051: throw new AssertionError();
052: }
053:
054: public HttpServer getServer() {
055: throw new AssertionError();
056: }
057:
058: public EventsManager getEventsManager() {
059: throw new AssertionError();
060: }
061:
062: // === Methods simulating those added by ASM ====
063:
064: public boolean __tc_isWeblogic8() {
065: try {
066: this .getClass().getDeclaredField("sessionCookieName");
067: return true;
068: } catch (Exception e) {
069: }
070: return false;
071: }
072:
073: public HttpSessionAttributeListener[] __tc_session_getHttpSessionAttributeListeners() {
074: if (__tc_isWeblogic8()) {
075: if (sessAttrListeners == null) {
076: return new HttpSessionAttributeListener[0];
077: } else {
078: return (HttpSessionAttributeListener[]) sessAttrListeners
079: .toArray(new HttpSessionAttributeListener[0]);
080: }
081: } else {
082: return getEventsManager()
083: .__tc_session_getHttpSessionAttributeListeners();
084: }
085: }
086:
087: public HttpSessionListener[] __tc_session_getHttpSessionListener() {
088: if (__tc_isWeblogic8()) {
089: if (sessListeners == null) {
090: return new HttpSessionListener[0];
091: } else {
092: return (HttpSessionListener[]) sessListeners
093: .toArray(new HttpSessionListener[0]);
094: }
095: } else {
096: return getEventsManager()
097: .__tc_session_getHttpSessionListener();
098: }
099: }
100:
101: public String __tc_session_getCookieComment() {
102: if (__tc_isWeblogic8()) {
103: return sessionCookieComment;
104: } else {
105: return sessionContext.getConfigMgr().getCookieComment();
106: }
107: }
108:
109: public String __tc_session_getCookieDomain() {
110: if (__tc_isWeblogic8()) {
111: return sessionCookieDomain;
112: } else {
113: return sessionContext.getConfigMgr().getCookieDomain();
114: }
115: }
116:
117: public int __tc_session_getCookieMaxAgeSecs() {
118: if (__tc_isWeblogic8()) {
119: return sessionCookieMaxAgeSecs;
120: } else {
121: return sessionContext.getConfigMgr().getCookieMaxAgeSecs();
122: }
123: }
124:
125: public String __tc_session_getCookieName() {
126: if (__tc_isWeblogic8()) {
127: return sessionCookieName;
128: } else {
129: return sessionContext.getConfigMgr().getCookieName();
130: }
131: }
132:
133: public String __tc_session_getCookiePath() {
134: if (__tc_isWeblogic8()) {
135: return sessionCookiePath;
136: } else {
137: return sessionContext.getConfigMgr().getCookiePath();
138: }
139: }
140:
141: public boolean __tc_session_getCookieSecure() {
142: if (__tc_isWeblogic8()) {
143: return sessionCookieSecure;
144: } else {
145: return sessionContext.getConfigMgr().isCookieSecure();
146: }
147: }
148:
149: public boolean __tc_session_getCookiesEnabled() {
150: if (__tc_isWeblogic8()) {
151: return sessionCookiesEnabled;
152: } else {
153: return sessionContext.getConfigMgr()
154: .isSessionCookiesEnabled();
155: }
156: }
157:
158: public int __tc_session_getIdLength() {
159: if (__tc_isWeblogic8()) {
160: return sessionIDLength;
161: } else {
162: return sessionContext.getConfigMgr().getIDLength();
163: }
164: }
165:
166: // same for both weblogic 8 and 9
167: public String __tc_session_getServerId() {
168: return httpServer.getServerHash();
169: }
170:
171: // same for both wl 8 and 9
172: public String __tc_session_getSessionDelimiter() {
173: return "!";
174: }
175:
176: public int __tc_session_getSessionTimeoutSecs() {
177: if (__tc_isWeblogic8()) {
178: return sessionTimeoutSecs;
179: } else {
180: return sessionContext.getConfigMgr()
181: .getSessionTimeoutSecs();
182: }
183: }
184:
185: public boolean __tc_session_getTrackingEnabled() {
186: if (__tc_isWeblogic8()) {
187: return sessionTrackingEnabled;
188: } else {
189: return sessionContext.getConfigMgr()
190: .isSessionTrackingEnabled();
191: }
192: }
193:
194: public boolean __tc_session_getURLRewritingEnabled() {
195: if (__tc_isWeblogic8()) {
196: return sessionURLRewritingEnabled;
197: } else {
198: return sessionContext.getConfigMgr()
199: .isUrlRewritingEnabled();
200: }
201: }
202:
203: }
|