Source Code Cross Referenced for JServiceEndpointHome.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ejb » container » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_ejb.container 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server Copyright (C) 1999 Bull S.A. Contact:
003:         * jonas-team@objectweb.org This library is free software; you can redistribute
004:         * it and/or modify it under the terms of the GNU Lesser General Public License
005:         * as published by the Free Software Foundation; either version 2.1 of the
006:         * License, or any later version. This library is distributed in the hope that
007:         * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
008:         * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
009:         * Lesser General Public License for more details. You should have received a
010:         * copy of the GNU Lesser General Public License along with this library; if
011:         * not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
012:         * Boston, MA 02111-1307 USA
013:         * --------------------------------------------------------------------------
014:         * $Id: JServiceEndpointHome.java 9584 2006-09-12 15:10:41Z sauthieg $
015:         * --------------------------------------------------------------------------
016:         */package org.objectweb.jonas_ejb.container;
017:
018:        import java.rmi.RemoteException;
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.Map;
022:
023:        import javax.ejb.EJBException;
024:        import javax.naming.Context;
025:        import javax.naming.NamingException;
026:        import javax.naming.Reference;
027:        import javax.naming.StringRefAddr;
028:        import javax.xml.namespace.QName;
029:        import javax.xml.soap.SOAPBody;
030:        import javax.xml.soap.SOAPElement;
031:        import javax.xml.soap.SOAPEnvelope;
032:        import javax.xml.soap.SOAPException;
033:
034:        import org.apache.axis.AxisFault;
035:        import org.apache.axis.MessageContext;
036:
037:        import org.objectweb.jonas_ejb.deployment.api.MethodDesc;
038:        import org.objectweb.jonas_ejb.deployment.api.SessionStatelessDesc;
039:        import org.objectweb.jonas_ejb.lib.BeanNaming;
040:        import org.objectweb.jonas_ejb.lib.EJBInvocation;
041:
042:        import org.objectweb.jonas.common.Log;
043:
044:        import org.objectweb.util.monolog.api.BasicLevel;
045:        import org.objectweb.util.monolog.api.Logger;
046:
047:        /**
048:         * This class is a factory for JServiceEndpoint objects.
049:         * @author Philippe Durieux
050:         */
051:        public abstract class JServiceEndpointHome {
052:
053:            /**
054:             * Logger, used also in the generated part.
055:             */
056:            protected static Logger logger = Log
057:                    .getLogger(Log.JONAS_WS_EJBPROVIDER_PREFIX);
058:            protected static Logger lognaming = Log
059:                    .getLogger(Log.JONAS_NAMING_PREFIX);
060:
061:            protected SessionStatelessDesc dd;
062:
063:            protected JFactory bf;
064:
065:            // The static table of all JServiceEndpointHome objects
066:            protected static Map sehomeList = new HashMap();
067:
068:            /**
069:             * constructor
070:             * @param dd The Session Deployment Decriptor
071:             * @param bf The Session Factory
072:             */
073:            public JServiceEndpointHome(SessionStatelessDesc dd,
074:                    JStatelessFactory bf) {
075:                if (logger.isLoggable(BasicLevel.DEBUG)) {
076:                    logger.log(BasicLevel.DEBUG, "");
077:                }
078:                this .dd = dd;
079:                this .bf = bf;
080:            }
081:
082:            /**
083:             * register this bean to JNDI (rebind) We register actually a Reference
084:             * object.
085:             */
086:            protected void register() throws NamingException {
087:                if (logger.isLoggable(BasicLevel.DEBUG)) {
088:                    logger.log(BasicLevel.DEBUG, "");
089:                }
090:                String name = dd.getJndiServiceEndpointName();
091:
092:                // Keep it in the static list for later retrieving.
093:                sehomeList.put(name, this );
094:
095:                Reference ref = new Reference(
096:                        "org.objectweb.jonas_ejb.container.JServiceEndpointHome",
097:                        "org.objectweb.jonas_ejb.container.HomeFactory", null);
098:                ref.add(new StringRefAddr("bean.name", name));
099:                bf.getInitialContext().rebind(name, ref);
100:            }
101:
102:            /**
103:             * unregister this bean in JNDI (unbind)
104:             */
105:            protected void unregister() throws NamingException {
106:                if (logger.isLoggable(BasicLevel.DEBUG)) {
107:                    logger.log(BasicLevel.DEBUG, "");
108:                }
109:                String name = dd.getJndiServiceEndpointName();
110:                // unregister in default InitialContext
111:                bf.getInitialContext().unbind(name);
112:                // remove from the static list
113:                sehomeList.remove(name);
114:            }
115:
116:            /**
117:             * Get JServiceEndpointHome by its name
118:             * used by HomeFactory to retrieve object from its reference.
119:             * @param beanName The Bean JNDI local Name
120:             * @return The Bean ServiceEndpointHome
121:             */
122:            public static JServiceEndpointHome getSEHome(String beanName) {
123:                if (logger.isLoggable(BasicLevel.DEBUG)) {
124:                    logger.log(BasicLevel.DEBUG, "");
125:                }
126:                JServiceEndpointHome seh = (JServiceEndpointHome) sehomeList
127:                        .get(beanName);
128:                return seh;
129:            }
130:
131:            /**
132:             * unique create method
133:             */
134:            public JServiceEndpoint create() throws RemoteException {
135:                if (TraceEjb.isDebugIc()) {
136:                    TraceEjb.interp.log(BasicLevel.DEBUG, "");
137:                }
138:                RequestCtx rctx = bf.preInvoke(MethodDesc.TX_NOT_SET);
139:                bf.checkSecurity(null);
140:                JStatelessSwitch bs = null;
141:                try {
142:                    bs = (JStatelessSwitch) ((JStatelessFactory) bf)
143:                            .createEJB();
144:                } catch (javax.ejb.AccessLocalException e) {
145:                    throw new EJBException(
146:                            "Security Exception thrown by an enterprise Bean",
147:                            e);
148:                } catch (EJBException e) {
149:                    rctx.sysExc = e;
150:                    throw e;
151:                } catch (RuntimeException e) {
152:                    rctx.sysExc = e;
153:                    throw new EJBException(
154:                            "RuntimeException thrown by an enterprise Bean", e);
155:                } catch (Error e) {
156:                    rctx.sysExc = e;
157:                    throw new EJBException("Error thrown by an enterprise Bean"
158:                            + e);
159:                } catch (RemoteException e) {
160:                    rctx.sysExc = e;
161:                    throw new EJBException("Remote Exception raised:", e);
162:                } finally {
163:                    bf.postInvoke(rctx);
164:                }
165:                return bs.getServiceEndpoint();
166:            }
167:
168:            /**
169:             * Set the bean environment in current context
170:             * @return previous Context
171:             */
172:            public Context setCompCtx() {
173:                if (lognaming.isLoggable(BasicLevel.DEBUG)) {
174:                    lognaming.log(BasicLevel.DEBUG, "");
175:                }
176:                return bf.setComponentContext();
177:            }
178:
179:            /**
180:             * Restore old value
181:             * @return previous Context
182:             */
183:            public void resetCompCtx(Context ctx) {
184:                if (lognaming.isLoggable(BasicLevel.DEBUG)) {
185:                    lognaming.log(BasicLevel.DEBUG, "reset ctx:" + ctx);
186:                }
187:                bf.resetComponentContext(ctx);
188:            }
189:
190:            /**
191:             * Check security with the Meesage Context
192:             */
193:            public void checkSecurity(MessageContext msgContext) {
194:
195:                EJBInvocation ejb = new EJBInvocation();
196:                QName q = null;
197:                try {
198:                    SOAPEnvelope env = msgContext.getMessage().getSOAPPart()
199:                            .getEnvelope();
200:                    SOAPBody body = env.getBody();
201:                    Iterator it = body.getChildElements();
202:                    SOAPElement operation = (SOAPElement) it.next();
203:
204:                    q = new QName(operation.getNamespaceURI(), operation
205:                            .getLocalName());
206:                    ejb.methodPermissionSignature = BeanNaming.getSignature(bf
207:                            .getEJBName(), msgContext.getOperationByQName(q)
208:                            .getMethod());
209:                } catch (AxisFault e) {
210:                    // error during getting the operation from the message
211:                    // not possible to check the security
212:                    if (lognaming.isLoggable(BasicLevel.WARN))
213:                        lognaming
214:                                .log(BasicLevel.WARN,
215:                                        "can't retreive the operation from message...can not check the security");
216:                    return;
217:                } catch (SOAPException e) {
218:                    // error during getting the operation from the message
219:                    // not possible to check the security
220:                    if (lognaming.isLoggable(BasicLevel.WARN))
221:                        lognaming
222:                                .log(BasicLevel.WARN,
223:                                        "can't retreive the operation from message...can not check the security");
224:                    return;
225:                }
226:
227:                bf.checkSecurity(ejb);
228:            }
229:
230:            /**
231:             * @return A JServiceEndpoint that can be used by the JonasEJBProvider
232:             */
233:            public abstract JServiceEndpoint createServiceEndpointObject()
234:                    throws RemoteException;
235:
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.