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.xml.internal.ws.server; aoqi@0: aoqi@0: import com.sun.istack.internal.NotNull; aoqi@0: import com.sun.xml.internal.ws.api.server.SDDocument; aoqi@0: import com.sun.xml.internal.ws.api.server.SDDocumentFilter; aoqi@0: import com.sun.xml.internal.ws.api.server.ServiceDefinition; aoqi@0: import com.sun.xml.internal.ws.wsdl.SDDocumentResolver; aoqi@0: aoqi@0: import java.util.ArrayList; aoqi@0: import java.util.HashMap; aoqi@0: import java.util.Iterator; aoqi@0: import java.util.List; aoqi@0: import java.util.Map; aoqi@0: aoqi@0: /** aoqi@0: * {@link ServiceDefinition} implementation. aoqi@0: * aoqi@0: *

aoqi@0: * You construct a {@link ServiceDefinitionImpl} by first constructing aoqi@0: * a list of {@link SDDocumentImpl}s. aoqi@0: * aoqi@0: * @author Kohsuke Kawaguchi aoqi@0: */ aoqi@0: public final class ServiceDefinitionImpl implements ServiceDefinition, SDDocumentResolver { aoqi@0: private final List docs; aoqi@0: aoqi@0: private final Map bySystemId; aoqi@0: private final @NotNull SDDocumentImpl primaryWsdl; aoqi@0: aoqi@0: /** aoqi@0: * Set when {@link WSEndpointImpl} is created. aoqi@0: */ aoqi@0: /*package*/ WSEndpointImpl owner; aoqi@0: aoqi@0: /*package*/ final List filters = new ArrayList(); aoqi@0: aoqi@0: /** aoqi@0: * @param docs aoqi@0: * List of {@link SDDocumentImpl}s to form the description. aoqi@0: * There must be at least one entry. aoqi@0: * The first document is considered {@link #getPrimary() primary}. aoqi@0: */ aoqi@0: public ServiceDefinitionImpl(List docs, @NotNull SDDocumentImpl primaryWsdl) { aoqi@0: assert docs.contains(primaryWsdl); aoqi@0: this.docs = docs; aoqi@0: this.primaryWsdl = primaryWsdl; aoqi@0: aoqi@0: this.bySystemId = new HashMap(docs.size()); aoqi@0: for (SDDocumentImpl doc : docs) { aoqi@0: bySystemId.put(doc.getURL().toExternalForm(),doc); aoqi@0: doc.setFilters(filters); aoqi@0: doc.setResolver(this); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * The owner is set when {@link WSEndpointImpl} is created. aoqi@0: */ aoqi@0: /*package*/ void setOwner(WSEndpointImpl owner) { aoqi@0: assert owner!=null && this.owner==null; aoqi@0: this.owner = owner; aoqi@0: } aoqi@0: aoqi@0: public @NotNull SDDocument getPrimary() { aoqi@0: return primaryWsdl; aoqi@0: } aoqi@0: aoqi@0: public void addFilter(SDDocumentFilter filter) { aoqi@0: filters.add(filter); aoqi@0: } aoqi@0: aoqi@0: public Iterator iterator() { aoqi@0: return (Iterator)docs.iterator(); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Gets the {@link SDDocumentImpl} whose {@link SDDocumentImpl#getURL()} aoqi@0: * returns the specified value. aoqi@0: * aoqi@0: * @return aoqi@0: * null if none is found. aoqi@0: */ aoqi@0: public SDDocument resolve(String systemId) { aoqi@0: return bySystemId.get(systemId); aoqi@0: } aoqi@0: }