Source Code Cross Referenced for JAXWSServiceRefBuilder.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » jaxws » builder » 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 » EJB Server geronimo » plugins » org.apache.geronimo.jaxws.builder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.jaxws.builder;
017:
018:        import java.net.URI;
019:        import java.net.URISyntaxException;
020:        import java.util.HashMap;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import javax.xml.namespace.QName;
025:        import javax.xml.ws.Service;
026:        import javax.xml.ws.handler.Handler;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.apache.geronimo.common.DeploymentException;
031:        import org.apache.geronimo.j2ee.deployment.Module;
032:        import org.apache.geronimo.kernel.repository.Environment;
033:        import org.apache.geronimo.naming.deployment.AbstractNamingBuilder;
034:        import org.apache.geronimo.naming.deployment.ServiceRefBuilder;
035:        import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefDocument;
036:        import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
037:        import org.apache.geronimo.xbeans.javaee.PortComponentRefType;
038:        import org.apache.geronimo.xbeans.javaee.ServiceRefHandlerChainType;
039:        import org.apache.geronimo.xbeans.javaee.ServiceRefHandlerChainsType;
040:        import org.apache.geronimo.xbeans.javaee.ServiceRefHandlerType;
041:        import org.apache.geronimo.xbeans.javaee.ServiceRefType;
042:
043:        import org.apache.xmlbeans.QNameSet;
044:        import org.apache.xmlbeans.XmlObject;
045:
046:        public abstract class JAXWSServiceRefBuilder extends
047:                AbstractNamingBuilder implements  ServiceRefBuilder {
048:            private static final Log log = LogFactory
049:                    .getLog(JAXWSServiceRefBuilder.class);
050:
051:            private static final QName GER_SERVICE_REF_QNAME = GerServiceRefDocument.type
052:                    .getDocumentElementName();
053:
054:            private static final QNameSet GER_SERVICE_REF_QNAME_SET = QNameSet
055:                    .singleton(GER_SERVICE_REF_QNAME);
056:
057:            private final QNameSet serviceRefQNameSet;
058:
059:            public JAXWSServiceRefBuilder(Environment defaultEnvironment,
060:                    String[] eeNamespaces) {
061:                super (defaultEnvironment);
062:                serviceRefQNameSet = buildQNameSet(eeNamespaces, "service-ref");
063:            }
064:
065:            protected boolean willMergeEnvironment(XmlObject specDD,
066:                    XmlObject plan) {
067:                return specDD.selectChildren(serviceRefQNameSet).length > 0;
068:            }
069:
070:            public void buildNaming(XmlObject specDD, XmlObject plan,
071:                    Module module, Map componentContext)
072:                    throws DeploymentException {
073:                List<ServiceRefType> serviceRefsUntyped = convert(specDD
074:                        .selectChildren(serviceRefQNameSet), JEE_CONVERTER,
075:                        ServiceRefType.class, ServiceRefType.type);
076:                XmlObject[] gerServiceRefsUntyped = plan == null ? NO_REFS
077:                        : plan.selectChildren(GER_SERVICE_REF_QNAME_SET);
078:                Map serviceRefMap = mapServiceRefs(gerServiceRefsUntyped);
079:
080:                for (ServiceRefType serviceRef : serviceRefsUntyped) {
081:                    String name = getStringValue(serviceRef.getServiceRefName());
082:                    addInjections(name, serviceRef.getInjectionTargetArray(),
083:                            componentContext);
084:                    GerServiceRefType serviceRefType = (GerServiceRefType) serviceRefMap
085:                            .get(name);
086:                    serviceRefMap.remove(name);
087:                    buildNaming(serviceRef, serviceRefType, module,
088:                            componentContext);
089:                }
090:
091:                if (serviceRefMap.size() > 0) {
092:                    log
093:                            .warn("Failed to build reference to service reference "
094:                                    + serviceRefMap.keySet()
095:                                    + " defined in plan file, reason - corresponding entry in deployment descriptor missing.");
096:                }
097:            }
098:
099:            private Class loadClass(String className, ClassLoader cl,
100:                    String classDescription) throws DeploymentException {
101:                try {
102:                    return cl.loadClass(className);
103:                } catch (ClassNotFoundException e) {
104:                    throw new DeploymentException("Could not load "
105:                            + classDescription + " class " + className, e);
106:                }
107:            }
108:
109:            public void buildNaming(XmlObject serviceRef,
110:                    GerServiceRefType gerServiceRefType, Module module,
111:                    Map componentContext) throws DeploymentException {
112:                ServiceRefType serviceRefType = (ServiceRefType) convert(
113:                        serviceRef, JEE_CONVERTER, ServiceRefType.type);
114:                buildNaming(serviceRefType, gerServiceRefType, module,
115:                        componentContext);
116:            }
117:
118:            public void buildNaming(ServiceRefType serviceRef,
119:                    GerServiceRefType gerServiceRef, Module module,
120:                    Map componentContext) throws DeploymentException {
121:                ClassLoader cl = module.getEarContext().getClassLoader();
122:                String name = getStringValue(serviceRef.getServiceRefName());
123:
124:                String serviceInterfaceName = getStringValue(serviceRef
125:                        .getServiceInterface());
126:                Class serviceInterfaceClass = loadClass(serviceInterfaceName,
127:                        cl, "service");
128:                if (!Service.class.isAssignableFrom(serviceInterfaceClass)) {
129:                    throw new DeploymentException(serviceInterfaceName
130:                            + " service class does not extend "
131:                            + Service.class.getName());
132:                }
133:
134:                QName serviceQName = null;
135:                if (serviceRef.isSetServiceQname()) {
136:                    serviceQName = serviceRef.getServiceQname().getQNameValue();
137:                }
138:
139:                URI wsdlURI = null;
140:                if (serviceRef.isSetWsdlFile()) {
141:                    String wsdlLocation = serviceRef.getWsdlFile()
142:                            .getStringValue().trim();
143:                    try {
144:                        wsdlURI = new URI(wsdlLocation);
145:                    } catch (URISyntaxException e) {
146:                        throw new DeploymentException(
147:                                "Could not construct WSDL URI from "
148:                                        + wsdlLocation, e);
149:                    }
150:                }
151:
152:                Class serviceReferenceType = null;
153:                if (serviceRef.isSetServiceRefType()) {
154:                    String referenceClassName = getStringValue(serviceRef
155:                            .getServiceRefType());
156:                    serviceReferenceType = loadClass(referenceClassName, cl,
157:                            "service reference");
158:                }
159:
160:                if (serviceRef.isSetHandlerChains()) {
161:                    ServiceRefHandlerChainsType handlerChains = serviceRef
162:                            .getHandlerChains();
163:                    for (ServiceRefHandlerChainType handlerChain : handlerChains
164:                            .getHandlerChainArray()) {
165:                        for (ServiceRefHandlerType handler : handlerChain
166:                                .getHandlerArray()) {
167:                            String handlerClassName = getStringValue(handler
168:                                    .getHandlerClass());
169:                            Class handlerClass = loadClass(handlerClassName,
170:                                    cl, "handler");
171:                            if (!Handler.class.isAssignableFrom(handlerClass)) {
172:                                throw new DeploymentException(handlerClassName
173:                                        + " handler class does not extend "
174:                                        + Handler.class.getName());
175:                            }
176:                        }
177:                    }
178:                }
179:
180:                Map<Class, PortComponentRefType> portComponentRefMap = new HashMap<Class, PortComponentRefType>();
181:                PortComponentRefType[] portComponentRefs = serviceRef
182:                        .getPortComponentRefArray();
183:                if (portComponentRefs != null) {
184:                    for (int j = 0; j < portComponentRefs.length; j++) {
185:                        PortComponentRefType portComponentRef = portComponentRefs[j];
186:                        String serviceEndpointInterfaceType = getStringValue(portComponentRef
187:                                .getServiceEndpointInterface());
188:                        Class serviceEndpointClass = loadClass(
189:                                serviceEndpointInterfaceType, cl,
190:                                "service endpoint");
191:
192:                        // TODO: check if it is annotated?
193:
194:                        portComponentRefMap.put(serviceEndpointClass,
195:                                portComponentRef);
196:                    }
197:                }
198:
199:                Object ref = createService(serviceRef, gerServiceRef, module,
200:                        cl, serviceInterfaceClass, serviceQName, wsdlURI,
201:                        serviceReferenceType, portComponentRefMap);
202:                getJndiContextMap(componentContext).put(ENV + name, ref);
203:            }
204:
205:            public abstract Object createService(ServiceRefType serviceRef,
206:                    GerServiceRefType gerServiceRef, Module module,
207:                    ClassLoader cl, Class serviceInterfaceClass,
208:                    QName serviceQName, URI wsdlURI,
209:                    Class serviceReferenceType,
210:                    Map<Class, PortComponentRefType> portComponentRefMap)
211:                    throws DeploymentException;
212:
213:            private static Map mapServiceRefs(XmlObject[] refs) {
214:                Map refMap = new HashMap();
215:                if (refs != null) {
216:                    for (int i = 0; i < refs.length; i++) {
217:                        GerServiceRefType ref = (GerServiceRefType) refs[i]
218:                                .copy().changeType(GerServiceRefType.type);
219:                        String serviceRefName = ref.getServiceRefName().trim();
220:                        refMap.put(serviceRefName, ref);
221:                    }
222:                }
223:                return refMap;
224:            }
225:
226:            public QNameSet getSpecQNameSet() {
227:                return serviceRefQNameSet;
228:            }
229:
230:            public QNameSet getPlanQNameSet() {
231:                return GER_SERVICE_REF_QNAME_SET;
232:            }
233:
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.