Source Code Cross Referenced for JOnASEJBProvider.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » ws » axis » 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.ws.axis 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: JOnASEJBProvider.java 6100 2005-01-17 08:33:56Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.ws.axis;
025:
026:        import java.lang.reflect.Method;
027:
028:        import javax.naming.InitialContext;
029:        import javax.naming.NamingException;
030:
031:        import org.apache.axis.AxisFault;
032:        import org.apache.axis.Handler;
033:        import org.apache.axis.MessageContext;
034:        import org.apache.axis.i18n.Messages;
035:        import org.apache.axis.providers.java.RPCProvider;
036:
037:        import org.objectweb.jonas_ejb.container.JServiceEndpoint;
038:        import org.objectweb.jonas_ejb.container.JServiceEndpointHome;
039:
040:        import org.objectweb.jonas.common.Log;
041:        import org.objectweb.jonas.security.ws.SecurityContextHelper;
042:
043:        import org.objectweb.util.monolog.api.BasicLevel;
044:        import org.objectweb.util.monolog.api.Logger;
045:
046:        /**
047:         * Expose the service-endpoint interface of the Ejb.
048:         *
049:         * @author Guillaume Sauthier
050:         */
051:        public class JOnASEJBProvider extends RPCProvider {
052:
053:            /**
054:             * Logger
055:             */
056:            private static Logger logger = null;
057:
058:            /**
059:             * parameter service-endpoint class name
060:             */
061:            public static final String OPTION_SEINTERFACENAME = "serviceEndpointInterfaceName";
062:
063:            /**
064:             * parameter service-endpoint JNDI name
065:             */
066:            public static final String OPTION_SEJNDINAME = "serviceEndpointJndiName";
067:
068:            /**
069:             * cached initial context
070:             */
071:            private static InitialContext cachedContext;
072:
073:            /**
074:             * Create a new JOnASEJBProvider
075:             */
076:            public JOnASEJBProvider() {
077:                super ();
078:                logger = Log.getLogger(Log.JONAS_WS_EJBPROVIDER_PREFIX);
079:                logger.log(BasicLevel.DEBUG, "");
080:            }
081:
082:            /**
083:             * Override the default implementation
084:             * Return a object which implements the service.
085:             * @param msgContext the message context
086:             * @param seiName The Service Endpoint Interface classname
087:             * @return an object that implements the service
088:             * @throws Exception when trying to create a Serviceobject without serviceendpoint name aprameter
089:             */
090:            protected Object makeNewServiceObject(MessageContext msgContext,
091:                    String seiName) throws Exception {
092:                logger.log(BasicLevel.DEBUG, seiName);
093:                if (seiName == null) {
094:                    logger.log(BasicLevel.ERROR,
095:                            "Service Endpoint Interface classname is null");
096:                    // cannot find service-endpoint
097:                    throw new AxisFault(Messages.getMessage("noOption00",
098:                            OPTION_SEINTERFACENAME, msgContext.getService()
099:                                    .getName()));
100:                }
101:
102:                // Get ServiceEndpointHome in JNDI
103:                String jndiName = getStrOption(OPTION_SEJNDINAME, msgContext
104:                        .getService());
105:                if (jndiName == null) {
106:                    logger.log(BasicLevel.ERROR,
107:                            "Service Endpoint JNDI name is null");
108:                    throw new AxisFault("Missing parameter in service : "
109:                            + OPTION_SEJNDINAME);
110:                }
111:                JServiceEndpointHome sehome = null;
112:                try {
113:                    InitialContext ic = getCachedContext();
114:                    sehome = (JServiceEndpointHome) ic.lookup(jndiName);
115:                } catch (NamingException ne) {
116:                    logger.log(BasicLevel.ERROR,
117:                            "Cannot lookup ServiceEndpointHome");
118:                    throw new AxisFault("Cannot lookup ServiceEndpointHome: "
119:                            + jndiName);
120:                }
121:                // Check that the object implements the SEI
122:                // TODO
123:
124:                // Create a new ServiceEndpoint object
125:                JServiceEndpoint se = sehome.create();
126:
127:                // Set the MessageContext that can be retrived by the bean
128:                se.setMessageContext(msgContext);
129:                return se;
130:            }
131:
132:            /**
133:             * Override the default implementation : create a SecurityContext from username and password
134:             * @throws Exception if method invokation fail or produce an Exception
135:             */
136:            protected Object invokeMethod(MessageContext msgContext,
137:                    Method method, Object obj, Object[] argValues)
138:                    throws Exception {
139:                logger.log(BasicLevel.DEBUG, "");
140:                String username = msgContext.getUsername();
141:                if (username != null) {
142:                    // Do not forget to initialize the security context
143:                    SecurityContextHelper.getInstance().login(username,
144:                            msgContext.getPassword());
145:                }
146:                return super .invokeMethod(msgContext, method, obj, argValues);
147:            }
148:
149:            /**
150:             * Override the default implementation
151:             * @return Return the option in the configuration that contains the service
152:             *         class name. In the EJB case, it is the JNDI name of the bean.
153:             */
154:            protected String getServiceClassNameOptionName() {
155:                logger.log(BasicLevel.DEBUG, "");
156:                return OPTION_SEINTERFACENAME;
157:            }
158:
159:            /**
160:             * Get a String option by looking first in the service options, and then at
161:             * the Handler's options. This allows defaults to be specified at the
162:             * provider level, and then overriden for particular services.
163:             *
164:             * @param optionName the option to retrieve
165:             * @param service Option holder
166:             *
167:             * @return String the value of the option or null if not found in either
168:             *         scope
169:             */
170:            private String getStrOption(String optionName, Handler service) {
171:                String value = null;
172:                if (service != null) {
173:                    value = (String) service.getOption(optionName);
174:                }
175:                if (value == null) {
176:                    value = (String) getOption(optionName);
177:                }
178:                return value;
179:            }
180:
181:            /**
182:             * @return Returns the cached InitialContext (or created a new one)
183:             * @throws javax.naming.NamingException when InitialContext creation fails
184:             */
185:            private InitialContext getCachedContext()
186:                    throws javax.naming.NamingException {
187:                if (cachedContext == null) {
188:                    cachedContext = new InitialContext();
189:                }
190:                return cachedContext;
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.