001/**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.ksb.api.bus.support;
017
018import javax.xml.bind.annotation.XmlAccessType;
019import javax.xml.bind.annotation.XmlAccessorType;
020import javax.xml.bind.annotation.XmlElement;
021import javax.xml.bind.annotation.XmlRootElement;
022import javax.xml.bind.annotation.XmlType;
023
024@XmlRootElement(name = SoapServiceConfiguration.Constants.ROOT_ELEMENT_NAME)
025@XmlAccessorType(XmlAccessType.NONE)
026@XmlType(name = SoapServiceConfiguration.Constants.TYPE_NAME, propOrder = {
027                SoapServiceConfiguration.Elements.SERVICE_INTERFACE,
028                SoapServiceConfiguration.Elements.JAX_WS_SERVICE
029})
030public class SoapServiceConfiguration extends AbstractServiceConfiguration {
031
032        private static final long serialVersionUID = -4226512121638441108L;
033
034        @XmlElement(name = Elements.SERVICE_INTERFACE, required = true)
035        private final String serviceInterface;
036        
037        @XmlElement(name = Elements.JAX_WS_SERVICE, required = true)
038        private final boolean jaxWsService;
039        
040        /**
041     * Private constructor used only by JAXB.
042     */
043        private SoapServiceConfiguration() {
044                super();
045                this.serviceInterface = null;
046                this.jaxWsService = false;
047        }
048        
049        private SoapServiceConfiguration(Builder builder) {
050                super(builder);
051                this.serviceInterface = builder.getServiceInterface();
052                this.jaxWsService = builder.isJaxWsService();
053        }
054        
055        public static SoapServiceConfiguration fromServiceDefinition(SoapServiceDefinition soapServiceDefinition) {
056                return Builder.create(soapServiceDefinition).build();
057        }
058        
059        public String getServiceInterface() {
060                return serviceInterface;
061        }
062
063        public boolean isJaxWsService() {
064                return jaxWsService;
065        }
066        
067        public static final class Builder extends AbstractServiceConfiguration.Builder<SoapServiceConfiguration> {
068
069                private static final long serialVersionUID = 722267174667364588L;
070
071                private String serviceInterface;
072                private boolean jaxWsService = false;           
073                                
074                public String getServiceInterface() {
075                        return serviceInterface;
076                }
077
078                public void setServiceInterface(String serviceInterface) {
079                        this.serviceInterface = serviceInterface;
080                }
081
082                public boolean isJaxWsService() {
083                        return jaxWsService;
084                }
085
086                public void setJaxWsService(boolean jaxWsService) {
087                        this.jaxWsService = jaxWsService;
088                }
089
090                private Builder() {}
091                
092                public static Builder create() {
093                        return new Builder();
094                }
095                
096                public static Builder create(SoapServiceDefinition soapServiceDefinition) {
097                        Builder builder = create();
098                        builder.copyServiceDefinitionProperties(soapServiceDefinition);
099                        builder.setServiceInterface(soapServiceDefinition.getServiceInterface());
100                        builder.setJaxWsService(soapServiceDefinition.isJaxWsService());
101                        return builder;
102                }
103
104                @Override
105                public SoapServiceConfiguration build() {
106                        return new SoapServiceConfiguration(this);
107                }
108                
109        }
110        
111        /**
112     * Defines some internal constants used on this class.
113     */
114    static class Constants {
115        final static String ROOT_ELEMENT_NAME = "soapServiceConfiguration";
116        final static String TYPE_NAME = "SoapServiceConfigurationType";
117    }
118
119    /**
120     * A private class which exposes constants which define the XML element names to use
121     * when this object is marshalled to XML.
122     */
123     static class Elements {
124        protected final static String SERVICE_INTERFACE = "serviceInterface";
125        protected final static String JAX_WS_SERVICE = "jaxWsService";
126    }
127        
128}