325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.tools.internal.ws.processor.model;
325N/A
325N/Aimport com.sun.tools.internal.ws.processor.model.java.JavaInterface;
325N/Aimport com.sun.tools.internal.ws.wsdl.framework.Entity;
325N/A
325N/Aimport javax.xml.namespace.QName;
325N/Aimport java.util.*;
325N/A
325N/A/**
325N/A *
325N/A * @author WS Development Team
325N/A */
325N/Apublic class Service extends ModelObject {
325N/A
325N/A public Service(Entity entity) {
325N/A super(entity);
325N/A }
325N/A
325N/A public Service(QName name, JavaInterface javaInterface, Entity entity) {
325N/A super(entity);
325N/A this.name = name;
325N/A this.javaInterface = javaInterface;
325N/A }
325N/A
325N/A public QName getName() {
325N/A return name;
325N/A }
325N/A
325N/A public void setName(QName n) {
325N/A name = n;
325N/A }
325N/A
325N/A public void addPort(Port port) {
325N/A if (portsByName.containsKey(port.getName())) {
325N/A throw new ModelException("model.uniqueness");
325N/A }
325N/A ports.add(port);
325N/A portsByName.put(port.getName(), port);
325N/A }
325N/A
325N/A
325N/A public Port getPortByName(QName n) {
325N/A if (portsByName.size() != ports.size()) {
325N/A initializePortsByName();
325N/A }
325N/A return (Port) portsByName.get(n);
325N/A }
325N/A
325N/A /* serialization */
325N/A public List<Port> getPorts() {
325N/A return ports;
325N/A }
325N/A
325N/A /* serialization */
325N/A public void setPorts(List<Port> m) {
325N/A ports = m;
325N/A// initializePortsByName();
325N/A }
325N/A
325N/A private void initializePortsByName() {
325N/A portsByName = new HashMap();
325N/A if (ports != null) {
325N/A for (Iterator iter = ports.iterator(); iter.hasNext();) {
325N/A Port port = (Port) iter.next();
325N/A if (port.getName() != null &&
325N/A portsByName.containsKey(port.getName())) {
325N/A
325N/A throw new ModelException("model.uniqueness");
325N/A }
325N/A portsByName.put(port.getName(), port);
325N/A }
325N/A }
325N/A }
325N/A
325N/A public JavaInterface getJavaIntf() {
325N/A return getJavaInterface();
325N/A }
325N/A
325N/A public JavaInterface getJavaInterface() {
325N/A return javaInterface;
325N/A }
325N/A
325N/A public void setJavaInterface(JavaInterface i) {
325N/A javaInterface = i;
325N/A }
325N/A
325N/A public void accept(ModelVisitor visitor) throws Exception {
325N/A visitor.visit(this);
325N/A }
325N/A
325N/A private QName name;
325N/A private List<Port> ports = new ArrayList();
325N/A private Map<QName, Port> portsByName = new HashMap<QName, Port>();
325N/A private JavaInterface javaInterface;
325N/A}