View Javadoc

1   package org.kuali.rice.ksb.api.bus.support;
2   
3   import java.util.ArrayList;
4   import java.util.Collections;
5   import java.util.List;
6   
7   import javax.xml.bind.annotation.XmlAccessType;
8   import javax.xml.bind.annotation.XmlAccessorType;
9   import javax.xml.bind.annotation.XmlElement;
10  import javax.xml.bind.annotation.XmlElementWrapper;
11  import javax.xml.bind.annotation.XmlRootElement;
12  import javax.xml.bind.annotation.XmlType;
13  
14  @XmlRootElement(name = JavaServiceConfiguration.Constants.ROOT_ELEMENT_NAME)
15  @XmlAccessorType(XmlAccessType.NONE)
16  @XmlType(name = JavaServiceConfiguration.Constants.TYPE_NAME, propOrder = {
17  		JavaServiceConfiguration.Elements.SERVICE_INTERFACES
18  })
19  public final class JavaServiceConfiguration extends AbstractServiceConfiguration {
20  
21  	private static final long serialVersionUID = -4226512121638441108L;
22  
23  	@XmlElementWrapper(name = Elements.SERVICE_INTERFACES, required = false)
24  	@XmlElement(name = Elements.SERVICE_INTERFACE, required = false)
25  	private final List<String> serviceInterfaces;
26  	
27  	/**
28       * Private constructor used only by JAXB.
29       */
30  	private JavaServiceConfiguration() {
31  		super();
32  		this.serviceInterfaces = null;
33  	}
34  
35  	
36  	private JavaServiceConfiguration(Builder builder) {
37  		super(builder);
38  		this.serviceInterfaces = builder.getServiceInterfaces() == null ? null : new ArrayList<String>(builder.getServiceInterfaces());
39  	}
40  	
41  	public static JavaServiceConfiguration fromServiceDefinition(JavaServiceDefinition javaServiceDefinition) {
42  		return Builder.create(javaServiceDefinition).build();
43  	}
44  		
45  	public List<String> getServiceInterfaces() {
46  		if (this.serviceInterfaces == null) {
47  			return Collections.emptyList();
48  		}
49  		return Collections.unmodifiableList(this.serviceInterfaces);
50  	}
51  		
52  	public static final class Builder extends AbstractServiceConfiguration.Builder<JavaServiceConfiguration> {
53  
54  		private static final long serialVersionUID = 4300659121377259098L;
55  
56  		private List<String> serviceInterfaces;
57  				
58  		public List<String> getServiceInterfaces() {
59  			return serviceInterfaces;
60  		}
61  		
62  		public void setServiceInterfaces(List<String> serviceInterfaces) {
63  			if (serviceInterfaces == null) {
64  				this.serviceInterfaces = null;
65  			} else {
66  				this.serviceInterfaces = new ArrayList<String>(serviceInterfaces);
67  			}
68  		}
69  		
70  		private Builder() {}
71  		
72  		public static Builder create() {
73  			return new Builder();
74  		}
75  		
76  		public static Builder create(JavaServiceDefinition javaServiceDefinition) {
77  			Builder builder = create();
78  			builder.copyServiceDefinitionProperties(javaServiceDefinition);
79  			builder.setServiceInterfaces(javaServiceDefinition.getServiceInterfaces());
80  			return builder;
81  		}
82  
83  		@Override
84  		public JavaServiceConfiguration build() {
85  			return new JavaServiceConfiguration(this);
86  		}
87  		
88  	}
89  	
90  	/**
91       * Defines some internal constants used on this class.
92       */
93      static class Constants {
94      	final static String ROOT_ELEMENT_NAME = "javaServiceConfiguration";
95          final static String TYPE_NAME = "JavaServiceConfigurationType";
96      }
97  
98      /**
99       * A private class which exposes constants which define the XML element names to use
100      * when this object is marshalled to XML.
101      */
102     static class Elements {
103     	protected final static String SERVICE_INTERFACES = "serviceInterfaces";
104     	protected final static String SERVICE_INTERFACE = "serviceInterface";
105     }
106 	
107 }