Source Code Cross Referenced for ModelerUtils.java in  » 6.0-JDK-Modules » jax-ws-tools » com » sun » tools » ws » processor » modeler » wsdl » 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 » 6.0 JDK Modules » jax ws tools » com.sun.tools.ws.processor.modeler.wsdl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         * 
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common Development
008:         * and Distribution License("CDDL") (collectively, the "License").  You
009:         * may not use this file except in compliance with the License. You can obtain
010:         * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011:         * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
012:         * language governing permissions and limitations under the License.
013:         * 
014:         * When distributing the software, include this License Header Notice in each
015:         * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016:         * Sun designates this particular file as subject to the "Classpath" exception
017:         * as provided by Sun in the GPL Version 2 section of the License file that
018:         * accompanied this code.  If applicable, add the following below the License
019:         * Header, with the fields enclosed by brackets [] replaced by your own
020:         * identifying information: "Portions Copyrighted [year]
021:         * [name of copyright owner]"
022:         * 
023:         * Contributor(s):
024:         * 
025:         * If you wish your version of this file to be governed by only the CDDL or
026:         * only the GPL Version 2, indicate your decision by adding "[Contributor]
027:         * elects to include this software in this distribution under the [CDDL or GPL
028:         * Version 2] license."  If you don't indicate a single choice of license, a
029:         * recipient has the option to distribute your version of this file under
030:         * either the CDDL, the GPL Version 2 or to extend the choice of license to
031:         * its licensees as provided above.  However, if you add GPL Version 2 code
032:         * and therefore, elected the GPL Version 2 license, then the option applies
033:         * only if the new code is made subject to such option by the copyright
034:         * holder.
035:         */
036:        package com.sun.tools.ws.processor.modeler.wsdl;
037:
038:        import com.sun.tools.ws.processor.model.AbstractType;
039:        import com.sun.tools.ws.processor.model.Block;
040:        import com.sun.tools.ws.processor.model.ModelProperties;
041:        import com.sun.tools.ws.processor.model.Parameter;
042:        import com.sun.tools.ws.processor.model.java.JavaSimpleType;
043:        import com.sun.tools.ws.processor.model.java.JavaStructureMember;
044:        import com.sun.tools.ws.processor.model.java.JavaStructureType;
045:        import com.sun.tools.ws.processor.model.java.JavaType;
046:        import com.sun.tools.ws.processor.model.jaxb.*;
047:        import com.sun.tools.ws.resources.ModelerMessages;
048:        import com.sun.tools.ws.util.ClassNameInfo;
049:        import com.sun.tools.ws.wscompile.AbortException;
050:        import com.sun.tools.ws.wscompile.ErrorReceiverFilter;
051:        import com.sun.tools.ws.wsdl.document.Message;
052:        import com.sun.tools.ws.wsdl.document.MessagePart;
053:        import com.sun.tools.xjc.api.S2JJAXBModel;
054:        import com.sun.tools.xjc.api.TypeAndAnnotation;
055:
056:        import javax.xml.namespace.QName;
057:        import java.util.ArrayList;
058:        import java.util.Iterator;
059:        import java.util.List;
060:
061:        /**
062:         * Utilities to be used by WSDLModeler
063:         *
064:         * @author Vivek Pandey
065:         *
066:         */
067:        class ModelerUtils {
068:
069:            /**
070:             * This method should be called incase of wrapper style operations. This is
071:             * equivalent to wrapper style schema component or JAXB Mapping object.
072:             *
073:             * @param jaxbType JAXBType from which a JAXBStructured type will be created.
074:             * @return returns JAXBStructured type
075:             */
076:            public static JAXBStructuredType createJAXBStructureType(
077:                    JAXBType jaxbType) {
078:                JAXBStructuredType type = new JAXBStructuredType(jaxbType);
079:                type.setName(jaxbType.getName());
080:                type.setJavaType(jaxbType.getJavaType());
081:                return type;
082:            }
083:
084:            /**
085:             * This method uses JAXBStructured type (wrapper style operations) and
086:             * unwraps it to create list of parameters.
087:             *
088:             *
089:             * @param jaxbType instance of JAXBType, could be JAXBStructured type.
090:             * @param block The Block (body/Header/Attachment) to which the created Parameter belong.
091:             * @return list of Parameters
092:             */
093:            public static List<Parameter> createUnwrappedParameters(
094:                    JAXBType jaxbType, Block block) {
095:                List<Parameter> paramList = new ArrayList<Parameter>();
096:                JAXBStructuredType type = null;
097:                if (!(jaxbType instanceof  JAXBStructuredType))
098:                    type = createJAXBStructureType(jaxbType);
099:                else
100:                    type = (JAXBStructuredType) jaxbType;
101:
102:                JavaStructureType jst = new JavaStructureType(jaxbType
103:                        .getJavaType().getRealName(), true, type);
104:                type.setJavaType(jst);
105:                block.setType(type);
106:                List memberList = jaxbType.getWrapperChildren();
107:                Iterator props = memberList.iterator();
108:                while (props.hasNext()) {
109:                    JAXBProperty prop = (JAXBProperty) props.next();
110:                    paramList.add(createUnwrappedParameter(prop, jaxbType,
111:                            block, type, jst));
112:                }
113:
114:                return paramList;
115:            }
116:
117:            /**
118:             * @param prop
119:             * @param jaxbType
120:             * @param block
121:             * @return
122:             */
123:            private static Parameter createUnwrappedParameter(
124:                    JAXBProperty prop, JAXBType jaxbType, Block block,
125:                    JAXBStructuredType type, JavaStructureType jst) {
126:                QName elementName = prop.getElementName();
127:                JavaType javaType = new JavaSimpleType(prop.getType());
128:                JAXBElementMember eType = new JAXBElementMember(elementName,
129:                        jaxbType);
130:                JavaStructureMember jsm = new JavaStructureMember(elementName
131:                        .getLocalPart(), javaType, eType);
132:                eType.setJavaStructureMember(jsm);
133:                jst.add(jsm);
134:                eType.setProperty(prop);
135:                type.add(eType);
136:                JAXBType t = new JAXBType(elementName, javaType, jaxbType
137:                        .getJaxbMapping(), jaxbType.getJaxbModel());
138:                t.setUnwrapped(true);
139:                Parameter parameter = createParameter(elementName
140:                        .getLocalPart(), t, block);
141:                parameter.setEmbedded(true);
142:                return parameter;
143:            }
144:
145:            public static List<Parameter> createRpcLitParameters(
146:                    Message message, Block block, S2JJAXBModel jaxbModel,
147:                    ErrorReceiverFilter errReceiver) {
148:                RpcLitStructure rpcStruct = (RpcLitStructure) block.getType();
149:
150:                List<Parameter> parameters = new ArrayList<Parameter>();
151:                for (MessagePart part : message.getParts()) {
152:                    if (!ModelerUtils.isBoundToSOAPBody(part))
153:                        continue;
154:                    QName name = part.getDescriptor();
155:                    TypeAndAnnotation typeAndAnn = jaxbModel.getJavaType(name);
156:                    if (typeAndAnn == null) {
157:                        String msgQName = "{"
158:                                + message.getDefining().getTargetNamespaceURI()
159:                                + "}" + message.getName();
160:                        errReceiver.error(part.getLocator(), ModelerMessages
161:                                .WSDLMODELER_RPCLIT_UNKOWNSCHEMATYPE(name
162:                                        .toString(), part.getName(), msgQName));
163:                        throw new AbortException();
164:                    }
165:                    String type = typeAndAnn.getTypeClass().fullName();
166:                    type = ClassNameInfo.getGenericClass(type);
167:                    RpcLitMember param = new RpcLitMember(new QName("", part
168:                            .getName()), type);
169:                    JavaType javaType = new JavaSimpleType(
170:                            new JAXBTypeAndAnnotation(typeAndAnn));
171:                    param.setJavaType(javaType);
172:                    rpcStruct.addRpcLitMember(param);
173:                    Parameter parameter = ModelerUtils.createParameter(part
174:                            .getName(), param, block);
175:                    parameter.setEmbedded(true);
176:                    parameters.add(parameter);
177:                }
178:                return parameters;
179:            }
180:
181:            /**
182:             * Called for non-wrapper style operations. It returns a Parameter constructed
183:             * using the JAXBType and the Block.
184:             *
185:             * @param partName typically wsdl:part or any name to be given to the parameter
186:             * @param jaxbType type of Parameter
187:             * @param block Block to which the parameter belongs to
188:             * @return Parameter created.
189:             */
190:            public static Parameter createParameter(String partName,
191:                    AbstractType jaxbType, Block block) {
192:                Parameter parameter = new Parameter(partName, block.getEntity());
193:                parameter.setProperty(
194:                        ModelProperties.PROPERTY_PARAM_MESSAGE_PART_NAME,
195:                        partName);
196:                parameter.setEmbedded(false);
197:                parameter.setType(jaxbType);
198:                parameter.setTypeName(jaxbType.getJavaType().getType()
199:                        .getName());
200:                parameter.setBlock(block);
201:                return parameter;
202:            }
203:
204:            /**
205:             * Get Parameter from the list of parameters.
206:             *
207:             * @param paramName
208:             * @param parameters
209:             * @return the Parameter with name paramName from parameters
210:             */
211:            public static Parameter getParameter(String paramName,
212:                    List<Parameter> parameters) {
213:                if (parameters == null)
214:                    return null;
215:                for (Parameter param : parameters) {
216:                    //if(param.getName().equals("_return") && paramName.equals("return") || param.getName().equals(paramName)) {
217:                    if (param.getName().equals(paramName)) {
218:                        return param;
219:                    }
220:                }
221:                return null;
222:            }
223:
224:            /**
225:             * Compares two JAXBStructures.
226:             *
227:             * @param struct1
228:             * @param struct2
229:             * @return true if struct1 and struct2 are equivalent.
230:             */
231:            public static boolean isEquivalentLiteralStructures(
232:                    JAXBStructuredType struct1, JAXBStructuredType struct2) {
233:                if (struct1.getElementMembersCount() != struct2
234:                        .getElementMembersCount())
235:                    return false;
236:                Iterator members = struct1.getElementMembers();
237:                JAXBElementMember member1;
238:                JavaStructureMember javaMember1, javaMember2;
239:                for (int i = 0; members.hasNext(); i++) {
240:                    member1 = (JAXBElementMember) members.next();
241:                    javaMember1 = member1.getJavaStructureMember();
242:                    javaMember2 = ((JavaStructureType) struct2.getJavaType())
243:                            .getMemberByName(member1.getJavaStructureMember()
244:                                    .getName());
245:                    if (javaMember2.getConstructorPos() != i
246:                            || !javaMember1.getType().equals(
247:                                    javaMember2.getType())) {
248:                        return false;
249:                    }
250:                }
251:                return false;
252:            }
253:
254:            /**
255:             * @param part
256:             * @return true if part is bound to Mime content
257:             */
258:            public static boolean isBoundToMimeContent(MessagePart part) {
259:                if ((part != null)
260:                        && part.getBindingExtensibilityElementKind() == MessagePart.WSDL_MIME_BINDING)
261:                    return true;
262:                return false;
263:            }
264:
265:            /**
266:             * @param part
267:             * @return true if part is bound to SOAPBody
268:             */
269:            public static boolean isBoundToSOAPBody(MessagePart part) {
270:                if ((part != null)
271:                        && part.getBindingExtensibilityElementKind() == MessagePart.SOAP_BODY_BINDING)
272:                    return true;
273:                return false;
274:            }
275:
276:            /**
277:             * @param part
278:             * @return true if part is bound to SOAPHeader
279:             */
280:            public static boolean isBoundToSOAPHeader(MessagePart part) {
281:                if ((part != null)
282:                        && part.getBindingExtensibilityElementKind() == MessagePart.SOAP_HEADER_BINDING)
283:                    return true;
284:                return false;
285:            }
286:
287:            public static boolean isUnbound(MessagePart part) {
288:                if ((part != null)
289:                        && part.getBindingExtensibilityElementKind() == MessagePart.PART_NOT_BOUNDED)
290:                    return true;
291:                return false;
292:            }
293:        }
ww___w___.j_a_v_a___2_s.__co___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.