Coverage Report - org.kuali.rice.ksb.api.registry.ServiceEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceEndpoint
0%
0/13
N/A
1.5
ServiceEndpoint$1
N/A
N/A
1.5
ServiceEndpoint$Builder
0%
0/21
0%
0/6
1.5
ServiceEndpoint$Constants
0%
0/1
N/A
1.5
ServiceEndpoint$Elements
0%
0/1
N/A
1.5
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.registry;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Collection;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlRootElement;
 26  
 import javax.xml.bind.annotation.XmlType;
 27  
 
 28  
 import org.kuali.rice.core.api.CoreConstants;
 29  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 30  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 31  
 import org.w3c.dom.Element;
 32  
 
 33  
 /**
 34  
  * Immutable implementation of the {@link ServiceEndpointContract} interface.
 35  
  * Represents a service endpoint that has been published to the service registry.
 36  
  * Includes both a {@link ServiceInfo} and {@link ServiceDescriptor} which
 37  
  * compose the two different pieces of information about a service endpoint.
 38  
  * 
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 40  
  *
 41  
  */
 42  0
 @XmlRootElement(name = ServiceEndpoint.Constants.ROOT_ELEMENT_NAME)
 43  
 @XmlAccessorType(XmlAccessType.NONE)
 44  
 @XmlType(name = ServiceEndpoint.Constants.TYPE_NAME, propOrder = {
 45  
                 ServiceEndpoint.Elements.INFO,
 46  
                 ServiceEndpoint.Elements.DESCRIPTOR,
 47  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 48  
 })
 49  0
 public final class ServiceEndpoint extends AbstractDataTransferObject implements ServiceEndpointContract {
 50  
 
 51  
         private static final long serialVersionUID = -2295962329997871877L;
 52  
     
 53  
         @XmlElement(name = Elements.INFO, required = false)
 54  
     private final ServiceInfo info;
 55  
         
 56  
     @XmlElement(name = Elements.DESCRIPTOR, required = false)
 57  
     private final ServiceDescriptor descriptor;
 58  
     
 59  0
     @SuppressWarnings("unused")
 60  
     @XmlAnyElement
 61  
     private final Collection<Element> _futureElements = null;
 62  
 
 63  
     /**
 64  
      * Private constructor used only by JAXB.
 65  
      */
 66  0
     private ServiceEndpoint() {
 67  0
         this.info = null;
 68  0
             this.descriptor = null;
 69  0
     }
 70  
     
 71  0
     private ServiceEndpoint(Builder builder) {
 72  0
         this.info = builder.getInfo().build();
 73  0
         this.descriptor = builder.getDescriptor().build();
 74  0
     }
 75  
     
 76  
     @Override
 77  
     public ServiceInfo getInfo() {
 78  0
         return this.info;
 79  
     }
 80  
     
 81  
     @Override
 82  
     public ServiceDescriptor getDescriptor() {
 83  0
         return this.descriptor;
 84  
     }
 85  
 
 86  
     /**
 87  
      * A builder which can be used to construct {@link ServiceEndpoint} instances.  Enforces the constraints of the {@link ServiceEndpointContract}.
 88  
      */
 89  0
     public final static class Builder implements Serializable, ModelBuilder, ServiceEndpointContract {
 90  
 
 91  
                 private static final long serialVersionUID = -1783718474634197837L;
 92  
 
 93  
                 private ServiceInfo.Builder info;
 94  
         private ServiceDescriptor.Builder descriptor;
 95  
 
 96  0
         private Builder(ServiceInfo.Builder info, ServiceDescriptor.Builder descriptor) {
 97  0
             setInfo(info);
 98  0
             setDescriptor(descriptor);
 99  0
         }
 100  
 
 101  
         public static Builder create(ServiceInfo.Builder info, ServiceDescriptor.Builder descriptor) {
 102  0
             return new Builder(info, descriptor);
 103  
         }
 104  
 
 105  
         public static Builder create(ServiceEndpointContract contract) {
 106  0
             if (contract == null) {
 107  0
                 throw new IllegalArgumentException("contract was null");
 108  
             }
 109  0
             Builder builder = create(ServiceInfo.Builder.create(contract.getInfo()), ServiceDescriptor.Builder.create(contract.getDescriptor()));
 110  0
             return builder;
 111  
         }
 112  
 
 113  
         public ServiceEndpoint build() {
 114  0
             return new ServiceEndpoint(this);
 115  
         }
 116  
 
 117  
         @Override
 118  
         public ServiceInfo.Builder getInfo() {
 119  0
             return this.info;
 120  
         }
 121  
         
 122  
         @Override
 123  
         public ServiceDescriptor.Builder getDescriptor() {
 124  0
             return this.descriptor;
 125  
         }
 126  
         
 127  
         public void setInfo(ServiceInfo.Builder info) {
 128  0
             if (info == null) {
 129  0
                     throw new IllegalArgumentException("info was null");
 130  
             }
 131  0
             this.info = info;
 132  0
         }
 133  
 
 134  
         public void setDescriptor(ServiceDescriptor.Builder descriptor) {
 135  0
                 if (descriptor == null) {
 136  0
                     throw new IllegalArgumentException("descriptor was null");
 137  
             }
 138  0
             this.descriptor = descriptor;
 139  0
         }
 140  
         
 141  
     }
 142  
 
 143  
 
 144  
     /**
 145  
      * Defines some internal constants used on this class.
 146  
      */
 147  0
     static class Constants {
 148  
 
 149  
         final static String ROOT_ELEMENT_NAME = "serviceEndpoint";
 150  
         final static String TYPE_NAME = "ServiceEndpointType";
 151  
 
 152  
     }
 153  
 
 154  
 
 155  
     /**
 156  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 157  
      */
 158  0
     static class Elements {
 159  
 
 160  
         final static String INFO = "info";
 161  
         final static String DESCRIPTOR = "descriptor";
 162  
 
 163  
     }
 164  
     
 165  
 }