Source Code Cross Referenced for JAXWSEJBModuleBuilderExtension.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.URL;
019:        import java.util.Collection;
020:        import java.util.HashMap;
021:        import java.util.List;
022:        import java.util.Map;
023:        import java.util.jar.JarFile;
024:
025:        import org.apache.geronimo.common.DeploymentException;
026:        import org.apache.geronimo.deployment.ModuleIDBuilder;
027:        import org.apache.geronimo.deployment.service.EnvironmentBuilder;
028:        import org.apache.geronimo.gbean.AbstractName;
029:        import org.apache.geronimo.gbean.AbstractNameQuery;
030:        import org.apache.geronimo.gbean.GBeanData;
031:        import org.apache.geronimo.gbean.GBeanInfo;
032:        import org.apache.geronimo.gbean.GBeanInfoBuilder;
033:        import org.apache.geronimo.j2ee.deployment.EARContext;
034:        import org.apache.geronimo.j2ee.deployment.Module;
035:        import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
036:        import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
037:        import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
038:        import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
039:        import org.apache.geronimo.kernel.Kernel;
040:        import org.apache.geronimo.kernel.Naming;
041:        import org.apache.geronimo.kernel.config.ConfigurationModuleType;
042:        import org.apache.geronimo.kernel.config.ConfigurationStore;
043:        import org.apache.geronimo.kernel.repository.Environment;
044:        import org.apache.geronimo.openejb.deployment.EjbModule;
045:        import org.apache.openejb.assembler.classic.EnterpriseBeanInfo;
046:        import org.apache.openejb.jee.oejb2.GeronimoEjbJarType;
047:        import org.apache.openejb.jee.oejb2.WebServiceBindingType;
048:        import org.apache.openejb.jee.oejb2.WebServiceBindingType.WebServiceSecurityType;
049:
050:        /**
051:         * @version $Rev$ $Date$
052:         */
053:        public class JAXWSEJBModuleBuilderExtension implements 
054:                ModuleBuilderExtension {
055:
056:            protected WebServiceBuilder jaxwsBuilder;
057:            protected AbstractNameQuery listener;
058:            protected GBeanInfo wsGBeanInfo;
059:            protected Environment defaultEnvironment;
060:
061:            public JAXWSEJBModuleBuilderExtension() throws Exception {
062:            }
063:
064:            public JAXWSEJBModuleBuilderExtension(WebServiceBuilder wsBuilder,
065:                    Environment defaultEnvironment, AbstractNameQuery listener,
066:                    Object dataLink, Kernel kernel) throws Exception {
067:                this .jaxwsBuilder = wsBuilder;
068:                this .listener = listener;
069:                this .defaultEnvironment = defaultEnvironment;
070:                this .wsGBeanInfo = getGBeanInfo(kernel, dataLink);
071:            }
072:
073:            private static GBeanInfo getGBeanInfo(Kernel kernel,
074:                    Object webServiceLinkTemplate) throws Exception {
075:                AbstractName webServiceLinkTemplateName = kernel
076:                        .getAbstractNameFor(webServiceLinkTemplate);
077:                return kernel.getGBeanInfo(webServiceLinkTemplateName);
078:            }
079:
080:            public void createModule(Module module, Object plan,
081:                    JarFile moduleFile, String targetPath, URL specDDUrl,
082:                    Environment environment, Object moduleContextInfo,
083:                    AbstractName earName, Naming naming,
084:                    ModuleIDBuilder idBuilder) throws DeploymentException {
085:                if (this .defaultEnvironment != null) {
086:                    EnvironmentBuilder.mergeEnvironments(environment,
087:                            this .defaultEnvironment);
088:                }
089:            }
090:
091:            public void installModule(JarFile earFile, EARContext earContext,
092:                    Module module, Collection configurationStores,
093:                    ConfigurationStore targetConfigurationStore,
094:                    Collection repository) throws DeploymentException {
095:            }
096:
097:            public void initContext(EARContext earContext, Module module,
098:                    ClassLoader cl) throws DeploymentException {
099:                if (module.getType() != ConfigurationModuleType.EJB) {
100:                    return;
101:                }
102:
103:                EjbModule ejbModule = (EjbModule) module;
104:                Environment environment = module.getEnvironment();
105:
106:                //overridden web service locations       
107:                Map correctedPortLocations = new HashMap();
108:                GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule
109:                        .getEjbModule().getAltDDs().get("geronimo-openejb.xml");
110:                if (geronimoEjbJarType != null) {
111:                    for (WebServiceBindingType bt : geronimoEjbJarType
112:                            .getWebServiceBinding()) {
113:                        String location = bt.getWebServiceAddress();
114:                        if (location != null) {
115:                            location = location.trim();
116:                            if (!location.startsWith("/")) {
117:                                location = "/" + location;
118:                            }
119:                            correctedPortLocations.put(bt.getEjbName(),
120:                                    location);
121:                        }
122:                    }
123:                }
124:
125:                jaxwsBuilder.findWebServices(module, true,
126:                        correctedPortLocations, environment, ejbModule
127:                                .getSharedContext());
128:            }
129:
130:            public void addGBeans(EARContext earContext, Module module,
131:                    ClassLoader cl, Collection repository)
132:                    throws DeploymentException {
133:                if (module.getType() != ConfigurationModuleType.EJB) {
134:                    return;
135:                }
136:
137:                EjbModule ejbModule = (EjbModule) module;
138:
139:                Map<String, WebServiceBindingType> wsBindingMap = createWebServiceBindingMap(ejbModule);
140:
141:                for (EnterpriseBeanInfo bean : ejbModule.getEjbJarInfo().enterpriseBeans) {
142:                    if (bean.type != EnterpriseBeanInfo.STATELESS) {
143:                        continue;
144:                    }
145:
146:                    String ejbName = bean.ejbName;
147:
148:                    AbstractName sessionName = earContext.getNaming()
149:                            .createChildName(module.getModuleName(), ejbName,
150:                                    NameFactory.STATELESS_SESSION_BEAN);
151:
152:                    assert sessionName != null : "StatelesSessionBean object name is null";
153:
154:                    AbstractName ejbWebServiceName = earContext.getNaming()
155:                            .createChildName(sessionName, ejbName,
156:                                    NameFactory.WEB_SERVICE_LINK);
157:
158:                    GBeanData ejbWebServiceGBean = new GBeanData(
159:                            ejbWebServiceName, this .wsGBeanInfo);
160:
161:                    ejbWebServiceGBean.setAttribute("ejbName", ejbName);
162:                    ejbWebServiceGBean.setAttribute("ejbClass", bean.ejbClass);
163:
164:                    WebServiceBindingType wsBinding = wsBindingMap.get(ejbName);
165:                    if (wsBinding != null) {
166:                        List<String> ddVirtualHosts = wsBinding
167:                                .getWebServiceVirtualHost();
168:                        if (ddVirtualHosts != null) {
169:                            String[] virtualHosts = new String[ddVirtualHosts
170:                                    .size()];
171:                            for (int i = 0; i < ddVirtualHosts.size(); i++) {
172:                                virtualHosts[i] = ddVirtualHosts.get(i).trim();
173:                            }
174:                            ejbWebServiceGBean.setAttribute("virtualHosts",
175:                                    virtualHosts);
176:                        }
177:
178:                        WebServiceSecurityType wsSecurity = wsBinding
179:                                .getWebServiceSecurity();
180:                        if (wsSecurity != null) {
181:                            ejbWebServiceGBean.setAttribute(
182:                                    "securityRealmName", wsSecurity
183:                                            .getSecurityRealmName().trim());
184:                            ejbWebServiceGBean
185:                                    .setAttribute("transportGuarantee",
186:                                            wsSecurity.getTransportGuarantee()
187:                                                    .toString());
188:                            ejbWebServiceGBean.setAttribute("authMethod",
189:                                    wsSecurity.getAuthMethod().value());
190:                            if (wsSecurity.getRealmName() != null) {
191:                                ejbWebServiceGBean.setAttribute("realmName",
192:                                        wsSecurity.getRealmName().trim());
193:                            }
194:                        }
195:                    }
196:
197:                    if (jaxwsBuilder.configureEJB(ejbWebServiceGBean,
198:                            bean.ejbName, ejbModule, ejbModule
199:                                    .getSharedContext(), cl)) {
200:
201:                        try {
202:                            earContext.addGBean(ejbWebServiceGBean);
203:                        } catch (GBeanAlreadyExistsException e) {
204:                            throw new DeploymentException(
205:                                    "Could not add ejb web service gbean to context",
206:                                    e);
207:                        }
208:
209:                        if (this .listener != null) {
210:                            ejbWebServiceGBean.setReferencePattern(
211:                                    "WebServiceContainer", this .listener);
212:                        }
213:
214:                        ejbWebServiceGBean.setReferencePattern("EjbDeployment",
215:                                sessionName);
216:                    }
217:
218:                    ejbWebServiceGBean.clearAttribute("ejbName");
219:                    ejbWebServiceGBean.clearAttribute("ejbClass");
220:
221:                }
222:            }
223:
224:            private Map<String, WebServiceBindingType> createWebServiceBindingMap(
225:                    EjbModule ejbModule) {
226:                Map<String, WebServiceBindingType> wsBindingMap = new HashMap<String, WebServiceBindingType>();
227:                GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule
228:                        .getEjbModule().getAltDDs().get("geronimo-openejb.xml");
229:                if (geronimoEjbJarType != null) {
230:                    for (WebServiceBindingType bt : geronimoEjbJarType
231:                            .getWebServiceBinding()) {
232:                        wsBindingMap.put(bt.getEjbName(), bt);
233:                    }
234:                }
235:                return wsBindingMap;
236:            }
237:
238:            public static final GBeanInfo GBEAN_INFO;
239:
240:            static {
241:                GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(
242:                        JAXWSEJBModuleBuilderExtension.class,
243:                        NameFactory.MODULE_BUILDER);
244:                infoBuilder.addInterface(ModuleBuilderExtension.class);
245:                infoBuilder.addReference("WebServiceBuilder",
246:                        WebServiceBuilder.class, NameFactory.MODULE_BUILDER);
247:                infoBuilder.addAttribute("defaultEnvironment",
248:                        Environment.class, true, true);
249:                infoBuilder.addAttribute("listener", AbstractNameQuery.class,
250:                        true);
251:                infoBuilder.addReference("WebServiceLinkTemplate",
252:                        Object.class, NameFactory.WEB_SERVICE_LINK);
253:                infoBuilder.addAttribute("kernel", Kernel.class, false);
254:
255:                infoBuilder.setConstructor(new String[] { "WebServiceBuilder",
256:                        "defaultEnvironment", "listener",
257:                        "WebServiceLinkTemplate", "kernel" });
258:
259:                GBEAN_INFO = infoBuilder.getBeanInfo();
260:            }
261:
262:            public static GBeanInfo getGBeanInfo() {
263:                return GBEAN_INFO;
264:            }
265:
266:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.