1 /* 2 * Copyright (c) 1997, 2013, 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.oracle.webservices.internal.api.databinding; 27 28 import java.util.Map; 29 30 /** 31 * {@code DatabindingFactory} is the entry point of all the WebService 32 * Databinding APIs. A DatabindingFactory instance can be used to create 33 * <code>Databinding.Builder</code> instances, and <code>Databinding.Builder</code> 34 * instances are used to configure and build <code>Databinding</code> instances. 35 * <p> 36 * </P> 37 * <blockquote> 38 * Following is an example that creates a {@code Databinding} which provides the 39 * operations to serialize/deserialize a JavaCallInfo to/from a SOAP message:<br/> 40 * <pre> 41 * DatabindingFactory factory = DatabindingFactory.newInstance(); 42 * Databinding.Builder builder = factory.createBuilder(seiClass, endpointClass); 43 * Databinding databinding = builder.build(); 44 * </pre> 45 * </blockquote> 46 * 47 * @see com.oracle.webservices.internal.api.databinding.Databinding 48 * 49 * @author shih-chang.chen@oracle.com 50 */ 51 public abstract class DatabindingFactory { 52 53 /** 54 * Creates a new instance of a <code>Databinding.Builder</code> which is 55 * initialized with the specified contractClass and endpointClass. The most 56 * importance initial states of a Builder object is the contract class which 57 * is also called "service endpoint interface" or "SEI" in JAX-WS and JAX-RPC, 58 * and the implementation bean class (endpointClass). The the implementation 59 * bean class (endpointClass) should be null if the Builder is to create 60 * the client side proxy databinding. 61 * 62 * @param contractClass The service endpoint interface class 63 * @param endpointClass The service implementation bean class 64 * 65 * @return New instance of a <code>Databinding.Builder</code> 66 */ createBuilder(Class<?> contractClass, Class<?> endpointClass)67 abstract public Databinding.Builder createBuilder(Class<?> contractClass, Class<?> endpointClass); 68 69 /** 70 * Access properties on the <code>DatabindingFactory</code> instance. 71 * 72 * @return properties of this WsFactory 73 */ properties()74 abstract public Map<String, Object> properties(); 75 76 /** 77 * The default implementation class name. 78 */ 79 static final String ImplClass = "com.sun.xml.internal.ws.db.DatabindingFactoryImpl"; 80 81 /** 82 * Create a new instance of a <code>DatabindingFactory</code>. This static method 83 * creates a new factory instance. 84 * 85 * Once an application has obtained a reference to a <code>DatabindingFactory</code> 86 * it can use the factory to obtain and configure a <code>Databinding.Builder</code> 87 * to build a <code>Databinding</code> instances. 88 * 89 * @return New instance of a <code>DatabindingFactory</code> 90 */ newInstance()91 static public DatabindingFactory newInstance() { 92 try { 93 Class<?> cls = Class.forName(ImplClass); 94 return convertIfNecessary(cls); 95 } catch (Exception e) { 96 e.printStackTrace(); 97 } 98 return null; 99 } 100 101 @SuppressWarnings("deprecation") convertIfNecessary(Class<?> cls)102 private static DatabindingFactory convertIfNecessary(Class<?> cls) throws InstantiationException, IllegalAccessException { 103 return (DatabindingFactory) cls.newInstance(); 104 } 105 } 106