01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.webadmin.httpd;
17:
18: import java.util.HashMap;
19:
20: import javax.ejb.CreateException;
21: import javax.ejb.SessionBean;
22: import javax.ejb.SessionContext;
23: import javax.ejb.Stateless;
24: import javax.ejb.RemoteHome;
25:
26: import org.apache.openejb.core.stateful.StatefulEjbObjectHandler;
27: import org.apache.openejb.util.proxy.ProxyManager;
28:
29: /**
30: * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
31: */
32: @Stateless(name="httpd/session")
33: @RemoteHome(WebSessionHome.class)
34: public class WebSessionBean implements SessionBean {
35:
36: private SessionContext ctx;
37: private HashMap attributes;
38:
39: public void ejbCreate() throws CreateException {
40: attributes = new HashMap();
41: }
42:
43: public String getId() {
44: Object obj = ProxyManager.getInvocationHandler(ctx
45: .getEJBObject());
46: StatefulEjbObjectHandler handler = (StatefulEjbObjectHandler) obj;
47: return handler.getRegistryId() + "";
48: }
49:
50: // private void uberHack() throws Exception {
51: // org.apache.catalina.core.StandardWrapperFacade standardWrapperFacade = (org.apache.catalina.core.StandardWrapperFacade)config;
52: // org.apache.catalina.core.ContainerBase containerBase = (org.apache.catalina.core.ContainerBase)standardWrapperFacade.config;
53: // org.apache.catalina.core.ContainerBase containerBase2 = (org.apache.catalina.core.ContainerBase)containerBase.parent;
54: // java.util.HashMap children = (java.util.HashMap)containerBase2.children;
55: // org.apache.catalina.core.StandardWrapper standardWrapper = (org.apache.catalina.core.StandardWrapper) children.get("jsp");
56: // org.apache.jasper.servlet.JspServlet jspServlet = (org.apache.jasper.servlet.JspServlet)standardWrapper.instance;
57: // jspServlet.rctxt;
58: // }
59:
60: public Object getAttribute(String name) {
61: return attributes.get(name);
62: }
63:
64: public void setAttribute(String name, Object value) {
65: attributes.put(name, value);
66: }
67:
68: public void removeAttribute(String name) {
69: attributes.remove(name);
70: }
71:
72: public void ejbActivate() {
73:
74: }
75:
76: public void ejbPassivate() {
77:
78: }
79:
80: public void ejbRemove() {
81:
82: }
83:
84: public void setSessionContext(SessionContext ctx) {
85: this.ctx = ctx;
86: }
87: }
|