Class AbstractHttpRegistrySidecar<DESC extends HttpServerDescriptor, B extends HttpRegistrySidecar<DESC,B>>
java.lang.Object
org.refcodes.rest.AbstractHttpRegistrySidecar<DESC,B>
- Type Parameters:
DESC- the generic typeB- the generic type
- All Implemented Interfaces:
Configurable<HttpRegistryContext<DESC>>, Destroyable, Destroyable.DestroyAutomaton, Initializable, Initializable.InitializeAutomaton, InitializedAccessor, LifecycleComponent, LifecycleComponent.LifecycleAutomaton, LifecycleStatusAccessor, Pausable, Pausable.PauseAutomaton, Resumable, Resumable.ResumeAutomaton, RunningAccessor, Startable, Startable.StartAutomaton, Stoppable, Stoppable.StopAutomaton, AliasAccessor, AliasAccessor.AliasBuilder<B>, AliasAccessor.AliasMutator, AliasAccessor.AliasProperty, InstanceIdAccessor, InstanceIdAccessor.InstanceIdBuilder<B>, InstanceIdAccessor.InstanceIdMutator, InstanceIdAccessor.InstanceIdProperty, PortAccessor, PortAccessor.PortBuilder<B>, PortAccessor.PortMutator, PortAccessor.PortProperty, IpAddressAccessor, IpAddressAccessor.IpAddressBuilder<B>, IpAddressAccessor.IpAddressMutator, IpAddressAccessor.IpAddressProperty, HttpRegistry<DESC,B>, HttpRegistrySidecar<DESC, B>, HttpRegistryUrlAccessor, HttpRegistryUrlAccessor.HttpRegistryUrlBuilder<B>, HttpRegistryUrlAccessor.HttpRegistryUrlMutator, HttpRegistryUrlAccessor.HttpRegistryUrlProperty, HttpServerDescriptorAccessor<DESC>, HttpServerDescriptorAccessor.HttpServerDescriptorBuilder<DESC, B>, HttpServerDescriptorAccessor.HttpServerDescriptorMutator<DESC>, HttpServerDescriptorAccessor.HttpServerDescriptorProperty<DESC>, HttpServerDescriptorFactory<DESC>, PingPathAccessor, PingPathAccessor.PingPathBuilder<B>, PingPathAccessor.PingPathMutator, PingPathAccessor.PingPathProperty, TrustStoreDescriptorAccessor, TrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<B>, TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator, TrustStoreDescriptorAccessor.TrustStoreDescriptorProperty, HostAccessor, HostAccessor.HostBuilder<B>, HostAccessor.HostMutator, HostAccessor.HostProperty, SchemeAccessor, SchemeAccessor.SchemeBuilder<B>, SchemeAccessor.SchemeMutator, SchemeAccessor.SchemeProperty, VirtualHostAccessor, VirtualHostAccessor.VirtualHostBuilder<B>, VirtualHostAccessor.VirtualHostMutator, VirtualHostAccessor.VirtualHostProperty
public abstract class AbstractHttpRegistrySidecar<DESC extends HttpServerDescriptor, B extends HttpRegistrySidecar<DESC,B>>
extends Object
implements HttpRegistrySidecar<DESC,B>
Abstract class for easily decorating a
HttpRegistrySidecar.-
Nested Class Summary
Nested classes/interfaces inherited from interface AliasAccessor
AliasAccessor.AliasBuilder<B>, AliasAccessor.AliasMutator, AliasAccessor.AliasPropertyNested classes/interfaces inherited from interface Configurable
Configurable.ConfigureAutomaton<CTX>, Configurable.ConfigureBuilder<CTX,B> Nested classes/interfaces inherited from interface Destroyable
Destroyable.DestroyAutomatonNested classes/interfaces inherited from interface HostAccessor
HostAccessor.HostBuilder<B>, HostAccessor.HostMutator, HostAccessor.HostPropertyNested classes/interfaces inherited from interface HttpRegistryUrlAccessor
HttpRegistryUrlAccessor.HttpRegistryUrlBuilder<B>, HttpRegistryUrlAccessor.HttpRegistryUrlMutator, HttpRegistryUrlAccessor.HttpRegistryUrlPropertyNested classes/interfaces inherited from interface HttpServerDescriptorAccessor
HttpServerDescriptorAccessor.HttpServerDescriptorBuilder<DESC,B>, HttpServerDescriptorAccessor.HttpServerDescriptorMutator<DESC>, HttpServerDescriptorAccessor.HttpServerDescriptorProperty<DESC> Nested classes/interfaces inherited from interface Initializable
Initializable.InitializeAutomaton, Initializable.InitializeBuilder<B>, Initializable.UncheckedInitializableNested classes/interfaces inherited from interface InitializedAccessor
InitializedAccessor.InitializedMutator, InitializedAccessor.InitializedPropertyNested classes/interfaces inherited from interface InstanceIdAccessor
InstanceIdAccessor.InstanceIdBuilder<B>, InstanceIdAccessor.InstanceIdMutator, InstanceIdAccessor.InstanceIdPropertyNested classes/interfaces inherited from interface IpAddressAccessor
IpAddressAccessor.IpAddressBuilder<B>, IpAddressAccessor.IpAddressMutator, IpAddressAccessor.IpAddressPropertyNested classes/interfaces inherited from interface LifecycleComponent
LifecycleComponent.LifecycleAutomaton, LifecycleComponent.UncheckedLifecycleComponentNested classes/interfaces inherited from interface LifecycleStatusAccessor
LifecycleStatusAccessor.LifecycleStatusBuilder<B>, LifecycleStatusAccessor.LifecycleStatusMutator, LifecycleStatusAccessor.LifecycleStatusPropertyNested classes/interfaces inherited from interface Pausable
Pausable.PauseAutomaton, Pausable.PauseBuilder<B>, Pausable.UncheckedPausableNested classes/interfaces inherited from interface PingPathAccessor
PingPathAccessor.PingPathBuilder<B>, PingPathAccessor.PingPathMutator, PingPathAccessor.PingPathPropertyNested classes/interfaces inherited from interface PortAccessor
PortAccessor.PortBuilder<B>, PortAccessor.PortMutator, PortAccessor.PortPropertyNested classes/interfaces inherited from interface Resumable
Resumable.ResumeAutomaton, Resumable.ResumeBuilder<B>, Resumable.UncheckedResumableNested classes/interfaces inherited from interface RunningAccessor
RunningAccessor.RunningMutator, RunningAccessor.RunningPropertyNested classes/interfaces inherited from interface SchemeAccessor
SchemeAccessor.SchemeBuilder<B>, SchemeAccessor.SchemeMutator, SchemeAccessor.SchemePropertyNested classes/interfaces inherited from interface Startable
Startable.StartAutomaton, Startable.StartBuilder<B>, Startable.UncheckedStartableNested classes/interfaces inherited from interface Stoppable
Stoppable.StopAutomaton, Stoppable.StopBuilder<B>, Stoppable.UncheckedStoppableNested classes/interfaces inherited from interface TrustStoreDescriptorAccessor
TrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<B>, TrustStoreDescriptorAccessor.TrustStoreDescriptorMutator, TrustStoreDescriptorAccessor.TrustStoreDescriptorPropertyNested classes/interfaces inherited from interface VirtualHostAccessor
VirtualHostAccessor.VirtualHostBuilder<B>, VirtualHostAccessor.VirtualHostMutator, VirtualHostAccessor.VirtualHostProperty -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LifecycleMachine.ManualLifecycleMachineprotected RestRequestConsumer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()This server is taken (removed) from the registry server.getAlias()getHost()Retrieves the URL from the URL property locating the service registry registry.Retrieves theHttpServerDescriptorfrom theHttpServerDescriptorproperty.int[]Retrieves the ping path from the ping path property.voidInitializes theHttpRegistryby registering it at the service registry with a status such as "starting" or "initializing" or "not-ready-yet".booleanbooleanbooleanbooleanbooleanbooleanisPaused()booleanbooleanbooleanbooleanbooleanvoidpause()Some "deactivated" status is communicated to the registry server.voidresume()Some "up-and-running (again)" status is communicated to the registry server.voidvoidvoidsetHttpRegistryUrl(Url aRegistryUrl) Sets the URL for the URL property locating the service registry registry.voidsetHttpServerDescriptor(DESC aServerDescriptor) Sets theHttpServerDescriptorfor theHttpServerDescriptorproperty.voidsetInstanceId(String aInstanceId) voidsetIpAddress(int[] aIpAddress) voidsetPingPath(String aPingPath) Sets the ping path for the ping path property.voidsetTrustStoreDescriptor(TrustStoreDescriptor aTrustStoreDescriptor) voidsetVirtualHost(String aVirtualHost) voidstart()Some "up-and-running" status is communicated to the registry server.voidstop()Some "out-of-order" status is communicated to the registry server.protected static StringtoAlias(String aAlias, AliasAccessor.AliasProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static StringtoHost(String aHost, HostAccessor.HostProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static UrltoHttpRegistryUrl(Url aRegistryUrl, HttpRegistryUrlAccessor.HttpRegistryUrlProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static <DESC extends HttpServerDescriptor>
DESCtoHttpServerDescriptor(DESC aServerDescriptor, HttpServerDescriptorAccessor.HttpServerDescriptorProperty<DESC> aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static StringtoInstanceId(String aInstanceId, String aHost, InstanceIdAccessor.InstanceIdProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static int[]toIpAddress(int[] aIpAddress, IpAddressAccessor.IpAddressProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static StringtoPingPath(String aPingPath, String aDefaultPingPath, PingPathAccessor.PingPathProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static inttoPort(int aPort, PortAccessor.PortProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static SchemetoScheme(Scheme aScheme, SchemeAccessor.SchemeProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static TrustStoreDescriptortoTrustStoreDescriptor(TrustStoreDescriptor aStoreDescriptor, TrustStoreDescriptorAccessor.TrustStoreDescriptorProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.protected static StringtoVirtualHost(String aVirtualHost, VirtualHostAccessor.VirtualHostProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AliasAccessor.AliasProperty
letAliasMethods inherited from interface Configurable
initializeUncheckedMethods inherited from interface HostAccessor.HostProperty
letHostMethods inherited from interface HttpRegistry
initialize, initialize, initialize, initialize, initialize, initialize, initialize, withAlias, withCidrNotation, withHost, withHttpRegistryUrl, withHttpServerDescriptor, withInstanceId, withIpAddress, withPingPath, withTrustStoreDescriptor, withVirtualHostMethods inherited from interface HttpRegistrySidecar
withPort, withProtocol, withSchemeMethods inherited from interface HttpRegistryUrlAccessor.HttpRegistryUrlProperty
letHttpRegistryUrlMethods inherited from interface HttpServerDescriptorAccessor.HttpServerDescriptorProperty
letHttpServerDescriptorMethods inherited from interface HttpServerDescriptorFactory
toHttpServerDescriptor, toHttpServerDescriptor, toHttpServerDescriptor, toHttpServerDescriptor, toHttpServerDescriptorMethods inherited from interface Initializable
initializeUncheckedMethods inherited from interface InstanceIdAccessor.InstanceIdProperty
letInstanceIdMethods inherited from interface IpAddressAccessor
toCidrNotationMethods inherited from interface IpAddressAccessor.IpAddressMutator
fromCidrNotationMethods inherited from interface IpAddressAccessor.IpAddressProperty
letIpAddressMethods inherited from interface Pausable
pauseUncheckedMethods inherited from interface PingPathAccessor.PingPathProperty
letPingPathMethods inherited from interface PortAccessor
getPortMethods inherited from interface PortAccessor.PortMutator
setPortMethods inherited from interface PortAccessor.PortProperty
letPortMethods inherited from interface Resumable
resumeUncheckedMethods inherited from interface SchemeAccessor
getScheme, toProtocolMethods inherited from interface SchemeAccessor.SchemeMutator
setProtocol, setSchemeMethods inherited from interface SchemeAccessor.SchemeProperty
letProtocol, letSchemeMethods inherited from interface Startable
startUncheckedMethods inherited from interface Stoppable
stopUncheckedMethods inherited from interface TrustStoreDescriptorAccessor.TrustStoreDescriptorProperty
letTrustStoreDescriptorMethods inherited from interface VirtualHostAccessor.VirtualHostProperty
letVirtualHost
-
Field Details
-
_lifeCycleAutomaton
-
_pingRequestObserver
-
-
Constructor Details
-
AbstractHttpRegistrySidecar
public AbstractHttpRegistrySidecar()
-
-
Method Details
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceRunningAccessor
-
isInitialized
public boolean isInitialized()- Specified by:
isInitializedin interfaceInitializedAccessor
-
getLifecycleStatus
- Specified by:
getLifecycleStatusin interfaceLifecycleStatusAccessor
-
pause
Some "deactivated" status is communicated to the registry server.
- Specified by:
pausein interfaceHttpRegistry<DESC extends HttpServerDescriptor, B extends HttpRegistrySidecar<DESC,B>> - Specified by:
pausein interfacePausable- Throws:
PauseException
-
stop
Some "out-of-order" status is communicated to the registry server. Also stops a "ping" or "heartbeat" daemon.
- Specified by:
stopin interfaceHttpRegistry<DESC extends HttpServerDescriptor, B extends HttpRegistrySidecar<DESC,B>> - Specified by:
stopin interfaceStoppable- Throws:
StopException
-
start
Some "up-and-running" status is communicated to the registry server. May also start a "ping" or "heartbeat" daemon.
- Specified by:
startin interfaceHttpRegistry<DESC extends HttpServerDescriptor, B extends HttpRegistrySidecar<DESC,B>> - Specified by:
startin interfaceStartable- Throws:
StartException
-
resume
Some "up-and-running (again)" status is communicated to the registry server.
- Specified by:
resumein interfaceHttpRegistry<DESC extends HttpServerDescriptor, B extends HttpRegistrySidecar<DESC,B>> - Specified by:
resumein interfaceResumable- Throws:
ResumeException
-
initialize
Initializes theHttpRegistryby registering it at the service registry with a status such as "starting" or "initializing" or "not-ready-yet".- Specified by:
initializein interfaceHttpRegistry<DESC extends HttpServerDescriptor, B extends HttpRegistrySidecar<DESC,B>> - Specified by:
initializein interfaceInitializable- Throws:
InitializeException- the initialize exception
-
isStoppable
public boolean isStoppable()- Specified by:
isStoppablein interfaceStoppable.StopAutomaton
-
isPausable
public boolean isPausable()- Specified by:
isPausablein interfacePausable.PauseAutomaton
-
isStartable
public boolean isStartable()- Specified by:
isStartablein interfaceStartable.StartAutomaton
-
isResumable
public boolean isResumable()- Specified by:
isResumablein interfaceResumable.ResumeAutomaton
-
isStopped
public boolean isStopped()- Specified by:
isStoppedin interfaceStoppable.StopAutomaton
-
isPaused
public boolean isPaused()- Specified by:
isPausedin interfacePausable.PauseAutomaton
-
isInitalizable
public boolean isInitalizable()- Specified by:
isInitalizablein interfaceInitializable.InitializeAutomaton
-
destroy
public void destroy()This server is taken (removed) from the registry server. Also stops a "ping" or "heartbeat" daemon. Finally the connection is closed.
- Specified by:
destroyin interfaceDestroyable- Specified by:
destroyin interfaceHttpRegistry<DESC extends HttpServerDescriptor, B extends HttpRegistrySidecar<DESC,B>>
-
isDestroyable
public boolean isDestroyable()- Specified by:
isDestroyablein interfaceDestroyable.DestroyAutomaton
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable.DestroyAutomaton
-
setInstanceId
- Specified by:
setInstanceIdin interfaceInstanceIdAccessor.InstanceIdMutator
-
getInstanceId
- Specified by:
getInstanceIdin interfaceInstanceIdAccessor
-
setHost
- Specified by:
setHostin interfaceHostAccessor.HostMutator
-
getHost
- Specified by:
getHostin interfaceHostAccessor
-
getVirtualHost
- Specified by:
getVirtualHostin interfaceVirtualHostAccessor
-
setVirtualHost
- Specified by:
setVirtualHostin interfaceVirtualHostAccessor.VirtualHostMutator
-
getIpAddress
public int[] getIpAddress()- Specified by:
getIpAddressin interfaceIpAddressAccessor
-
setIpAddress
public void setIpAddress(int[] aIpAddress) - Specified by:
setIpAddressin interfaceIpAddressAccessor.IpAddressMutator
-
getTrustStoreDescriptor
- Specified by:
getTrustStoreDescriptorin interfaceTrustStoreDescriptorAccessor
-
setTrustStoreDescriptor
- Specified by:
setTrustStoreDescriptorin interfaceTrustStoreDescriptorAccessor.TrustStoreDescriptorMutator
-
getHttpServerDescriptor
Retrieves theHttpServerDescriptorfrom theHttpServerDescriptorproperty.- Specified by:
getHttpServerDescriptorin interfaceHttpServerDescriptorAccessor<DESC extends HttpServerDescriptor>- Returns:
- The
HttpServerDescriptorstored by theHttpServerDescriptorproperty.
-
setHttpServerDescriptor
Sets theHttpServerDescriptorfor theHttpServerDescriptorproperty.- Specified by:
setHttpServerDescriptorin interfaceHttpServerDescriptorAccessor.HttpServerDescriptorMutator<DESC extends HttpServerDescriptor>- Parameters:
aServerDescriptor- TheHttpServerDescriptorto be stored by theHttpServerDescriptorproperty.
-
getHttpRegistryUrl
Retrieves the URL from the URL property locating the service registry registry.- Specified by:
getHttpRegistryUrlin interfaceHttpRegistryUrlAccessor- Returns:
- The URL stored by the URL property.
-
setHttpRegistryUrl
Sets the URL for the URL property locating the service registry registry.- Specified by:
setHttpRegistryUrlin interfaceHttpRegistryUrlAccessor.HttpRegistryUrlMutator- Parameters:
aRegistryUrl- The service registry registry URL to be stored by the URL property.
-
getAlias
- Specified by:
getAliasin interfaceAliasAccessor
-
setAlias
- Specified by:
setAliasin interfaceAliasAccessor.AliasMutator
-
getPingPath
Retrieves the ping path from the ping path property.- Specified by:
getPingPathin interfacePingPathAccessor- Returns:
- The ping path stored by the ping path property.
-
setPingPath
Sets the ping path for the ping path property.- Specified by:
setPingPathin interfacePingPathAccessor.PingPathMutator- Parameters:
aPingPath- The ping path to be stored by the ping path property.
-
toHost
protected static String toHost(String aHost, HostAccessor.HostProperty aProperty) throws UnknownHostException Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aHost- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
- Throws:
UnknownHostException- thrown in case the local machine's host cannot be resolved when the provided host is null.
-
toVirtualHost
protected static String toVirtualHost(String aVirtualHost, VirtualHostAccessor.VirtualHostProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aVirtualHost- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-
toIpAddress
protected static int[] toIpAddress(int[] aIpAddress, IpAddressAccessor.IpAddressProperty aProperty) throws IOException Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aIpAddress- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
- Throws:
IOException- thrown in case the local machine's IP-Address cannot be resolved when the provided IP-Address is null.
-
toAlias
Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aAlias- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-
toScheme
Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aScheme- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-
toPort
Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aPort- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-
toInstanceId
protected static String toInstanceId(String aInstanceId, String aHost, InstanceIdAccessor.InstanceIdProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aInstanceId- The value to be used when not null.aHost- The value to be used when instance TID is null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-
toPingPath
protected static String toPingPath(String aPingPath, String aDefaultPingPath, PingPathAccessor.PingPathProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aPingPath- The value to be used when not null.aDefaultPingPath- The value to be used when the ping path is null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-
toTrustStoreDescriptor
protected static TrustStoreDescriptor toTrustStoreDescriptor(TrustStoreDescriptor aStoreDescriptor, TrustStoreDescriptorAccessor.TrustStoreDescriptorProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aStoreDescriptor- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-
toHttpRegistryUrl
protected static Url toHttpRegistryUrl(Url aRegistryUrl, HttpRegistryUrlAccessor.HttpRegistryUrlProperty aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Parameters:
aRegistryUrl- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-
toHttpServerDescriptor
protected static <DESC extends HttpServerDescriptor> DESC toHttpServerDescriptor(DESC aServerDescriptor, HttpServerDescriptorAccessor.HttpServerDescriptorProperty<DESC> aProperty) Resolves the property from the provided value and the provided property and the and sets the property in case the provided value is not null.- Type Parameters:
DESC- The type of the server discovery descriptor (the object describing your service and locating the service registry).- Parameters:
aServerDescriptor- The value to be used when not null.aProperty- The property to be used when the value is null and which is to be set when the value is not null.- Returns:
- The value when not null, else the value of the provided property.
-