Source Code Cross Referenced for JaxRpcServiceReference.java in  » J2EE » openejb3 » org » apache » openejb » core » ivm » naming » 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 » openejb3 » org.apache.openejb.core.ivm.naming 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *
003:         * Licensed to the Apache Software Foundation (ASF) under one or more
004:         * contributor license agreements.  See the NOTICE file distributed with
005:         * this work for additional information regarding copyright ownership.
006:         * The ASF licenses this file to You under the Apache License, Version 2.0
007:         * (the "License"); you may not use this file except in compliance with
008:         * the License.  You may obtain a copy of the License at
009:         *
010:         *     http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         *  Unless required by applicable law or agreed to in writing, software
013:         *  distributed under the License is distributed on an "AS IS" BASIS,
014:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         *  See the License for the specific language governing permissions and
016:         *  limitations under the License.
017:         */package org.apache.openejb.core.ivm.naming;
018:
019:        import org.apache.openejb.util.Logger;
020:        import org.apache.openejb.util.LogCategory;
021:
022:        import javax.naming.NamingException;
023:        import javax.xml.namespace.QName;
024:        import javax.xml.rpc.ServiceFactory;
025:        import javax.xml.rpc.Service;
026:        import javax.xml.rpc.ServiceException;
027:        import java.net.MalformedURLException;
028:        import java.net.URI;
029:        import java.net.URL;
030:
031:        // todo deal with handlers
032:        public class JaxRpcServiceReference extends Reference {
033:            private static final Logger logger = Logger.getInstance(
034:                    LogCategory.OPENEJB, JaxRpcServiceReference.class);
035:
036:            private String serviceClassName;
037:            private ClassLoader classLoader;
038:            private URI wsdlURI;
039:            private QName serviceQName;
040:            private String referenceClassName;
041:
042:            public JaxRpcServiceReference(QName serviceQName, URI wsdlURI,
043:                    String referenceClassName, String serviceClassName,
044:                    ClassLoader classLoader) {
045:                this .classLoader = classLoader;
046:                this .serviceQName = serviceQName;
047:                this .wsdlURI = wsdlURI;
048:                this .referenceClassName = referenceClassName;
049:                this .serviceClassName = serviceClassName;
050:            }
051:
052:            public Object getObject() throws NamingException {
053:                Class<? extends Service> serviceClass = loadClass(
054:                        serviceClassName).asSubclass(Service.class);
055:                Class<?> referenceClass = getReferenceClass();
056:
057:                if (referenceClass != null
058:                        && Service.class.isAssignableFrom(referenceClass)) {
059:                    serviceClass = referenceClass.asSubclass(Service.class);
060:                }
061:
062:                try {
063:                    Service instance;
064:                    if (Service.class.equals(serviceClass)) {
065:                        instance = ServiceFactory.newInstance().createService(
066:                                getWsdlURL(), serviceQName);
067:                    } else {
068:                        try {
069:                            instance = serviceClass.getConstructor(URL.class,
070:                                    QName.class).newInstance(getWsdlURL(),
071:                                    serviceQName);
072:                        } catch (Throwable e) {
073:                            throw (NamingException) new NamingException(
074:                                    "Could not instantiate jax-ws service class "
075:                                            + serviceClass.getName())
076:                                    .initCause(e);
077:                        }
078:                    }
079:
080:                    if (referenceClass != null
081:                            && !Service.class.isAssignableFrom(referenceClass)) {
082:                        // do port lookup
083:                        return instance.getPort(referenceClass);
084:                    } else {
085:                        // return service
086:                        return instance;
087:                    }
088:                } catch (ServiceException e) {
089:                    throw (NamingException) new NamingException(
090:                            "Error creating service proxy").initCause(e);
091:                }
092:            }
093:
094:            private Class getReferenceClass() throws NamingException {
095:                if (referenceClassName == null)
096:                    return null;
097:                return loadClass(referenceClassName);
098:            }
099:
100:            private Class<?> loadClass(String name) throws NamingException {
101:                try {
102:                    return classLoader.loadClass(name);
103:                } catch (ClassNotFoundException e) {
104:                    NamingException exception = new NamingException(
105:                            "Count not load class " + name);
106:                    exception.initCause(e);
107:                    throw exception;
108:                }
109:            }
110:
111:            private URL getWsdlURL() {
112:                if (wsdlURI == null)
113:                    return null;
114:
115:                try {
116:                    return new URL(wsdlURI.toString());
117:                } catch (MalformedURLException e) {
118:                    URL wsdlURL = classLoader.getResource(this .wsdlURI
119:                            .toString());
120:                    if (wsdlURL == null) {
121:                        logger.warning("Error obtaining WSDL: " + this.wsdlURI,
122:                                e);
123:                    }
124:                    return wsdlURL;
125:                }
126:            }
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.