View Javadoc

1   /**
2    * Copyright 2005-2013 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.util.ClassLoaderUtils;
19  import org.kuali.rice.ksb.api.KsbApiConstants;
20  import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class JavaServiceDefinition extends AbstractServiceDefinition {
29  	
30  	private List<String> serviceInterfaces = new ArrayList<String>();
31  
32  	@Override
33  	public String getType() {
34  		return KsbApiConstants.ServiceTypes.HTTP_INVOKER;
35  	}
36  	
37  	public List<String> getServiceInterfaces() {
38  		return this.serviceInterfaces;
39  	}
40  	public void setServiceInterfaces(List<String> serviceInterfaces) {
41  		this.serviceInterfaces = serviceInterfaces;
42  	}
43  	public void setServiceInterface(String serviceName) {
44  	    this.serviceInterfaces.add(serviceName);
45  	}
46  	public String getServiceInterface() {
47  		return this.serviceInterfaces.get(0);
48  	}
49  	
50  	@Override
51  	public void validate() {
52  		super.validate();
53  		if (this.serviceInterfaces == null || this.serviceInterfaces.isEmpty()) {
54  			Class<?>[] interfaces = ClassLoaderUtils.getInterfacesToProxy(getService(), null, null);
55  			for (Class<?> serviceInterfaceClass : interfaces) {
56  			    this.serviceInterfaces.add(serviceInterfaceClass.getName());
57  			}
58  		}
59  	}
60  	
61  	protected ServiceConfiguration configure() {
62  		return JavaServiceConfiguration.fromServiceDefinition(this);
63  	}
64  	
65  	/**
66       * Defines some internal constants used on this class.
67       */
68      static class Constants {
69      	final static String ROOT_ELEMENT_NAME = "javaServiceDefinition";
70          final static String TYPE_NAME = "JavaServiceDefinitionType";
71      }
72  
73      /**
74       * A private class which exposes constants which define the XML element names to use
75       * when this object is marshalled to XML.
76       */
77      protected static class Elements {
78      	protected final static String SERVICE_INTERFACES = "serviceInterfaces";
79      	protected final static String SERVICE_INTERFACE = "serviceInterface";
80      }
81  	
82  }