aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.tools.internal.ws.processor.model; aoqi@0: aoqi@0: import com.sun.tools.internal.ws.processor.model.jaxb.JAXBModel; aoqi@0: import com.sun.tools.internal.ws.wsdl.framework.Entity; aoqi@0: aoqi@0: import javax.xml.namespace.QName; aoqi@0: import java.util.*; aoqi@0: aoqi@0: /** aoqi@0: * The model is used to represent the entire Web Service. The JAX-WS ProcessorActions can process aoqi@0: * this Model to generate Java artifacts such as the service interface. aoqi@0: * aoqi@0: * @author WS Development Team aoqi@0: */ aoqi@0: public class Model extends ModelObject { aoqi@0: aoqi@0: public Model(Entity entity) { aoqi@0: super(entity); aoqi@0: } aoqi@0: aoqi@0: public Model(QName name, Entity entity) { aoqi@0: super(entity); aoqi@0: this.name = name; aoqi@0: } aoqi@0: aoqi@0: public QName getName() { aoqi@0: return name; aoqi@0: } aoqi@0: aoqi@0: public void setName(QName n) { aoqi@0: name = n; aoqi@0: } aoqi@0: aoqi@0: public String getTargetNamespaceURI() { aoqi@0: return targetNamespace; aoqi@0: } aoqi@0: aoqi@0: public void setTargetNamespaceURI(String s) { aoqi@0: targetNamespace = s; aoqi@0: } aoqi@0: aoqi@0: public void addService(Service service) { aoqi@0: if (servicesByName.containsKey(service.getName())) { aoqi@0: throw new ModelException("model.uniqueness"); aoqi@0: } aoqi@0: services.add(service); aoqi@0: servicesByName.put(service.getName(), service); aoqi@0: } aoqi@0: aoqi@0: public Service getServiceByName(QName name) { aoqi@0: if (servicesByName.size() != services.size()) { aoqi@0: initializeServicesByName(); aoqi@0: } aoqi@0: return (Service)servicesByName.get(name); aoqi@0: } aoqi@0: aoqi@0: /* serialization */ aoqi@0: public List getServices() { aoqi@0: return services; aoqi@0: } aoqi@0: aoqi@0: /* serialization */ aoqi@0: public void setServices(List l) { aoqi@0: services = l; aoqi@0: } aoqi@0: aoqi@0: private void initializeServicesByName() { aoqi@0: servicesByName = new HashMap(); aoqi@0: if (services != null) { aoqi@0: for (Service service : services) { aoqi@0: if (service.getName() != null && aoqi@0: servicesByName.containsKey(service.getName())) { aoqi@0: aoqi@0: throw new ModelException("model.uniqueness"); aoqi@0: } aoqi@0: servicesByName.put(service.getName(), service); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public void addExtraType(AbstractType type) { aoqi@0: extraTypes.add(type); aoqi@0: } aoqi@0: aoqi@0: public Iterator getExtraTypes() { aoqi@0: return extraTypes.iterator(); aoqi@0: } aoqi@0: aoqi@0: /* serialization */ aoqi@0: public Set getExtraTypesSet() { aoqi@0: return extraTypes; aoqi@0: } aoqi@0: aoqi@0: /* serialization */ aoqi@0: public void setExtraTypesSet(Set s) { aoqi@0: extraTypes = s; aoqi@0: } aoqi@0: aoqi@0: aoqi@0: public void accept(ModelVisitor visitor) throws Exception { aoqi@0: visitor.visit(this); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * @return the source version aoqi@0: */ aoqi@0: public String getSource() { aoqi@0: return source; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * @param string aoqi@0: */ aoqi@0: public void setSource(String string) { aoqi@0: source = string; aoqi@0: } aoqi@0: aoqi@0: public void setJAXBModel(JAXBModel jaxBModel) { aoqi@0: this.jaxBModel = jaxBModel; aoqi@0: } aoqi@0: aoqi@0: public JAXBModel getJAXBModel() { aoqi@0: return jaxBModel; aoqi@0: } aoqi@0: aoqi@0: private QName name; aoqi@0: private String targetNamespace; aoqi@0: private List services = new ArrayList(); aoqi@0: private Map servicesByName = new HashMap(); aoqi@0: private Set extraTypes = new HashSet(); aoqi@0: private String source; aoqi@0: private JAXBModel jaxBModel = null; aoqi@0: }