Source Code Cross Referenced for XMLBeansExtension.java in  » Web-Services-AXIS2 » codegen-wsdl2java » org » apache » axis2 » wsdl » codegen » extension » 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 » Web Services AXIS2 » codegen wsdl2java » org.apache.axis2.wsdl.codegen.extension 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:
020:        package org.apache.axis2.wsdl.codegen.extension;
021:
022:        import org.apache.axis2.description.AxisService;
023:        import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
024:        import org.apache.axis2.wsdl.databinding.TypeMapper;
025:        import org.apache.axis2.wsdl.i18n.CodegenMessages;
026:        import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
027:        import org.w3c.dom.Document;
028:        import org.w3c.dom.Element;
029:
030:        import javax.xml.parsers.DocumentBuilder;
031:        import javax.xml.parsers.DocumentBuilderFactory;
032:        import javax.xml.parsers.ParserConfigurationException;
033:        import java.io.InputStream;
034:        import java.lang.reflect.Method;
035:        import java.util.ArrayList;
036:        import java.util.Iterator;
037:        import java.util.List;
038:
039:        public class XMLBeansExtension extends AbstractDBProcessingExtension {
040:            /** Name of "extra" option used to supply package name for xsb files. */
041:            public static final String TYPESYSTEMNAME_OPTION = "typesystemname";
042:            public static final String SCHEMA_FOLDER = "schemas";
043:            public static final String XSDCONFIG_OPTION = "xc";
044:            public static final String XSDCONFIG_OPTION_LONG = "xsdconfig";
045:
046:            public static String MAPPINGS = "mappings";
047:            public static String MAPPING = "mapping";
048:            public static String MESSAGE = "message";
049:            public static String JAVA_NAME = "javaclass";
050:
051:            public static final String MAPPING_FOLDER = "Mapping";
052:            public static final String MAPPER_FILE_NAME = "mapper";
053:            public static final String SCHEMA_PATH = "/org/apache/axis2/wsdl/codegen/schema/";
054:
055:            public static final String XMLBEANS_CONFIG_CLASS = "org.apache.xmlbeans.BindingConfig";
056:            public static final String XMLBEANS_UTILITY_CLASS = "org.apache.axis2.xmlbeans.CodeGenerationUtility";
057:            public static final String XMLBEANS_PROCESS_METHOD = "processSchemas";
058:
059:            boolean debug = false;
060:
061:            public void engage(CodeGenConfiguration configuration) {
062:
063:                //test the databinding type. If not just fall through
064:                if (testFallThrough(configuration.getDatabindingType())) {
065:                    return;
066:                }
067:
068:                // check the JiBX binding definition file specified
069:                String typeSystemName = (String) configuration.getProperties()
070:                        .get(TYPESYSTEMNAME_OPTION);
071:
072:                try {
073:                    // try dummy load of framework class first to check missing jars
074:                    try {
075:                        getClass().getClassLoader().loadClass(
076:                                XMLBEANS_CONFIG_CLASS);
077:                    } catch (ClassNotFoundException e) {
078:                        throw new RuntimeException(
079:                                "XMLBeans framework jars not in classpath");
080:                    }
081:
082:                    // load the actual utility class
083:                    Class clazz = null;
084:                    try {
085:                        clazz = getClass().getClassLoader().loadClass(
086:                                XMLBEANS_UTILITY_CLASS);
087:                    } catch (ClassNotFoundException e) {
088:                        throw new RuntimeException(
089:                                "XMLBeans binding extension not in classpath");
090:                    }
091:
092:                    // invoke utility class method for actual processing
093:                    Method method = clazz.getMethod(XMLBEANS_PROCESS_METHOD,
094:                            new Class[] { List.class, Element[].class,
095:                                    CodeGenConfiguration.class, String.class });
096:                    List schemas = new ArrayList();
097:                    List axisServices = configuration.getAxisServices();
098:                    AxisService axisService = null;
099:                    for (Iterator iter = axisServices.iterator(); iter
100:                            .hasNext();) {
101:                        axisService = (AxisService) iter.next();
102:                        schemas.addAll(axisService.getSchema());
103:                    }
104:
105:                    Element[] additionalSchemas = loadAdditionalSchemas();
106:                    TypeMapper mapper = (TypeMapper) method.invoke(null,
107:                            new Object[] { schemas, additionalSchemas,
108:                                    configuration, typeSystemName });
109:
110:                    // set the type mapper to the config
111:                    configuration.setTypeMapper(mapper);
112:
113:                } catch (Exception e) {
114:                    if (e instanceof  RuntimeException) {
115:                        throw (RuntimeException) e;
116:                    } else {
117:                        throw new RuntimeException(e);
118:                    }
119:                }
120:            }
121:
122:            /**
123:             * Loading the external schemas.
124:             *
125:             * @return element array consisting of the the DOM element objects that represent schemas
126:             */
127:            private Element[] loadAdditionalSchemas() {
128:                //load additional schemas
129:                String[] schemaNames = ConfigPropertyFileLoader
130:                        .getThirdPartySchemaNames();
131:                Element[] schemaElements;
132:
133:                try {
134:                    ArrayList additionalSchemaElements = new ArrayList();
135:                    DocumentBuilder documentBuilder = getNamespaceAwareDocumentBuilder();
136:                    for (int i = 0; i < schemaNames.length; i++) {
137:                        //the location for the third party schema;s is hardcoded
138:                        if (!"".equals(schemaNames[i].trim())) {
139:                            InputStream schemaStream = this .getClass()
140:                                    .getResourceAsStream(
141:                                            SCHEMA_PATH + schemaNames[i]);
142:                            Document doc = documentBuilder.parse(schemaStream);
143:                            additionalSchemaElements.add(doc
144:                                    .getDocumentElement());
145:                        }
146:                    }
147:
148:                    //Create the Schema element array
149:                    schemaElements = new Element[additionalSchemaElements
150:                            .size()];
151:                    for (int i = 0; i < additionalSchemaElements.size(); i++) {
152:                        schemaElements[i] = (Element) additionalSchemaElements
153:                                .get(i);
154:
155:                    }
156:                } catch (Exception e) {
157:                    throw new RuntimeException(CodegenMessages
158:                            .getMessage("extension.additionalSchemaFailure"), e);
159:                }
160:
161:                return schemaElements;
162:            }
163:
164:            private DocumentBuilder getNamespaceAwareDocumentBuilder()
165:                    throws ParserConfigurationException {
166:                DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
167:                        .newInstance();
168:                documentBuilderFactory.setNamespaceAware(true);
169:                return documentBuilderFactory.newDocumentBuilder();
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.