Source Code Cross Referenced for GeneratorFactory.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ws » wsgen » generator » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2003-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: GeneratorFactory.java 7609 2005-10-25 14:22:08Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas_ws.wsgen.generator;
025:
026:        import java.io.IOException;
027:        import java.io.InputStream;
028:        import java.util.Properties;
029:
030:        import org.objectweb.jonas_lib.I18n;
031:        import org.objectweb.jonas_lib.genbase.GenBaseException;
032:        import org.objectweb.jonas_lib.genbase.archive.Archive;
033:        import org.objectweb.jonas_lib.genbase.generator.Config;
034:
035:        import org.objectweb.jonas_ws.deployment.api.ServiceDesc;
036:        import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc;
037:        import org.objectweb.jonas_ws.wsgen.WsGenException;
038:        import org.objectweb.jonas_ws.wsgen.ddmodifier.WebServicesDDModifier;
039:        import org.objectweb.jonas_ws.wsgen.ddmodifier.WsClientDDModifier;
040:        import org.objectweb.jonas_ws.wsgen.ddmodifier.WsEndpointDDModifier;
041:
042:        import org.objectweb.jonas.common.Log;
043:
044:        import org.objectweb.util.monolog.api.BasicLevel;
045:        import org.objectweb.util.monolog.api.Logger;
046:
047:        /**
048:         * a <code>GeneratorFactory</code> has to be extended by specific generation
049:         * mecanism. It will look in <code>jonas.properties</code> file for a property
050:         * named :<code>jonas.service.ws.wsgen.generator.factory</code> that is a
051:         * classname extending <code>GeneratorFactory</code>. By default Axis
052:         * GeneratorFactory is used.
053:         *
054:         * @author Guillaume Sauthier
055:         */
056:        public abstract class GeneratorFactory implements 
057:                org.objectweb.jonas_lib.genbase.generator.GeneratorFactory {
058:
059:            /**
060:             * Generator Factory property name in jonas.properties
061:             */
062:            public static final String GENERATOR_FACTORY = "jonas.service.ws.wsgen.generator.factory";
063:
064:            /**
065:             * Default GeneratorFactory impl to use
066:             */
067:            public static final String GENERATOR_FACTORY_DEFAULT = "org.objectweb.jonas_ws.wsgen.generator.ews.EWSGeneratorFactory";
068:
069:            /** <code>GeneratorFactory</code> unique instance */
070:            private static GeneratorFactory instance = null;
071:
072:            /** i18n */
073:            private static I18n i18n = I18n.getInstance(GeneratorFactory.class);
074:
075:            /** logger */
076:            private static Logger logger = Log
077:                    .getLogger(Log.JONAS_WSGEN_PREFIX);
078:
079:            /** Configuration to set on instanciated Generator */
080:            private Config configuration;
081:
082:            /**
083:             * Returns the unique GeneratorFactory instance.
084:             *
085:             * @return the unique GeneratorFactory instance.
086:             *
087:             * @throws WsGenException When instanciation fails
088:             */
089:            public static GeneratorFactory getInstance() throws WsGenException {
090:                if (instance == null) {
091:                    instance = newInstance();
092:                }
093:
094:                return instance;
095:            }
096:
097:            /**
098:             * Create a new generatorFactory instance by looking up in
099:             * <code>jonas.properties</code> and load class specified with
100:             * <code>jonas.service.ws.wsgen.generator-factory</code> property. If not
101:             * set, Axis GeneratorFactory is the default Factory returned.
102:             *
103:             * @return a new generatorFactory instance.
104:             *
105:             * @throws WsGenException when Exception occurs when dynamiccaly
106:             *         instantiating GeneratorFactory subclass
107:             */
108:            private static GeneratorFactory newInstance() throws WsGenException {
109:
110:                String classname = null;
111:
112:                ClassLoader cl = Thread.currentThread().getContextClassLoader();
113:                InputStream is = cl.getResourceAsStream("jonas.properties");
114:
115:                if (is == null) {
116:                    // Should be on the client side
117:                    // use default value
118:                    classname = GENERATOR_FACTORY_DEFAULT;
119:                } else {
120:                    Properties jprop = new Properties();
121:                    try {
122:                        jprop.load(is);
123:                        classname = jprop.getProperty(GENERATOR_FACTORY,
124:                                GENERATOR_FACTORY_DEFAULT);
125:                    } catch (IOException e) {
126:                        // cannot read properties, use default value
127:                        logger.log(BasicLevel.WARN, "Cannot get '"
128:                                + GENERATOR_FACTORY
129:                                + "' value, default used : '"
130:                                + GENERATOR_FACTORY_DEFAULT + "'");
131:                        classname = GENERATOR_FACTORY_DEFAULT;
132:                    } finally {
133:                        try {
134:                            is.close();
135:                        } catch (IOException e) {
136:                            // use default if it was not set
137:                            if (classname == null) {
138:                                classname = GENERATOR_FACTORY_DEFAULT;
139:                            }
140:                        }
141:                    }
142:                }
143:
144:                // instanciate
145:                GeneratorFactory gf = null;
146:
147:                try {
148:                    Class gfc = cl.loadClass(classname);
149:                    gf = (GeneratorFactory) gfc.newInstance();
150:                } catch (Exception e) {
151:                    String err = i18n.getMessage(
152:                            "GeneratorFactory.newInstance.instance", classname);
153:                    throw new WsGenException(err, e);
154:                }
155:
156:                return gf;
157:
158:            }
159:
160:            /**
161:             * Return a new WsClientGenerator for the specific generation mecanism.
162:             *
163:             * @param serviceRef the service-ref containing information for client side
164:             *        generation process.
165:             * @param ddm the XML modifier.
166:             * @param archive the Archive to be modified
167:             *
168:             * @return a new WsClientGenerator.
169:             *
170:             * @throws GenBaseException When Factory cannot instanciate WsClientGenerator
171:             */
172:            public abstract WsClientGenerator newGenerator(
173:                    ServiceRefDesc serviceRef, WsClientDDModifier ddm,
174:                    Archive archive) throws GenBaseException;
175:
176:            /**
177:             * Return a new WsEndpointGenerator for the specific generation mecanism.
178:             *
179:             * @param serviceDesc the webservice-description containing information for
180:             *        server side generation process.
181:             * @param ddm the XML modifier.
182:             * @param wsddm the Webservices.xml DD modifier
183:             * @param arch The archive to modify
184:             *
185:             * @return a new WsEndpointGenerator.
186:             *
187:             * @throws GenBaseException When Factory cannot instanciate WsEndpointGenerator
188:             */
189:            public abstract WsEndpointGenerator newGenerator(
190:                    ServiceDesc serviceDesc, WsEndpointDDModifier ddm,
191:                    WebServicesDDModifier wsddm, Archive arch)
192:                    throws GenBaseException;
193:
194:            /**
195:             * Set the Configuration to use with newly created Generator.
196:             *
197:             * @param config the Configuration to use with newly created Generator.
198:             */
199:            public void setConfiguration(Config config) {
200:                this .configuration = config;
201:            }
202:
203:            /**
204:             * Get the Configuration to use with newly created Generator.
205:             *
206:             * @return the Configuration to use with newly created Generator
207:             */
208:            public Config getConfiguration() {
209:                return configuration;
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.