Coverage Report - org.kuali.rice.ksb.api.bus.support.AbstractServiceConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractServiceConfiguration
77%
34/44
50%
2/4
1.073
AbstractServiceConfiguration$Builder
100%
50/50
N/A
1.073
AbstractServiceConfiguration$Constants
0%
0/1
N/A
1.073
AbstractServiceConfiguration$CredentialsTypeAdapter
100%
2/2
N/A
1.073
AbstractServiceConfiguration$Elements
0%
0/1
N/A
1.073
 
 1  
 package org.kuali.rice.ksb.api.bus.support;
 2  
 
 3  
 import org.kuali.rice.core.api.CoreConstants;
 4  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 5  
 import org.kuali.rice.core.api.security.credentials.CredentialsType;
 6  
 import org.kuali.rice.core.api.util.jaxb.EnumStringAdapter;
 7  
 import org.kuali.rice.core.api.util.jaxb.QNameAsStringAdapter;
 8  
 import org.kuali.rice.ksb.api.bus.ServiceConfiguration;
 9  
 import org.kuali.rice.ksb.api.bus.ServiceDefinition;
 10  
 import org.w3c.dom.Element;
 11  
 
 12  
 import javax.xml.bind.annotation.XmlAccessType;
 13  
 import javax.xml.bind.annotation.XmlAccessorType;
 14  
 import javax.xml.bind.annotation.XmlAnyElement;
 15  
 import javax.xml.bind.annotation.XmlElement;
 16  
 import javax.xml.bind.annotation.XmlType;
 17  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 18  
 import javax.xml.namespace.QName;
 19  
 import java.io.Serializable;
 20  
 import java.net.URL;
 21  
 import java.util.Collection;
 22  
 
 23  
 @XmlAccessorType(XmlAccessType.NONE)
 24  
 @XmlType(name = AbstractServiceConfiguration.Constants.TYPE_NAME, propOrder = {
 25  
                 AbstractServiceConfiguration.Elements.SERVICE_NAME,
 26  
                 AbstractServiceConfiguration.Elements.ENDPOINT_URL,
 27  
                 AbstractServiceConfiguration.Elements.APPLICATION_ID,
 28  
                 AbstractServiceConfiguration.Elements.SERVICE_VERSION,
 29  
                 AbstractServiceConfiguration.Elements.TYPE,
 30  
                 AbstractServiceConfiguration.Elements.QUEUE,
 31  
                 AbstractServiceConfiguration.Elements.PRIORITY,
 32  
                 AbstractServiceConfiguration.Elements.RETRY_ATTEMPTS,
 33  
                 AbstractServiceConfiguration.Elements.MILLIS_TO_LIVE,
 34  
                 AbstractServiceConfiguration.Elements.MESSAGE_EXCEPTION_HANDLER,
 35  
                 AbstractServiceConfiguration.Elements.BUS_SECURITY,
 36  
                 AbstractServiceConfiguration.Elements.CREDENTIALS_TYPE,
 37  
         CoreConstants.CommonElements.FUTURE_ELEMENTS
 38  
 })
 39  
 public abstract class AbstractServiceConfiguration extends AbstractDataTransferObject implements ServiceConfiguration {
 40  
 
 41  
         private static final long serialVersionUID = 2681595879406587302L;
 42  
 
 43  
         @XmlJavaTypeAdapter(QNameAsStringAdapter.class)
 44  
         @XmlElement(name = Elements.SERVICE_NAME, required = true)
 45  
         private final QName serviceName;
 46  
         
 47  
         @XmlElement(name = Elements.ENDPOINT_URL, required = true)
 48  
         private final URL endpointUrl;
 49  
         
 50  
         @XmlElement(name = Elements.APPLICATION_ID, required = true)
 51  
         private final String applicationId;
 52  
         
 53  
         @XmlElement(name = Elements.SERVICE_VERSION, required = true)
 54  
         private final String serviceVersion;
 55  
         
 56  
         @XmlElement(name = Elements.TYPE, required = true)
 57  
         private final String type;
 58  
         
 59  
         @XmlElement(name = Elements.QUEUE, required = false)
 60  
         private final boolean queue;
 61  
         
 62  
         @XmlElement(name = Elements.PRIORITY, required = false)
 63  
         private final Integer priority;
 64  
         
 65  
         @XmlElement(name = Elements.RETRY_ATTEMPTS, required = false)
 66  
         private final Integer retryAttempts;
 67  
         
 68  
         @XmlElement(name = Elements.MILLIS_TO_LIVE, required = false)
 69  
         private final Long millisToLive;
 70  
         
 71  
         @XmlElement(name = Elements.MESSAGE_EXCEPTION_HANDLER, required = false)
 72  
         private final String messageExceptionHandler;
 73  
         
 74  
         @XmlElement(name = Elements.BUS_SECURITY, required = false)
 75  
         private final Boolean busSecurity;
 76  
         
 77  
         @XmlJavaTypeAdapter(CredentialsTypeAdapter.class)
 78  
         @XmlElement(name = Elements.CREDENTIALS_TYPE, required = false)
 79  
         private final String credentialsType;
 80  
         
 81  27
         @SuppressWarnings("unused")
 82  
     @XmlAnyElement
 83  
     private final Collection<Element> _futureElements = null;
 84  
 
 85  
         /**
 86  
      * Constructor intended for use only by JAXB.
 87  
      */
 88  19
         protected AbstractServiceConfiguration() {
 89  19
                 this.serviceName = null;
 90  19
                 this.endpointUrl = null;
 91  19
                 this.applicationId = null;
 92  19
                 this.serviceVersion = null;
 93  19
                 this.type = null;
 94  19
                 this.queue = false;
 95  19
                 this.priority = null;
 96  19
                 this.retryAttempts = null;
 97  19
                 this.millisToLive = null;
 98  19
                 this.messageExceptionHandler = null;
 99  19
                 this.busSecurity = null;
 100  19
                 this.credentialsType = null;
 101  19
         }
 102  
         
 103  8
         protected AbstractServiceConfiguration(Builder<?> builder) {
 104  8
                 this.serviceName = builder.getServiceName();
 105  8
                 this.endpointUrl = builder.getEndpointUrl();
 106  8
                 this.applicationId = builder.getApplicationId();
 107  8
                 this.serviceVersion = builder.getServiceVersion();
 108  8
                 this.type = builder.getType();
 109  8
                 this.queue = builder.isQueue();
 110  8
                 this.priority = builder.getPriority();
 111  8
                 this.retryAttempts = builder.getRetryAttempts();
 112  8
                 this.millisToLive = builder.getMillisToLive();
 113  8
                 this.messageExceptionHandler = builder.getMessageExceptionHandler();
 114  8
                 this.busSecurity = builder.getBusSecurity();
 115  8
                 CredentialsType cred = builder.getCredentialsType();
 116  8
                 this.credentialsType = cred == null ? null : cred.name();
 117  8
         }
 118  
         
 119  
         public QName getServiceName() {
 120  3
                 return serviceName;
 121  
         }
 122  
 
 123  
         public URL getEndpointUrl() {
 124  3
                 return endpointUrl;
 125  
         }
 126  
         
 127  
         public String getApplicationId() {
 128  3
                 return applicationId;
 129  
         }
 130  
         
 131  
         public String getServiceVersion() {
 132  3
                 return serviceVersion;
 133  
         }
 134  
         
 135  
         public String getType() {
 136  0
                 return type;
 137  
         }
 138  
 
 139  
         public boolean isQueue() {
 140  0
                 return queue;
 141  
         }
 142  
 
 143  
         public Integer getPriority() {
 144  0
                 return priority;
 145  
         }
 146  
 
 147  
         public Integer getRetryAttempts() {
 148  0
                 return retryAttempts;
 149  
         }
 150  
 
 151  
         public Long getMillisToLive() {
 152  0
                 return millisToLive;
 153  
         }
 154  
 
 155  
         public String getMessageExceptionHandler() {
 156  0
                 return messageExceptionHandler;
 157  
         }
 158  
 
 159  
         public Boolean getBusSecurity() {
 160  0
                 return busSecurity;
 161  
         }
 162  
 
 163  
         public CredentialsType getCredentialsType() {
 164  0
                 if (credentialsType == null) {
 165  0
                         return null;
 166  
                 }
 167  0
                 return CredentialsType.valueOf(credentialsType);
 168  
         }
 169  
                 
 170  8
         protected static abstract class Builder<T> implements Serializable {
 171  
                 
 172  
                 private static final long serialVersionUID = -3002495884401672488L;
 173  
 
 174  
                 private QName serviceName;
 175  
                 private URL endpointUrl;
 176  
                 private String applicationId;
 177  
                 private String serviceVersion;
 178  
                 private String type;
 179  
                 private boolean queue;
 180  
                 private Integer priority;
 181  
                 private Integer retryAttempts;
 182  
                 private Long millisToLive;
 183  
                 private String messageExceptionHandler;
 184  
                 private Boolean busSecurity;
 185  
                 private CredentialsType credentialsType;
 186  
                 
 187  
                 public abstract T build();
 188  
                 
 189  
                 protected void copyServiceDefinitionProperties(ServiceDefinition serviceDefinition) {
 190  8
                         setServiceName(serviceDefinition.getServiceName());
 191  8
                         setEndpointUrl(serviceDefinition.getEndpointUrl());
 192  8
                         setApplicationId(serviceDefinition.getApplicationId());
 193  8
                         setServiceVersion(serviceDefinition.getServiceVersion());
 194  8
                         setType(serviceDefinition.getType());
 195  8
                         setQueue(serviceDefinition.isQueue());
 196  8
                         setPriority(serviceDefinition.getPriority());
 197  8
                         setRetryAttempts(serviceDefinition.getRetryAttempts());
 198  8
                         setMillisToLive(serviceDefinition.getMillisToLive());
 199  8
                         setMessageExceptionHandler(serviceDefinition.getMessageExceptionHandler());
 200  8
                         setBusSecurity(serviceDefinition.getBusSecurity());
 201  8
                         setCredentialsType(serviceDefinition.getCredentialsType());
 202  8
                 }
 203  
                 
 204  
                 public QName getServiceName() {
 205  8
                         return serviceName;
 206  
                 }
 207  
                 public void setServiceName(QName serviceName) {
 208  8
                         this.serviceName = serviceName;
 209  8
                 }
 210  
                 public URL getEndpointUrl() {
 211  8
                         return endpointUrl;
 212  
                 }
 213  
                 public void setEndpointUrl(URL endpointUrl) {
 214  8
                         this.endpointUrl = endpointUrl;
 215  8
                 }
 216  
                 public String getApplicationId() {
 217  8
                         return applicationId;
 218  
                 }
 219  
                 public void setApplicationId(String applicationId) {
 220  8
                         this.applicationId = applicationId;
 221  8
                 }
 222  
                 public String getServiceVersion() {
 223  8
                         return serviceVersion;
 224  
                 }
 225  
                 public void setServiceVersion(String serviceVersion) {
 226  8
                         this.serviceVersion = serviceVersion;
 227  8
                 }
 228  
                 public String getType() {
 229  8
                         return type;
 230  
                 }
 231  
                 public void setType(String type) {
 232  8
                         this.type = type;
 233  8
                 }
 234  
                 public boolean isQueue() {
 235  8
                         return queue;
 236  
                 }
 237  
                 public void setQueue(boolean queue) {
 238  8
                         this.queue = queue;
 239  8
                 }
 240  
                 public Integer getPriority() {
 241  8
                         return priority;
 242  
                 }
 243  
                 public void setPriority(Integer priority) {
 244  8
                         this.priority = priority;
 245  8
                 }
 246  
                 public Integer getRetryAttempts() {
 247  8
                         return retryAttempts;
 248  
                 }
 249  
                 public void setRetryAttempts(Integer retryAttempts) {
 250  8
                         this.retryAttempts = retryAttempts;
 251  8
                 }
 252  
                 public Long getMillisToLive() {
 253  8
                         return millisToLive;
 254  
                 }
 255  
                 public void setMillisToLive(Long millisToLive) {
 256  8
                         this.millisToLive = millisToLive;
 257  8
                 }
 258  
                 public String getMessageExceptionHandler() {
 259  8
                         return messageExceptionHandler;
 260  
                 }
 261  
                 public void setMessageExceptionHandler(String messageExceptionHandler) {
 262  8
                         this.messageExceptionHandler = messageExceptionHandler;
 263  8
                 }
 264  
                 public Boolean getBusSecurity() {
 265  8
                         return busSecurity;
 266  
                 }
 267  
                 public void setBusSecurity(Boolean busSecurity) {
 268  8
                         this.busSecurity = busSecurity;
 269  8
                 }
 270  
                 public CredentialsType getCredentialsType() {
 271  8
                         return credentialsType;
 272  
                 }
 273  
                 public void setCredentialsType(CredentialsType credentialsType) {
 274  8
                         this.credentialsType = credentialsType;
 275  8
                 }
 276  
                 
 277  
         }
 278  
         
 279  
     /**
 280  
      * Defines some internal constants used on this class.
 281  
      */
 282  0
     protected static class Constants {
 283  
         protected final static String TYPE_NAME = "ServiceConfigurationType";
 284  
     }
 285  
 
 286  
     /**
 287  
      * A private class which exposes constants which define the XML element names to use
 288  
      * when this object is marshalled to XML.
 289  
      */
 290  0
     protected static class Elements {
 291  
             protected final static String SERVICE_NAME = "serviceName";
 292  
             protected final static String ENDPOINT_URL = "endpointUrl";
 293  
             protected final static String APPLICATION_ID = "applicationId";
 294  
             protected final static String SERVICE_VERSION = "serviceVersion";
 295  
             protected final static String TYPE = "type";
 296  
             protected final static String QUEUE = "queue";
 297  
             protected final static String PRIORITY = "priority";
 298  
             protected final static String RETRY_ATTEMPTS = "retryAttempts";
 299  
             protected final static String MILLIS_TO_LIVE = "millisToLive";
 300  
             protected final static String MESSAGE_EXCEPTION_HANDLER = "messageExceptionHandler";
 301  
             protected final static String BUS_SECURITY = "busSecurity";
 302  
             protected final static String CREDENTIALS_TYPE = "credentialsType";
 303  
     }
 304  
     
 305  3
     static final class CredentialsTypeAdapter extends EnumStringAdapter<CredentialsType> {
 306  
                 
 307  
                 protected Class<CredentialsType> getEnumClass() {
 308  4
                         return CredentialsType.class;
 309  
                 }
 310  
                 
 311  
         }
 312  
         
 313  
 }