src/share/jaxws_classes/com/sun/xml/internal/ws/api/WSService.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  65  * to think of this as an internal representation of a service.
  66  *
  67  * <p>
  68  * Only JAX-WS internal code may downcast this to {@link WSServiceDelegate}.
  69  *
  70  * @author Kohsuke Kawaguchi
  71  */
  72 public abstract class WSService extends ServiceDelegate implements ComponentRegistry {
  73         private final Set<Component> components = new CopyOnWriteArraySet<Component>();
  74 
  75         protected WSService() {
  76     }
  77 
  78     /**
  79      * Works like {@link #getPort(EndpointReference, Class, WebServiceFeature...)}
  80      * but takes {@link WSEndpointReference}.
  81      */
  82     public abstract <T> T getPort(WSEndpointReference epr, Class<T> portInterface, WebServiceFeature... features);
  83 
  84     /**
  85      * Works like {@link #createDispatch(EndpointReference, Class, Mode, WebServiceFeature[])}
  86      * but it takes the port name separately, so that EPR without embedded metadata can be used.
  87      */
  88     public abstract <T> Dispatch<T> createDispatch(QName portName, WSEndpointReference wsepr, Class<T> aClass, Service.Mode mode, WebServiceFeature... features);
  89 
  90     /**
  91      * Works like {@link #createDispatch(EndpointReference, JAXBContext, Mode, WebServiceFeature[])}
  92      * but it takes the port name separately, so that EPR without embedded metadata can be used.
  93      */
  94     public abstract Dispatch<Object> createDispatch(QName portName, WSEndpointReference wsepr, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeature... features);
  95 
  96     /**
  97      * Gets the {@link Container} object.
  98      *
  99      * <p>
 100      * The components inside {@link WSEndpoint} uses this reference
 101      * to communicate with the hosting environment.
 102      *
 103      * @return
 104      *      always same object. If no "real" {@link Container} instance
 105      *      is given, {@link Container#NONE} will be returned.
 106      */
 107     public abstract @NotNull Container getContainer();
 108 
 109     public @Nullable <S> S getSPI(@NotNull Class<S> spiType) {
 110         for (Component c : components) {
 111                 S s = c.getSPI(spiType);
 112                 if (s != null)
 113                         return s;
 114         }
 115 
 116         return null;
 117     }
 118 
 119     public @NotNull Set<Component> getComponents() {
 120         return components;
 121     }
 122 
 123     /**
 124      * Create a <code>Service</code> instance.
 125      *
 126      * The specified WSDL document location and service qualified name MUST
 127      * uniquely identify a <code>wsdl:service</code> element.
 128      *
 129      * @param wsdlDocumentLocation URL for the WSDL document location
 130      *                             for the service
 131      * @param serviceName QName for the service
 132      * @throws WebServiceException If any error in creation of the
 133      *                    specified service.
 134      **/
 135     public static WSService create( URL wsdlDocumentLocation, QName serviceName) {
 136         return new WSServiceDelegate(wsdlDocumentLocation,serviceName,Service.class);


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  65  * to think of this as an internal representation of a service.
  66  *
  67  * <p>
  68  * Only JAX-WS internal code may downcast this to {@link WSServiceDelegate}.
  69  *
  70  * @author Kohsuke Kawaguchi
  71  */
  72 public abstract class WSService extends ServiceDelegate implements ComponentRegistry {
  73         private final Set<Component> components = new CopyOnWriteArraySet<Component>();
  74 
  75         protected WSService() {
  76     }
  77 
  78     /**
  79      * Works like {@link #getPort(EndpointReference, Class, WebServiceFeature...)}
  80      * but takes {@link WSEndpointReference}.
  81      */
  82     public abstract <T> T getPort(WSEndpointReference epr, Class<T> portInterface, WebServiceFeature... features);
  83 
  84     /**
  85      * Works like {@link #createDispatch(javax.xml.ws.EndpointReference, java.lang.Class, javax.xml.ws.Service.Mode, javax.xml.ws.WebServiceFeature[])}
  86      * but it takes the port name separately, so that EPR without embedded metadata can be used.
  87      */
  88     public abstract <T> Dispatch<T> createDispatch(QName portName, WSEndpointReference wsepr, Class<T> aClass, Service.Mode mode, WebServiceFeature... features);
  89 
  90     /**
  91      * Works like {@link #createDispatch(javax.xml.ws.EndpointReference, javax.xml.bind.JAXBContext, javax.xml.ws.Service.Mode, javax.xml.ws.WebServiceFeature[])}
  92      * but it takes the port name separately, so that EPR without embedded metadata can be used.
  93      */
  94     public abstract Dispatch<Object> createDispatch(QName portName, WSEndpointReference wsepr, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeature... features);
  95 
  96     /**
  97      * Gets the {@link Container} object.
  98      *
  99      * <p>
 100      * The components inside {@link WSEndpoint} uses this reference
 101      * to communicate with the hosting environment.
 102      *
 103      * @return
 104      *      always same object. If no "real" {@link Container} instance
 105      *      is given, {@link Container#NONE} will be returned.
 106      */
 107     public abstract @NotNull Container getContainer();
 108 
 109     public @Nullable <S> S getSPI(@NotNull Class<S> spiType) {
 110         for (Component c : components) {
 111                 S s = c.getSPI(spiType);
 112                 if (s != null)
 113                         return s;
 114         }
 115 
 116         return getContainer().getSPI(spiType);
 117     }
 118 
 119     public @NotNull Set<Component> getComponents() {
 120         return components;
 121     }
 122 
 123     /**
 124      * Create a <code>Service</code> instance.
 125      *
 126      * The specified WSDL document location and service qualified name MUST
 127      * uniquely identify a <code>wsdl:service</code> element.
 128      *
 129      * @param wsdlDocumentLocation URL for the WSDL document location
 130      *                             for the service
 131      * @param serviceName QName for the service
 132      * @throws WebServiceException If any error in creation of the
 133      *                    specified service.
 134      **/
 135     public static WSService create( URL wsdlDocumentLocation, QName serviceName) {
 136         return new WSServiceDelegate(wsdlDocumentLocation,serviceName,Service.class);