View Javadoc

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