| /* |
| * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. |
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| * |
| * This code is free software; you can redistribute it and/or modify it |
| * under the terms of the GNU General Public License version 2 only, as |
| * published by the Free Software Foundation. Sun designates this |
| * particular file as subject to the "Classpath" exception as provided |
| * by Sun in the LICENSE file that accompanied this code. |
| * |
| * This code is distributed in the hope that it will be useful, but WITHOUT |
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| * version 2 for more details (a copy is included in the LICENSE file that |
| * accompanied this code). |
| * |
| * You should have received a copy of the GNU General Public License version |
| * 2 along with this work; if not, write to the Free Software Foundation, |
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| * |
| * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| * CA 95054 USA or visit www.sun.com if you need additional information or |
| * have any questions. |
| */ |
| |
| package com.sun.tools.internal.ws.util; |
| |
| import java.util.Properties; |
| |
| import com.sun.tools.internal.ws.processor.config.WSDLModelInfo; |
| import com.sun.tools.internal.ws.processor.generator.Names; |
| import com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler; |
| import com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModelerBase; |
| import com.sun.tools.internal.ws.wsdl.framework.AbstractDocument; |
| import com.sun.xml.internal.ws.util.VersionUtil; |
| |
| /** |
| * Singleton factory class to instantiate concrete classes based on the jaxws version |
| * to be used to generate the code. |
| * |
| * @author WS Development Team |
| */ |
| public class JAXWSClassFactory { |
| private static final JAXWSClassFactory factory = new JAXWSClassFactory(); |
| |
| private static String classVersion = VersionUtil.JAXWS_VERSION_DEFAULT; |
| |
| private JAXWSClassFactory() { |
| } |
| |
| /** |
| * Get the factory instance for the default version. |
| * @return JAXWSClassFactory instance |
| */ |
| public static JAXWSClassFactory newInstance() { |
| return factory; |
| } |
| |
| /** |
| * Sets the version to a static classVersion |
| * @param version |
| */ |
| public void setSourceVersion(String version) { |
| if (version == null) |
| version = VersionUtil.JAXWS_VERSION_DEFAULT; |
| |
| if (!VersionUtil.isValidVersion(version)) { |
| // TODO: throw exception |
| } else |
| classVersion = version; |
| } |
| |
| /** |
| * Returns the WSDLModeler for specific target version. |
| * |
| * @param modelInfo |
| * @param options |
| * @return the WSDLModeler for specific target version. |
| */ |
| public WSDLModelerBase createWSDLModeler( |
| WSDLModelInfo modelInfo, |
| Properties options) { |
| WSDLModelerBase wsdlModeler = null; |
| if (classVersion.equals(VersionUtil.JAXWS_VERSION_20)) |
| wsdlModeler = new WSDLModeler(modelInfo, options); |
| else { |
| // TODO: throw exception |
| } |
| return wsdlModeler; |
| } |
| |
| /** |
| * Returns the Names for specific target version. |
| * //bug fix:4904604 |
| * @return instance of Names |
| */ |
| public Names createNames() { |
| Names names = new Names(); |
| return names; |
| } |
| |
| public String getVersion() { |
| return classVersion; |
| } |
| } |