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.util;
027:
028: import java.util.Properties;
029:
030: import com.sun.tools.internal.ws.processor.config.WSDLModelInfo;
031: import com.sun.tools.internal.ws.processor.generator.Names;
032: import com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler;
033: import com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModelerBase;
034: import com.sun.tools.internal.ws.wsdl.framework.AbstractDocument;
035: import com.sun.xml.internal.ws.util.VersionUtil;
036:
037: /**
038: * Singleton factory class to instantiate concrete classes based on the jaxws version
039: * to be used to generate the code.
040: *
041: * @author WS Development Team
042: */
043: public class JAXWSClassFactory {
044: private static final JAXWSClassFactory factory = new JAXWSClassFactory();
045:
046: private static String classVersion = VersionUtil.JAXWS_VERSION_DEFAULT;
047:
048: private JAXWSClassFactory() {
049: }
050:
051: /**
052: * Get the factory instance for the default version.
053: * @return JAXWSClassFactory instance
054: */
055: public static JAXWSClassFactory newInstance() {
056: return factory;
057: }
058:
059: /**
060: * Sets the version to a static classVersion
061: * @param version
062: */
063: public void setSourceVersion(String version) {
064: if (version == null)
065: version = VersionUtil.JAXWS_VERSION_DEFAULT;
066:
067: if (!VersionUtil.isValidVersion(version)) {
068: // TODO: throw exception
069: } else
070: classVersion = version;
071: }
072:
073: /**
074: * Returns the WSDLModeler for specific target version.
075: *
076: * @param modelInfo
077: * @param options
078: * @return the WSDLModeler for specific target version.
079: */
080: public WSDLModelerBase createWSDLModeler(WSDLModelInfo modelInfo,
081: Properties options) {
082: WSDLModelerBase wsdlModeler = null;
083: if (classVersion.equals(VersionUtil.JAXWS_VERSION_20))
084: wsdlModeler = new WSDLModeler(modelInfo, options);
085: else {
086: // TODO: throw exception
087: }
088: return wsdlModeler;
089: }
090:
091: /**
092: * Returns the Names for specific target version.
093: * //bug fix:4904604
094: * @return instance of Names
095: */
096: public Names createNames() {
097: Names names = new Names();
098: return names;
099: }
100:
101: public String getVersion() {
102: return classVersion;
103: }
104: }
|