001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License. You may obtain a copy of the License at
009     *
010     * http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied. See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    package javax.xml.ws;
021    
022    import javax.xml.bind.JAXBContext;
023    import javax.xml.namespace.QName;
024    import javax.xml.ws.handler.HandlerResolver;
025    import javax.xml.ws.spi.Provider;
026    import javax.xml.ws.spi.ServiceDelegate;
027    import java.net.URL;
028    import java.util.Iterator;
029    import java.util.concurrent.Executor;
030    
031    public class Service {
032        public enum Mode {
033            MESSAGE, PAYLOAD }
034    
035        protected Service(URL wsdlDocumentLocation, QName serviceName) {
036            delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation, serviceName, getClass());
037        }
038    
039        public <T> T getPort(QName portName, Class<T> serviceEndpointInterface) {
040            return (T) delegate.getPort(portName, serviceEndpointInterface);
041        }
042    
043        public <T> T getPort(Class<T> serviceEndpointInterface) {
044            return (T) delegate.getPort(serviceEndpointInterface);
045        }
046    
047        public <T> T getPort(QName portName, Class<T> serviceEndpointInterface, WebServiceFeature... features) {
048            return (T) delegate.getPort(portName, serviceEndpointInterface, features);
049        }
050        
051        public <T> T getPort(Class<T> serviceEndpointInterface, WebServiceFeature... features) {
052            return (T) delegate.getPort(serviceEndpointInterface, features);
053        }
054        
055        public <T> T getPort(EndpointReference endpointReference, Class<T> serviceEndpointInterface, WebServiceFeature... features) {
056            return (T) delegate.getPort(endpointReference, serviceEndpointInterface, features);
057        }
058        
059        public void addPort(QName portName, String bindingId, String endpointAddress) {
060            delegate.addPort(portName, bindingId, endpointAddress);
061        }
062    
063        public <T>Dispatch<T> createDispatch(QName portName, Class<T> type, Mode mode) {
064            return delegate.createDispatch(portName, type, mode);
065        }
066    
067        public Dispatch<Object> createDispatch(QName portName, JAXBContext context, Mode mode) {
068            return delegate.createDispatch(portName, context, mode);
069        }
070    
071        public <T> Dispatch<T> createDispatch(QName portName, Class<T> type, Service.Mode mode, WebServiceFeature... features) {
072            return delegate.createDispatch(portName, type, mode, features);
073        }
074        
075        public <T> Dispatch<T> createDispatch(EndpointReference endpointReference, Class<T> type, Service.Mode mode, WebServiceFeature... features) {
076            return delegate.createDispatch(endpointReference, type, mode, features);
077        }
078        
079        public Dispatch<Object> createDispatch(QName portName, JAXBContext context, Service.Mode mode, WebServiceFeature... features) {
080            return delegate.createDispatch(portName, context, mode, features);
081        }
082        
083        public Dispatch<Object> createDispatch(EndpointReference endpointReference, JAXBContext context, Service.Mode mode, WebServiceFeature... features) {
084            return delegate.createDispatch(endpointReference, context, mode, features);
085        }
086        
087        public QName getServiceName() {
088            return delegate.getServiceName();
089        }
090    
091        public Iterator<QName> getPorts() {
092            return delegate.getPorts();
093        }
094    
095        public URL getWSDLDocumentLocation() {
096            return delegate.getWSDLDocumentLocation();
097        }
098    
099        public HandlerResolver getHandlerResolver() {
100            return delegate.getHandlerResolver();
101        }
102    
103        public void setHandlerResolver(HandlerResolver handlerResolver) {
104            delegate.setHandlerResolver(handlerResolver);
105        }
106    
107        public Executor getExecutor() {
108            return delegate.getExecutor();
109        }
110    
111        public void setExecutor(Executor executor) {
112            delegate.setExecutor(executor);
113        }
114    
115        public static Service create(URL wsdlDocumentLocation, QName serviceName) {
116            return new Service(wsdlDocumentLocation, serviceName);
117        }
118    
119        public static Service create(QName serviceName) {
120            return new Service(null, serviceName);
121        }
122    
123        private ServiceDelegate delegate;
124    }