| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ServiceEndpointStatus |
|
| 2.5;2.5 | ||||
| ServiceEndpointStatus$Adapter |
|
| 2.5;2.5 |
| 1 | package org.kuali.rice.ksb.api.registry; | |
| 2 | ||
| 3 | import javax.xml.bind.annotation.XmlEnum; | |
| 4 | import javax.xml.bind.annotation.XmlEnumValue; | |
| 5 | import javax.xml.bind.annotation.XmlRootElement; | |
| 6 | import javax.xml.bind.annotation.XmlType; | |
| 7 | ||
| 8 | import org.kuali.rice.core.api.mo.common.Coded; | |
| 9 | import org.kuali.rice.core.util.jaxb.EnumStringAdapter; | |
| 10 | ||
| 11 | /** | |
| 12 | * Defines the possible statuses for a service endpoint in the KSB registry. | |
| 13 | * | |
| 14 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 15 | */ | |
| 16 | 0 | @XmlRootElement(name = "serviceEndpointStatus") |
| 17 | @XmlType(name = "ServiceEndpointStatusType") | |
| 18 | @XmlEnum | |
| 19 | public enum ServiceEndpointStatus implements Coded { | |
| 20 | ||
| 21 | /** | |
| 22 | * Indicates the service is online and available to receieve requests. | |
| 23 | */ | |
| 24 | 0 | @XmlEnumValue("A") ONLINE("A"), |
| 25 | ||
| 26 | /** | |
| 27 | * Indicates the service has been taken offline, most likely as the | |
| 28 | * result of the instance hosting the service being taken offline | |
| 29 | * (i.e. for maintenance or otherwise) | |
| 30 | */ | |
| 31 | 0 | @XmlEnumValue("I") OFFLINE("I"), |
| 32 | ||
| 33 | /** | |
| 34 | * Indicates the service has been disabled because the registry has | |
| 35 | * detected that it, or it's host instance is defective or not | |
| 36 | * processing requests properly. | |
| 37 | */ | |
| 38 | 0 | @XmlEnumValue("D") DISABLED("D"); |
| 39 | ||
| 40 | private final String code; | |
| 41 | ||
| 42 | 0 | ServiceEndpointStatus(final String code) { |
| 43 | 0 | this.code = code; |
| 44 | 0 | } |
| 45 | ||
| 46 | @Override | |
| 47 | public String getCode() { | |
| 48 | 0 | return this.code; |
| 49 | } | |
| 50 | ||
| 51 | /** | |
| 52 | * Returns the endpoint status for the given status code. This method will | |
| 53 | * return null if the given code value is null. | |
| 54 | * | |
| 55 | * @param code the code for which to locate the {@link ServiceEndpointStatus} | |
| 56 | * @return the {@link ServiceEndpointStatus} which has the given code, or null | |
| 57 | * if the given code value was null | |
| 58 | * @throws IllegalArgumentException if an endpoint status does not match the given code | |
| 59 | */ | |
| 60 | public static ServiceEndpointStatus fromCode(String code) { | |
| 61 | 0 | if (code == null) { |
| 62 | 0 | return null; |
| 63 | } | |
| 64 | 0 | for (ServiceEndpointStatus status : values()) { |
| 65 | 0 | if (status.code.equals(code)) { |
| 66 | 0 | return status; |
| 67 | } | |
| 68 | } | |
| 69 | 0 | throw new IllegalArgumentException("Failed to locate the ServiceEndpointStatus with the given code: " + code); |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * Adapts the ServiceEndpointStatus to and from a string during JAXB operations. | |
| 74 | */ | |
| 75 | 0 | static final class Adapter extends EnumStringAdapter<ServiceEndpointStatus> { |
| 76 | ||
| 77 | protected Class<ServiceEndpointStatus> getEnumClass() { | |
| 78 | 0 | return ServiceEndpointStatus.class; |
| 79 | } | |
| 80 | ||
| 81 | } | |
| 82 | ||
| 83 | } |