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.wsdl.document; aoqi@0: aoqi@0: import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; aoqi@0: import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension; aoqi@0: import com.sun.tools.internal.ws.wsdl.framework.*; aoqi@0: import com.sun.tools.internal.ws.wscompile.ErrorReceiver; aoqi@0: import org.xml.sax.Locator; aoqi@0: aoqi@0: import javax.xml.namespace.QName; aoqi@0: import java.util.ArrayList; aoqi@0: import java.util.Iterator; aoqi@0: import java.util.List; aoqi@0: aoqi@0: /** aoqi@0: * Entity corresponding to the "service" WSDL element. aoqi@0: * aoqi@0: * @author WS Development Team aoqi@0: */ aoqi@0: public class Service extends GlobalEntity implements TWSDLExtensible { aoqi@0: aoqi@0: public Service(Defining defining, Locator locator, ErrorReceiver errReceiver) { aoqi@0: super(defining, locator, errReceiver); aoqi@0: _ports = new ArrayList(); aoqi@0: _helper = new ExtensibilityHelper(); aoqi@0: } aoqi@0: aoqi@0: public void add(Port port) { aoqi@0: port.setService(this); aoqi@0: _ports.add(port); aoqi@0: } aoqi@0: aoqi@0: public Iterator ports() { aoqi@0: return _ports.iterator(); aoqi@0: } aoqi@0: aoqi@0: public Kind getKind() { aoqi@0: return Kinds.SERVICE; aoqi@0: } aoqi@0: aoqi@0: public QName getElementName() { aoqi@0: return WSDLConstants.QNAME_SERVICE; aoqi@0: } aoqi@0: aoqi@0: public Documentation getDocumentation() { aoqi@0: return _documentation; aoqi@0: } aoqi@0: aoqi@0: public void setDocumentation(Documentation d) { aoqi@0: _documentation = d; aoqi@0: } aoqi@0: aoqi@0: public void withAllSubEntitiesDo(EntityAction action) { aoqi@0: for (Iterator iter = _ports.iterator(); iter.hasNext();) { aoqi@0: action.perform((Entity) iter.next()); aoqi@0: } aoqi@0: _helper.withAllSubEntitiesDo(action); aoqi@0: } aoqi@0: aoqi@0: public void accept(WSDLDocumentVisitor visitor) throws Exception { aoqi@0: visitor.preVisit(this); aoqi@0: for (Iterator iter = _ports.iterator(); iter.hasNext();) { aoqi@0: ((Port) iter.next()).accept(visitor); aoqi@0: } aoqi@0: _helper.accept(visitor); aoqi@0: visitor.postVisit(this); aoqi@0: } aoqi@0: aoqi@0: public void validateThis() { aoqi@0: if (getName() == null) { aoqi@0: failValidation("validation.missingRequiredAttribute", "name"); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public String getNameValue() { aoqi@0: return getName(); aoqi@0: } aoqi@0: aoqi@0: public String getNamespaceURI() { aoqi@0: return getDefining().getTargetNamespaceURI(); aoqi@0: } aoqi@0: aoqi@0: public QName getWSDLElementName() { aoqi@0: return getElementName(); aoqi@0: } aoqi@0: aoqi@0: public void addExtension(TWSDLExtension e) { aoqi@0: _helper.addExtension(e); aoqi@0: } aoqi@0: aoqi@0: public Iterable extensions() { aoqi@0: return _helper.extensions(); aoqi@0: } aoqi@0: aoqi@0: public TWSDLExtensible getParent() { aoqi@0: return null; //To change body of implemented methods use File | Settings | File Templates. aoqi@0: } aoqi@0: aoqi@0: private ExtensibilityHelper _helper; aoqi@0: private Documentation _documentation; aoqi@0: private List _ports; aoqi@0: }