ohair@286: /* ohair@286: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. ohair@286: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@286: * ohair@286: * This code is free software; you can redistribute it and/or modify it ohair@286: * under the terms of the GNU General Public License version 2 only, as ohair@286: * published by the Free Software Foundation. Oracle designates this ohair@286: * particular file as subject to the "Classpath" exception as provided ohair@286: * by Oracle in the LICENSE file that accompanied this code. ohair@286: * ohair@286: * This code is distributed in the hope that it will be useful, but WITHOUT ohair@286: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@286: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@286: * version 2 for more details (a copy is included in the LICENSE file that ohair@286: * accompanied this code). ohair@286: * ohair@286: * You should have received a copy of the GNU General Public License version ohair@286: * 2 along with this work; if not, write to the Free Software Foundation, ohair@286: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@286: * ohair@286: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@286: * or visit www.oracle.com if you need additional information or have any ohair@286: * questions. ohair@286: */ ohair@286: ohair@286: package com.sun.xml.internal.ws.db; ohair@286: ohair@286: import java.io.File; ohair@286: import java.util.Map; ohair@286: ohair@286: import com.sun.xml.internal.org.jvnet.ws.databinding.Databinding.WSDLGenerator; ohair@286: ohair@286: import com.sun.xml.internal.ws.api.databinding.Databinding; ohair@286: import com.sun.xml.internal.ws.api.databinding.DatabindingConfig; ohair@286: import com.sun.xml.internal.ws.api.databinding.WSDLGenInfo; ohair@286: import com.sun.xml.internal.ws.spi.db.DatabindingProvider; ohair@286: ohair@286: /** ohair@286: * DatabindingProviderImpl is the default JAXWS implementation of DatabindingProvider ohair@286: * ohair@286: * @author shih-chang.chen@oracle.com ohair@286: */ ohair@286: public class DatabindingProviderImpl implements DatabindingProvider { ohair@286: static final private String CachedDatabinding = "com.sun.xml.internal.ws.db.DatabindingProviderImpl"; ohair@286: Map properties; ohair@286: ohair@286: public void init(Map p) { ohair@286: properties = p; ohair@286: } ohair@286: ohair@286: DatabindingImpl getCachedDatabindingImpl(DatabindingConfig config) { ohair@286: Object object = config.properties().get(CachedDatabinding); ohair@286: return (object != null && object instanceof DatabindingImpl)? (DatabindingImpl)object : null; ohair@286: } ohair@286: ohair@286: public Databinding create(DatabindingConfig config) { ohair@286: DatabindingImpl impl = getCachedDatabindingImpl(config); ohair@286: if (impl == null) { ohair@286: impl = new DatabindingImpl(this, config); ohair@286: config.properties().put(CachedDatabinding, impl); ohair@286: } ohair@286: return impl; ohair@286: } ohair@286: ohair@286: public WSDLGenerator wsdlGen(DatabindingConfig config) { ohair@286: DatabindingImpl impl = (DatabindingImpl)create(config); ohair@286: return new JaxwsWsdlGen(impl); ohair@286: } ohair@286: ohair@286: public boolean isFor(String databindingMode) { ohair@286: //This is the default one, so it always return true ohair@286: return true; ohair@286: } ohair@286: ohair@286: static public class JaxwsWsdlGen implements Databinding.WSDLGenerator { ohair@286: DatabindingImpl databinding; ohair@286: WSDLGenInfo wsdlGenInfo; ohair@286: ohair@286: JaxwsWsdlGen(DatabindingImpl impl) { ohair@286: databinding = impl; ohair@286: wsdlGenInfo = new WSDLGenInfo(); ohair@286: } ohair@286: ohair@286: public WSDLGenerator inlineSchema(boolean inline) { ohair@286: wsdlGenInfo.setInlineSchemas(inline); ohair@286: return this; ohair@286: } ohair@286: ohair@286: public WSDLGenerator property(String name, Object value) { ohair@286: // TODO Auto-generated method stub ohair@286: return null; ohair@286: } ohair@286: ohair@286: public void generate(WSDLResolver wsdlResolver) { ohair@286: // wsdlGenInfo.setWsdlResolver(wsdlResolver); ohair@286: databinding.generateWSDL(wsdlGenInfo); ohair@286: } ohair@286: ohair@286: public void generate(File outputDir, String name) { ohair@286: // TODO Auto-generated method stub ohair@286: databinding.generateWSDL(wsdlGenInfo); ohair@286: } ohair@286: } ohair@286: }