1 /*
   2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.api.databinding;
  27 
  28 import java.util.Map;
  29 
  30 /**
  31  * WsFactory is the entry point of all the ws-databinding APIs. A WsFactory
  32  * instance can be used to create <code>WsTool</code>, <code>WsRuntime</code>,
  33  * <code>XsTool</code>, and <code>XsRuntime</code> instances.
  34  * <p>
  35  * </P>
  36  * <blockquote>
  37  * Following is an example that creates a {@code WsTool} which provides the
  38  * operations for "WSDL to JAVA" and "JAVA to WSDL":<br />
  39  * <pre>
  40  *       WsFactory wsfac = WsFactory.newInstance();
  41  *       WsTool tool = wsfac.createTool();
  42  *       GenerationStatus status = tool.generateWsdl(javaToWsdkInfo);
  43  * </pre>
  44  * </blockquote>
  45  *
  46  * <blockquote>
  47  * Following is an example that creates a {@code WsRuntime} which provides the
  48  * operations to serialize/deserialize a JavaCallInfo to/from a SOAP message:<br />
  49  * <pre>
  50  *       WsFactory wsfac = WsFactory.newInstance();
  51  *       WsRuntime rt = wsfac.createRuntime(wsRuntimeConfig);
  52  * </pre>
  53  * </blockquote>
  54  *
  55  * @see com.sun.xml.internal.ws.api.databinding.Databinding
  56  *
  57  * @author shih-chang.chen@oracle.com
  58  */
  59 public abstract class DatabindingFactory extends com.sun.xml.internal.org.jvnet.ws.databinding.DatabindingFactory {
  60 
  61   /**
  62    * Creates a new instance of a <code>WsTool</code>.
  63    *
  64    * @return New instance of a <code>WsTool</code>
  65    */
  66 //      abstract public WsTool createTool();
  67 
  68   /**
  69    * Creates a new instance of a <code>WsRuntime</code> which is initialized
  70    * with the specified configuration object.
  71    *
  72    * @param config
  73    *          the EndpointRuntimeConfig to init this WsRuntime
  74    * @return New instance of a <code>WsRuntime</code>
  75    */
  76   abstract public com.sun.xml.internal.org.jvnet.ws.databinding.Databinding createRuntime(DatabindingConfig config);
  77 
  78   /**
  79    * Creates a new instance of a <code>XsTool</code>.
  80    *
  81    * @return New instance of a <code>XsTool</code>
  82    */
  83 //      abstract public XsTool createXsTool(String mode);
  84 
  85   /**
  86    * Creates a new instance of a <code>XsRuntime</code>.
  87    *
  88    * @return New instance of a <code>XsRuntime</code>
  89    */
  90 //      abstract public XsRuntime createXsRuntime(String mode);
  91 
  92   /**
  93    * Access properties on the <code>WsFactory</code> instance.
  94    *
  95    * @return properties of this WsFactory
  96    */
  97         abstract public Map<String, Object> properties();
  98 
  99         /**
 100          * The default implementation class name.
 101          */
 102         static final String ImplClass = com.sun.xml.internal.ws.db.DatabindingFactoryImpl.class.getName();
 103 
 104   /**
 105    * Create a new instance of a <code>WsFactory</code>. This static method
 106    * creates a new factory instance.
 107    *
 108    * Once an application has obtained a reference to a <code>WsFactory</code>
 109    * it can use the factory to configure and obtain <code>WsTool</code> and
 110    * <code>WsRuntime</code> instances.
 111    *
 112    * @return New instance of a <code>WsFactory</code>
 113    */
 114         static public DatabindingFactory newInstance() {
 115                 try {
 116                         Class<?> cls = Class.forName(ImplClass);
 117                         return (DatabindingFactory) cls.newInstance();
 118                 } catch (Exception e) {
 119                         e.printStackTrace();
 120                 }
 121                 return null;
 122         }
 123 }