Source Code Cross Referenced for VContextFactory.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ws » wsgen » generator » 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.wsgen.generator.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: VContextFactory.java 5409 2004-09-10 11:40:10Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ws.wsgen.generator.axis;
025:
026:        import java.util.Enumeration;
027:        import java.util.Hashtable;
028:        import java.util.Iterator;
029:        import java.util.List;
030:        import java.util.Map;
031:        import java.util.Vector;
032:
033:        import javax.wsdl.Definition;
034:        import javax.wsdl.Port;
035:        import javax.wsdl.Service;
036:        import javax.xml.namespace.QName;
037:
038:        import org.apache.velocity.VelocityContext;
039:
040:        import org.objectweb.jonas_lib.deployment.api.HandlerDesc;
041:
042:        import org.objectweb.jonas_ws.deployment.api.MappingFile;
043:        import org.objectweb.jonas_ws.deployment.api.PortComponentDesc;
044:        import org.objectweb.jonas_ws.deployment.api.SSBPortComponentDesc;
045:        import org.objectweb.jonas_ws.deployment.api.ServiceDesc;
046:        import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc;
047:
048:        /**
049:         * This class allows to create the Velocity Context used to build the generated
050:         * sources with the Velocity templates.
051:         *
052:         * @author Xavier Delplanque (Bull)
053:         */
054:        public class VContextFactory {
055:
056:            /**
057:             * Provider property name
058:             */
059:            public static final String PROVIDER = "provider";
060:
061:            /**
062:             * JOnAS EJB Provider name
063:             */
064:            public static final String EJB_PROVIDER = "JOnASEJB";
065:
066:            /**
067:             * Default RPC Provider name
068:             */
069:            public static final String RPC_PROVIDER = "RPC";
070:
071:            /**
072:             * Mapping property name
073:             */
074:            public static final String MAPPINGS = "mappings";
075:
076:            /**
077:             * Port Components list property name
078:             */
079:            public static final String PORT_COMPONENTS = "portComponents";
080:
081:            /**
082:             * WSDL directory in Webapp
083:             */
084:            private static final String WEB_WSDL = "WEB-INF/wsdl/";
085:
086:            /**
087:             * WSDL directory in EjbJar/Client
088:             */
089:            private static final String META_WSDL = "META-INF/wsdl/";
090:
091:            /**
092:             * Empty Constructor for Utility class
093:             */
094:            private VContextFactory() {
095:            }
096:
097:            /**
098:             * Creates the Velocity Context used to build the generated files with the
099:             * Velocity templates.
100:             *
101:             * @param sd The ServiceDesc Deployment Descriptor
102:             *
103:             * @return a VelocityContext customized with the SD
104:             */
105:            public static VelocityContext getContext(ServiceDesc sd) {
106:
107:                VelocityContext vc = new VelocityContext();
108:
109:                // Set provider value
110:                String wsdl;
111:                if (sd.getPortComponents().get(0) instanceof  SSBPortComponentDesc) {
112:                    // EJB Provider
113:                    vc.put(PROVIDER, EJB_PROVIDER);
114:                    // get wsdl name
115:                    wsdl = sd.getWSDL().getName().substring(META_WSDL.length());
116:                } else {
117:                    // JAXRPC Provider
118:                    vc.put(PROVIDER, RPC_PROVIDER);
119:                    // get wsdl name
120:                    wsdl = sd.getWSDL().getName().substring(WEB_WSDL.length());
121:                }
122:
123:                // Add all ports
124:                List ports = sd.getPortComponents();
125:                List portComponents = new Vector();
126:                for (Iterator it = ports.iterator(); it.hasNext();) {
127:                    PortComponentDesc pcd = (PortComponentDesc) it.next();
128:                    portComponents.add(new VcPortComponent(pcd, wsdl));
129:                }
130:                vc.put(PORT_COMPONENTS, portComponents);
131:
132:                // add types mappings
133:                List mappings = new Vector();
134:                MappingFile mf = sd.getMapping();
135:                for (Iterator m = mf.getXmlTypeMappings(); m.hasNext();) {
136:                    QName xml = (QName) m.next();
137:                    String classname = mf.getClassname(xml);
138:
139:                    // if we have an Array, Axis use a different representation
140:                    if (classname.endsWith("[]")) {
141:                        mappings.add(new VcArrayMapping(xml, classname));
142:                    } else {
143:                        mappings.add(new VcBeanMapping(xml, classname));
144:                    }
145:                }
146:                vc.put(MAPPINGS, mappings);
147:
148:                return vc;
149:            }
150:
151:            /**
152:             * Creates the Velocity Context used to build the generated files with the
153:             * Velocity templates.
154:             *
155:             * @param sr The ServiceRefDesc Deployment Descriptor
156:             *
157:             * @return a VelocityContext customized with the SR
158:             */
159:            public static VelocityContext getContext(ServiceRefDesc sr) {
160:
161:                VelocityContext vc = new VelocityContext();
162:
163:                Hashtable pcds = new Hashtable();
164:
165:                // for each service-ref handler
166:                List hrs = sr.getHandlerRefs();
167:
168:                Vector commonh = new Vector();
169:                for (Iterator itHr = hrs.iterator(); itHr.hasNext();) {
170:                    HandlerDesc hr = (HandlerDesc) itHr.next();
171:                    List pcns = hr.getPortNames();
172:
173:                    if (pcns.size() != 0) {
174:                        // a port name list is defined : add the handler to each
175:                        // specified port
176:                        for (Iterator itPcn = pcns.iterator(); itPcn.hasNext();) {
177:                            String pcn = (String) itPcn.next();
178:                            if (!pcds.containsKey(pcn)) {
179:                                pcds.put(pcn, new Vector());
180:                            }
181:                            ((Vector) pcds.get(pcn)).add(hr);
182:                        }
183:                    } else {
184:                        // no port name is specified : the handler is added to each
185:                        // port
186:                        commonh.add(hr);
187:                    }
188:                }
189:
190:                // now, we can create the port component list
191:                Vector portComponents = new Vector();
192:
193:                // if there is not port-component-ref
194:                if (pcds.isEmpty()) {
195:                    Definition def = sr.getWSDLFile().getDefinition();
196:                    Service s = def.getService(sr.getServiceQName());
197:                    Map ports = s.getPorts();
198:                    // for each wsdl:port
199:                    for (Iterator i = ports.values().iterator(); i.hasNext();) {
200:                        Port p = (Port) i.next();
201:                        portComponents.add(new VcPortComponent(p.getName(),
202:                                commonh));
203:                    }
204:                } else {
205:                    for (Enumeration enPc = pcds.keys(); enPc.hasMoreElements();) {
206:                        String pcn = (String) enPc.nextElement();
207:                        // add common handlers to the list
208:                        Vector pchrs = (Vector) pcds.get(pcn);
209:                        pchrs.addAll(commonh);
210:                        portComponents.add(new VcPortComponent(pcn, pchrs));
211:                    }
212:                }
213:
214:                vc.put(PORT_COMPONENTS, portComponents);
215:
216:                // add types mappings
217:                List mappings = new Vector();
218:                MappingFile mf = sr.getMappingFile();
219:                if (mf != null) {
220:                    for (Iterator m = mf.getXmlTypeMappings(); m.hasNext();) {
221:                        QName xml = (QName) m.next();
222:                        String classname = mf.getClassname(xml);
223:
224:                        // if we have an Array, Axis use a different representaion
225:                        if (classname.endsWith("[]")) {
226:                            mappings.add(new VcArrayMapping(xml, classname));
227:                        } else {
228:                            mappings.add(new VcBeanMapping(xml, classname));
229:                        }
230:                    }
231:                }
232:                vc.put(MAPPINGS, mappings);
233:
234:                return vc;
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.