001 /**
002 * Copyright 2005-2011 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 */
016 package org.kuali.rice.ksb.api.bus.support;
017
018 import org.kuali.rice.core.api.config.ConfigurationException;
019 import org.kuali.rice.ksb.api.KsbApiConstants;
020 import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
021
022 /**
023 * @author Kuali Rice Team (rice.collab@kuali.org)
024 * @since 0.9
025 */
026 public class SoapServiceDefinition extends AbstractServiceDefinition {
027
028 private static final long serialVersionUID = 5892163789061959602L;
029
030 private String serviceInterface;
031 private boolean jaxWsService = false;
032
033 @Override
034 public String getType() {
035 return KsbApiConstants.ServiceTypes.SOAP;
036 }
037
038
039 /**
040 * @return the jaxWsService
041 */
042 public boolean isJaxWsService() {
043 return this.jaxWsService;
044 }
045
046 /**
047 * @param jaxWsService
048 * define service as jaxws service.
049 */
050 public void setJaxWsService(boolean jaxWsService) {
051 this.jaxWsService = jaxWsService;
052 }
053
054 /**
055 * Constructor that sets the bus security (i.e. digital signing) to FALSE by
056 * default.
057 */
058 public SoapServiceDefinition() {
059 setBusSecurity(true);
060 }
061
062 public String getServiceInterface() {
063 return this.serviceInterface;
064 }
065
066 public void setServiceInterface(final String serviceInterface) {
067 this.serviceInterface = serviceInterface;
068 }
069
070 @Override
071 public void validate() {
072
073 super.validate();
074 // if interface is null grab the first one and use it
075 if (getServiceInterface() == null) {
076 //gets the basic cases - not all
077 Class<?> cur = getService().getClass();
078 while(cur.getInterfaces().length == 0 && (cur.getSuperclass() != Object.class || cur.getSuperclass() != null)) {
079 cur = cur.getSuperclass();
080 }
081
082 if (cur.getInterfaces().length == 0) {
083 throw new ConfigurationException(getService().getClass().getName() +
084 " Service needs to implement interface to be exported as SOAP service");
085 }
086 setServiceInterface(cur.getInterfaces()[0].getName());
087 } else {
088 // Validate that the service interface set is an actual interface
089 // that exists
090 try {
091 if (!Class.forName(getServiceInterface()).isInterface()) {
092 throw new ConfigurationException(
093 "Service interface class '" + getServiceInterface() + "' must be a Java interface");
094 }
095 } catch (ClassNotFoundException e) {
096 throw new ConfigurationException(
097 "Service interface class '" + getServiceInterface() + "' could not be found in the classpath");
098 }
099 }
100
101 }
102
103 @Override
104 protected ServiceConfiguration configure() {
105 return SoapServiceConfiguration.fromServiceDefinition(this);
106 }
107
108
109 }