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


001:        /*
002:         * Portions Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.tools.internal.ws.processor.util;
027:
028:        import java.util.HashSet;
029:        import java.util.Iterator;
030:        import java.util.Set;
031:
032:        import javax.xml.namespace.QName;
033:
034:        import com.sun.tools.internal.ws.processor.model.AbstractType;
035:        import com.sun.tools.internal.ws.processor.model.Block;
036:        import com.sun.tools.internal.ws.processor.model.ExtendedModelVisitor;
037:        import com.sun.tools.internal.ws.processor.model.Fault;
038:        import com.sun.tools.internal.ws.processor.model.Model;
039:        import com.sun.tools.internal.ws.processor.model.ModelProperties;
040:        import com.sun.tools.internal.ws.processor.model.Parameter;
041:        import com.sun.tools.internal.ws.processor.model.Port;
042:        import com.sun.tools.internal.ws.processor.model.Service;
043:        import com.sun.tools.internal.ws.processor.model.jaxb.JAXBType;
044:        import com.sun.tools.internal.ws.processor.model.jaxb.JAXBTypeVisitor;
045:        import com.sun.tools.internal.ws.processor.model.jaxb.RpcLitStructure;
046:        import com.sun.tools.internal.ws.processor.model.java.JavaInterface;
047:        import com.sun.xml.internal.ws.util.VersionUtil;
048:
049:        /**
050:         * This class writes out a Model as an XML document.
051:         *
052:         * @author WS Development Team
053:         */
054:        public class ClassNameCollector extends ExtendedModelVisitor implements 
055:                JAXBTypeVisitor {
056:
057:            public ClassNameCollector() {
058:            }
059:
060:            public void process(Model model) {
061:                try {
062:                    _allClassNames = new HashSet();
063:                    _exceptions = new HashSet();
064:                    _wsdlBindingNames = new HashSet();
065:                    _conflictingClassNames = new HashSet();
066:                    _seiClassNames = new HashSet<String>();
067:                    _jaxbGeneratedClassNames = new HashSet<String>();
068:                    _exceptionClassNames = new HashSet<String>();
069:                    _portTypeNames = new HashSet<QName>();
070:                    visit(model);
071:                } catch (Exception e) {
072:                    e.printStackTrace();
073:                    // fail silently
074:                } finally {
075:                    _allClassNames = null;
076:                    _exceptions = null;
077:                }
078:            }
079:
080:            public Set getConflictingClassNames() {
081:                return _conflictingClassNames;
082:            }
083:
084:            protected void postVisit(Model model) throws Exception {
085:                for (Iterator iter = model.getExtraTypes(); iter.hasNext();) {
086:                    visitType((AbstractType) iter.next());
087:                }
088:            }
089:
090:            protected void preVisit(Service service) throws Exception {
091:                registerClassName(((JavaInterface) service.getJavaInterface())
092:                        .getName());
093:                registerClassName(((JavaInterface) service.getJavaInterface())
094:                        .getImpl());
095:            }
096:
097:            protected void processPort11x(Port port) {
098:                QName wsdlBindingName = (QName) port
099:                        .getProperty(ModelProperties.PROPERTY_WSDL_BINDING_NAME);
100:                if (!_wsdlBindingNames.contains(wsdlBindingName)) {
101:
102:                    // multiple ports can share a binding without causing a conflict
103:                    registerClassName(port.getJavaInterface().getName());
104:                }
105:                registerClassName((String) port
106:                        .getProperty(ModelProperties.PROPERTY_STUB_CLASS_NAME));
107:                registerClassName((String) port
108:                        .getProperty(ModelProperties.PROPERTY_TIE_CLASS_NAME));
109:            }
110:
111:            protected void preVisit(Port port) throws Exception {
112:                QName portTypeName = (QName) port
113:                        .getProperty(ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME);
114:                if (_portTypeNames.contains(portTypeName))
115:                    return;
116:
117:                //in 2.0, stub/tie class are binding agnostic so they should be per port, that is multiple
118:                // bindings can share the same port
119:
120:                addSEIClassName(port.getJavaInterface().getName());
121:            }
122:
123:            private void addSEIClassName(String s) {
124:                _seiClassNames.add(s);
125:                registerClassName(s);
126:            }
127:
128:            protected void postVisit(Port port) throws Exception {
129:                QName wsdlBindingName = (QName) port
130:                        .getProperty(ModelProperties.PROPERTY_WSDL_BINDING_NAME);
131:                if (!_wsdlBindingNames.contains(wsdlBindingName)) {
132:                    _wsdlBindingNames.add(wsdlBindingName);
133:                }
134:
135:                QName portTypeName = (QName) port
136:                        .getProperty(ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME);
137:                if (!_portTypeNames.contains(portTypeName)) {
138:                    _portTypeNames.add(portTypeName);
139:                }
140:            }
141:
142:            protected boolean shouldVisit(Port port) {
143:                QName wsdlBindingName = (QName) port
144:                        .getProperty(ModelProperties.PROPERTY_WSDL_BINDING_NAME);
145:                return !_wsdlBindingNames.contains(wsdlBindingName);
146:            }
147:
148:            protected void preVisit(Fault fault) throws Exception {
149:                if (!_exceptions.contains(fault.getJavaException())) {
150:
151:                    /* the same exception can be used in several faults, but that
152:                     * doesn't mean that there is a conflict
153:                     */
154:                    _exceptions.add(fault.getJavaException());
155:                    addExceptionClassName(fault.getJavaException().getName());
156:
157:                    if (fault.getParentFault() != null) {
158:                        preVisit(fault.getParentFault());
159:                    }
160:                    for (Iterator iter = fault.getSubfaults(); iter != null
161:                            && iter.hasNext();) {
162:
163:                        Fault subfault = (Fault) iter.next();
164:                        preVisit(subfault);
165:                    }
166:                }
167:            }
168:
169:            private void addExceptionClassName(String name) {
170:                if (_allClassNames.contains(name))
171:                    _exceptionClassNames.add(name);
172:                registerClassName(name);
173:                //To change body of created methods use File | Settings | File Templates.
174:            }
175:
176:            protected void visitBodyBlock(Block block) throws Exception {
177:                visitBlock(block);
178:            }
179:
180:            protected void visitHeaderBlock(Block block) throws Exception {
181:                visitBlock(block);
182:            }
183:
184:            protected void visitFaultBlock(Block block) throws Exception {
185:            }
186:
187:            protected void visitBlock(Block block) throws Exception {
188:                visitType(block.getType());
189:            }
190:
191:            protected void visit(Parameter parameter) throws Exception {
192:                visitType(parameter.getType());
193:            }
194:
195:            private void visitType(AbstractType type) throws Exception {
196:                if (type != null) {
197:                    if (type instanceof  JAXBType)
198:                        visitType((JAXBType) type);
199:                    else if (type instanceof  RpcLitStructure)
200:                        visitType((RpcLitStructure) type);
201:                }
202:            }
203:
204:            private void visitType(JAXBType type) throws Exception {
205:                type.accept(this );
206:            }
207:
208:            private void visitType(RpcLitStructure type) throws Exception {
209:                type.accept(this );
210:            }
211:
212:            private void registerClassName(String name) {
213:                if (name == null || name.equals("")) {
214:                    return;
215:                }
216:                if (_allClassNames.contains(name)) {
217:                    _conflictingClassNames.add(name);
218:                } else {
219:                    _allClassNames.add(name);
220:                }
221:            }
222:
223:            public Set<String> getSeiClassNames() {
224:                return _seiClassNames;
225:            }
226:
227:            private Set<String> _seiClassNames;
228:
229:            public Set<String> getJaxbGeneratedClassNames() {
230:                return _jaxbGeneratedClassNames;
231:            }
232:
233:            private Set<String> _jaxbGeneratedClassNames;
234:
235:            public Set<String> getExceptionClassNames() {
236:                return _exceptionClassNames;
237:            }
238:
239:            private Set<String> _exceptionClassNames;
240:            boolean doneVisitingJAXBModel = false;
241:
242:            public void visit(JAXBType type) throws Exception {
243:                if (!doneVisitingJAXBModel) {
244:                    Set<String> classNames = type.getJaxbModel()
245:                            .getGeneratedClassNames();
246:                    for (String className : classNames) {
247:                        addJAXBGeneratedClassName(className);
248:                    }
249:                    doneVisitingJAXBModel = true;
250:                }
251:            }
252:
253:            public void visit(RpcLitStructure type) throws Exception {
254:                if (!doneVisitingJAXBModel) {
255:                    Set<String> classNames = type.getJaxbModel()
256:                            .getGeneratedClassNames();
257:                    for (String className : classNames) {
258:                        addJAXBGeneratedClassName(className);
259:                    }
260:                    doneVisitingJAXBModel = true;
261:                }
262:            }
263:
264:            private void addJAXBGeneratedClassName(String name) {
265:                _jaxbGeneratedClassNames.add(name);
266:                registerClassName(name);
267:            }
268:
269:            private Set _allClassNames;
270:            private Set _exceptions;
271:            private Set _wsdlBindingNames;
272:            private Set _conflictingClassNames;
273:            private Set<QName> _portTypeNames;
274:        }
ww__w__.___j__ava_2s___.__c_o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.