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