Class AutoRegistration
- java.lang.Object
-
- io.micronaut.discovery.registration.AutoRegistration
-
- All Implemented Interfaces:
io.micronaut.context.event.ApplicationEventListener<AbstractServiceInstanceEvent>,java.util.EventListener
public abstract class AutoRegistration extends java.lang.Object implements io.micronaut.context.event.ApplicationEventListener<AbstractServiceInstanceEvent>
A base class for classes that automatically register the server with discovery services.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.LoggerLOGprotected java.util.concurrent.atomic.AtomicBooleanregistered
-
Constructor Summary
Constructors Modifier Constructor Description protectedAutoRegistration(RegistrationConfiguration registrationConfiguration)Initialize given configurations.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidderegister(ServiceInstance instance)Deregister theServiceInstancefrom service discovery services.voidonApplicationEvent(AbstractServiceInstanceEvent event)protected abstract voidpulsate(ServiceInstance instance, HealthStatus status)This method will be invoked each time aHeartbeatEventoccurs allowing the implementation to perform any necessary callbacks to the service discovery server.protected abstract voidregister(ServiceInstance instance)Register theServiceInstancewith discovery services.protected voidvalidateApplicationName(java.lang.String name)Validate the given application name.protected voidvalidateName(java.lang.String name, java.lang.String typeDescription)Validate the given application name.
-
-
-
Constructor Detail
-
AutoRegistration
protected AutoRegistration(RegistrationConfiguration registrationConfiguration)
Initialize given configurations.- Parameters:
registrationConfiguration- Common configurations for registration
-
-
Method Detail
-
onApplicationEvent
public void onApplicationEvent(AbstractServiceInstanceEvent event)
- Specified by:
onApplicationEventin interfaceio.micronaut.context.event.ApplicationEventListener<AbstractServiceInstanceEvent>
-
pulsate
protected abstract void pulsate(ServiceInstance instance, HealthStatus status)
This method will be invoked each time aHeartbeatEventoccurs allowing the implementation to perform any necessary callbacks to the service discovery server.- Parameters:
instance- The instancestatus- TheHealthStatus
-
deregister
protected abstract void deregister(ServiceInstance instance)
Deregister theServiceInstancefrom service discovery services.- Parameters:
instance- TheServiceInstance
-
register
protected abstract void register(ServiceInstance instance)
Register theServiceInstancewith discovery services.- Parameters:
instance- TheServiceInstance
-
validateApplicationName
protected void validateApplicationName(java.lang.String name)
Validate the given application name.- Parameters:
name- The application name
-
validateName
protected void validateName(java.lang.String name, java.lang.String typeDescription)Validate the given application name.- Parameters:
name- The application nametypeDescription- The detailed information about name
-
-