Source Code Cross Referenced for ClassNameCollector.java in  » 6.0-JDK-Modules » jax-ws-tools » com » sun » tools » ws » processor » util » 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.util 
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:
037:        package com.sun.tools.ws.processor.util;
038:
039:        import com.sun.tools.ws.processor.model.*;
040:        import com.sun.tools.ws.processor.model.java.JavaInterface;
041:        import com.sun.tools.ws.processor.model.jaxb.JAXBType;
042:        import com.sun.tools.ws.processor.model.jaxb.JAXBTypeVisitor;
043:        import com.sun.tools.ws.processor.model.jaxb.RpcLitStructure;
044:
045:        import javax.xml.namespace.QName;
046:        import java.util.HashSet;
047:        import java.util.Iterator;
048:        import java.util.Set;
049:
050:        /**
051:         * This class writes out a Model as an XML document.
052:         *
053:         * @author WS Development Team
054:         */
055:        public class ClassNameCollector extends ExtendedModelVisitor implements 
056:                JAXBTypeVisitor {
057:
058:            public ClassNameCollector() {
059:            }
060:
061:            public void process(Model model) {
062:                try {
063:                    _allClassNames = new HashSet();
064:                    _exceptions = new HashSet();
065:                    _wsdlBindingNames = new HashSet();
066:                    _conflictingClassNames = new HashSet();
067:                    _seiClassNames = new HashSet<String>();
068:                    _jaxbGeneratedClassNames = new HashSet<String>();
069:                    _exceptionClassNames = new HashSet<String>();
070:                    _portTypeNames = new HashSet<QName>();
071:                    visit(model);
072:                } catch (Exception e) {
073:                    e.printStackTrace();
074:                    // fail silently
075:                } finally {
076:                    _allClassNames = null;
077:                    _exceptions = null;
078:                }
079:            }
080:
081:            public Set getConflictingClassNames() {
082:                return _conflictingClassNames;
083:            }
084:
085:            protected void postVisit(Model model) throws Exception {
086:                for (Iterator iter = model.getExtraTypes(); iter.hasNext();) {
087:                    visitType((AbstractType) iter.next());
088:                }
089:            }
090:
091:            protected void preVisit(Service service) throws Exception {
092:                registerClassName(((JavaInterface) service.getJavaInterface())
093:                        .getName());
094:                registerClassName(((JavaInterface) service.getJavaInterface())
095:                        .getImpl());
096:            }
097:
098:            protected void processPort11x(Port port) {
099:                QName wsdlBindingName = (QName) port
100:                        .getProperty(ModelProperties.PROPERTY_WSDL_BINDING_NAME);
101:                if (!_wsdlBindingNames.contains(wsdlBindingName)) {
102:
103:                    // multiple ports can share a binding without causing a conflict
104:                    registerClassName(port.getJavaInterface().getName());
105:                }
106:                registerClassName((String) port
107:                        .getProperty(ModelProperties.PROPERTY_STUB_CLASS_NAME));
108:                registerClassName((String) port
109:                        .getProperty(ModelProperties.PROPERTY_TIE_CLASS_NAME));
110:            }
111:
112:            protected void preVisit(Port port) throws Exception {
113:                QName portTypeName = (QName) port
114:                        .getProperty(ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME);
115:                if (_portTypeNames.contains(portTypeName))
116:                    return;
117:
118:                //in 2.0, stub/tie class are binding agnostic so they should be per port, that is multiple
119:                // bindings can share the same port
120:
121:                addSEIClassName(port.getJavaInterface().getName());
122:            }
123:
124:            private void addSEIClassName(String s) {
125:                _seiClassNames.add(s);
126:                registerClassName(s);
127:            }
128:
129:            protected void postVisit(Port port) throws Exception {
130:                QName wsdlBindingName = (QName) port
131:                        .getProperty(ModelProperties.PROPERTY_WSDL_BINDING_NAME);
132:                if (!_wsdlBindingNames.contains(wsdlBindingName)) {
133:                    _wsdlBindingNames.add(wsdlBindingName);
134:                }
135:
136:                QName portTypeName = (QName) port
137:                        .getProperty(ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME);
138:                if (!_portTypeNames.contains(portTypeName)) {
139:                    _portTypeNames.add(portTypeName);
140:                }
141:            }
142:
143:            protected boolean shouldVisit(Port port) {
144:                QName wsdlBindingName = (QName) port
145:                        .getProperty(ModelProperties.PROPERTY_WSDL_BINDING_NAME);
146:                return !_wsdlBindingNames.contains(wsdlBindingName);
147:            }
148:
149:            protected void preVisit(Fault fault) throws Exception {
150:                if (!_exceptions.contains(fault.getJavaException())) {
151:
152:                    /* the same exception can be used in several faults, but that
153:                     * doesn't mean that there is a conflict
154:                     */
155:                    _exceptions.add(fault.getJavaException());
156:                    addExceptionClassName(fault.getJavaException().getName());
157:
158:                    if (fault.getParentFault() != null) {
159:                        preVisit(fault.getParentFault());
160:                    }
161:                    for (Iterator iter = fault.getSubfaults(); iter != null
162:                            && iter.hasNext();) {
163:
164:                        Fault subfault = (Fault) iter.next();
165:                        preVisit(subfault);
166:                    }
167:                }
168:            }
169:
170:            private void addExceptionClassName(String name) {
171:                if (_allClassNames.contains(name))
172:                    _exceptionClassNames.add(name);
173:                registerClassName(name);
174:                //To change body of created methods use File | Settings | File Templates.
175:            }
176:
177:            protected void visitBodyBlock(Block block) throws Exception {
178:                visitBlock(block);
179:            }
180:
181:            protected void visitHeaderBlock(Block block) throws Exception {
182:                visitBlock(block);
183:            }
184:
185:            protected void visitFaultBlock(Block block) throws Exception {
186:            }
187:
188:            protected void visitBlock(Block block) throws Exception {
189:                visitType(block.getType());
190:            }
191:
192:            protected void visit(Parameter parameter) throws Exception {
193:                visitType(parameter.getType());
194:            }
195:
196:            private void visitType(AbstractType type) throws Exception {
197:                if (type != null) {
198:                    if (type instanceof  JAXBType)
199:                        visitType((JAXBType) type);
200:                    else if (type instanceof  RpcLitStructure)
201:                        visitType((RpcLitStructure) type);
202:                }
203:            }
204:
205:            private void visitType(JAXBType type) throws Exception {
206:                type.accept(this );
207:            }
208:
209:            private void visitType(RpcLitStructure type) throws Exception {
210:                type.accept(this );
211:            }
212:
213:            private void registerClassName(String name) {
214:                if (name == null || name.equals("")) {
215:                    return;
216:                }
217:                if (_allClassNames.contains(name)) {
218:                    _conflictingClassNames.add(name);
219:                } else {
220:                    _allClassNames.add(name);
221:                }
222:            }
223:
224:            public Set<String> getSeiClassNames() {
225:                return _seiClassNames;
226:            }
227:
228:            private Set<String> _seiClassNames;
229:
230:            public Set<String> getJaxbGeneratedClassNames() {
231:                return _jaxbGeneratedClassNames;
232:            }
233:
234:            private Set<String> _jaxbGeneratedClassNames;
235:
236:            public Set<String> getExceptionClassNames() {
237:                return _exceptionClassNames;
238:            }
239:
240:            private Set<String> _exceptionClassNames;
241:            boolean doneVisitingJAXBModel = false;
242:
243:            public void visit(JAXBType type) throws Exception {
244:                if (!doneVisitingJAXBModel && type.getJaxbModel() != null) {
245:                    Set<String> classNames = type.getJaxbModel()
246:                            .getGeneratedClassNames();
247:                    for (String className : classNames) {
248:                        addJAXBGeneratedClassName(className);
249:                    }
250:                    doneVisitingJAXBModel = true;
251:                }
252:            }
253:
254:            public void visit(RpcLitStructure type) throws Exception {
255:                if (!doneVisitingJAXBModel) {
256:                    Set<String> classNames = type.getJaxbModel()
257:                            .getGeneratedClassNames();
258:                    for (String className : classNames) {
259:                        addJAXBGeneratedClassName(className);
260:                    }
261:                    doneVisitingJAXBModel = true;
262:                }
263:            }
264:
265:            private void addJAXBGeneratedClassName(String name) {
266:                _jaxbGeneratedClassNames.add(name);
267:                registerClassName(name);
268:            }
269:
270:            private Set _allClassNames;
271:            private Set _exceptions;
272:            private Set _wsdlBindingNames;
273:            private Set _conflictingClassNames;
274:            private Set<QName> _portTypeNames;
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.