View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.ksb.api.bus.support;
17  
18  import org.kuali.rice.core.api.config.ConfigurationException;
19  import org.kuali.rice.ksb.api.KsbApiConstants;
20  import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   * @since 0.9
25   */
26  public class SoapServiceDefinition extends AbstractServiceDefinition {
27  
28  	private static final long serialVersionUID = 5892163789061959602L;
29  
30  	private String serviceInterface;
31  	private boolean jaxWsService = false;
32  
33  	@Override
34  	public String getType() {
35  		return KsbApiConstants.ServiceTypes.SOAP;
36  	}
37  
38  	
39  	/**
40  	 * @return the jaxWsService
41  	 */
42  	public boolean isJaxWsService() {
43  		return this.jaxWsService;
44  	}
45  
46  	/**
47  	 * @param jaxWsService
48  	 *            define service as jaxws service.
49  	 */
50  	public void setJaxWsService(boolean jaxWsService) {
51  		this.jaxWsService = jaxWsService;
52  	}
53  
54  	/**
55  	 * Constructor that sets the bus security (i.e. digital signing) to FALSE by
56  	 * default.
57  	 */
58  	public SoapServiceDefinition() {
59  		setBusSecurity(true);
60  	}
61  
62  	public String getServiceInterface() {
63  		return this.serviceInterface;
64  	}
65  
66  	public void setServiceInterface(final String serviceInterface) {
67  		this.serviceInterface = serviceInterface;
68  	}
69  
70  	@Override
71  	public void validate() {
72  
73  		super.validate();
74  		// if interface is null grab the first one and use it
75  		if (getServiceInterface() == null) {
76  			//gets the basic cases - not all
77              Class<?> cur = getService().getClass();
78              while(cur.getInterfaces().length == 0 && (cur.getSuperclass() != Object.class || cur.getSuperclass() != null)) {
79                  cur = cur.getSuperclass();
80              }
81  
82              if (cur.getInterfaces().length == 0) {
83  				throw new ConfigurationException(getService().getClass().getName() +
84  						" Service needs to implement interface to be exported as SOAP service");
85  			}
86  			setServiceInterface(cur.getInterfaces()[0].getName());
87  		} else {
88  			// Validate that the service interface set is an actual interface
89  			// that exists
90  			try {
91  				if (!Class.forName(getServiceInterface()).isInterface()) {
92  					throw new ConfigurationException(
93  							"Service interface class '" + getServiceInterface() + "' must be a Java interface"); 
94  				}
95  			} catch (ClassNotFoundException e) {
96  				throw new ConfigurationException(
97  						"Service interface class '" + getServiceInterface() + "' could not be found in the classpath");
98  			}
99  		}
100 
101 	}
102 	
103 	@Override
104 	protected ServiceConfiguration configure() {
105 		return SoapServiceConfiguration.fromServiceDefinition(this);
106 	}
107 
108 	
109 }