-
Notifications
You must be signed in to change notification settings - Fork 31
io microsphere spring cloud client service registry aspect EventPublishingRegistrationAspect
Type: Class | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.client.service.registry.aspect | Since: 1.0.0
Event-Publishing Aspect for Registration.
public class EventPublishingRegistrationAspect implements ApplicationContextAwareAuthor: Mercy
-
Introduced in:
1.0.0 -
Current Project Version:
0.2.9-SNAPSHOT
This component is tested and compatible with the following Java versions:
| Java Version | Status |
|---|---|
| Java 17 | ✅ Compatible |
| Java 21 | ✅ Compatible |
| Java 25 | ✅ Compatible |
// This advice is triggered automatically when ServiceRegistry.register() is called:
serviceRegistry.register(registration);
// A RegistrationPreRegisteredEvent is published before the actual registration// This advice is triggered automatically when ServiceRegistry.deregister() is called:
serviceRegistry.deregister(registration);
// A RegistrationPreDeregisteredEvent is published before the actual deregistration// This advice is triggered automatically after ServiceRegistry.register() completes:
serviceRegistry.register(registration);
// A RegistrationRegisteredEvent is published after the actual registration// This advice is triggered automatically after ServiceRegistry.deregister() completes:
serviceRegistry.deregister(registration);
// A RegistrationDeregisteredEvent is published after the actual deregistration// Called automatically by Spring's ApplicationContextAware callback:
aspect.setApplicationContext(applicationContext);Add the following dependency to your pom.xml:
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-spring-cloud-commons</artifactId>
<version>${microsphere-spring-cloud.version}</version>
</dependency>Tip: Use the BOM (
microsphere-spring-cloud-dependencies) for consistent version management. See the Getting Started guide.
import io.microsphere.spring.cloud.client.service.registry.aspect.EventPublishingRegistrationAspect;| Method | Description |
|---|---|
beforeRegister |
The pointcut expression for ServiceRegistry#register(Registration). |
beforeDeregister |
AOP advice executed before ServiceRegistry#deregister(Registration), publishing a |
afterRegister |
AOP advice executed after ServiceRegistry#register(Registration), publishing a |
afterDeregister |
AOP advice executed after ServiceRegistry#deregister(Registration), publishing a |
setApplicationContext |
Sets the ApplicationContext used to publish registration events and |
public void beforeRegister(ServiceRegistry registry, Registration registration)The pointcut expression for ServiceRegistry#register(Registration).
/
public static final String REGISTER_POINTCUT_EXPRESSION = "execution(* org.springframework.cloud.client.serviceregistry.ServiceRegistry.register(*)) && target(registry) && args(registration)";
/**
The pointcut expression for ServiceRegistry#deregister(Registration).
/
public static final String DEREGISTER_POINTCUT_EXPRESSION = "execution(* org.springframework.cloud.client.serviceregistry.ServiceRegistry.deregister(*)) && target(registry) && args(registration)";
private ApplicationContext context;
private ObjectProvider registrationCustomizers;
/**
AOP advice executed before ServiceRegistry#register(Registration), publishing a
RegistrationPreRegisteredEvent and applying RegistrationCustomizer customizations.
Example Usage:
`// This advice is triggered automatically when ServiceRegistry.register() is called: serviceRegistry.register(registration); // A RegistrationPreRegisteredEvent is published before the actual registration `
public void beforeDeregister(ServiceRegistry registry, Registration registration)AOP advice executed before ServiceRegistry#deregister(Registration), publishing a
RegistrationPreDeregisteredEvent.
Example Usage:
`// This advice is triggered automatically when ServiceRegistry.deregister() is called: serviceRegistry.deregister(registration); // A RegistrationPreDeregisteredEvent is published before the actual deregistration `
public void afterRegister(ServiceRegistry registry, Registration registration)AOP advice executed after ServiceRegistry#register(Registration), publishing a
RegistrationRegisteredEvent.
Example Usage:
`// This advice is triggered automatically after ServiceRegistry.register() completes: serviceRegistry.register(registration); // A RegistrationRegisteredEvent is published after the actual registration `
public void afterDeregister(ServiceRegistry registry, Registration registration)AOP advice executed after ServiceRegistry#deregister(Registration), publishing a
RegistrationDeregisteredEvent.
Example Usage:
`// This advice is triggered automatically after ServiceRegistry.deregister() completes: serviceRegistry.deregister(registration); // A RegistrationDeregisteredEvent is published after the actual deregistration `
public void setApplicationContext(ApplicationContext applicationContext)Sets the ApplicationContext used to publish registration events and
to look up RegistrationCustomizer instances.
Example Usage:
`// Called automatically by Spring's ApplicationContextAware callback: aspect.setApplicationContext(applicationContext); `
RegistrationPreRegisteredEventRegistrationRegisteredEventRegistrationPreDeregisteredEventRegistrationDeregisteredEvent
This documentation was auto-generated from the source code of microsphere-spring-cloud.
spring-cloud-commons
- AbstractServiceRegistrationEndpoint
- CommonsPropertyConstants
- ConditionalOnAutoServiceRegistrationEnabled
- ConditionalOnFeaturesEnabled
- ConditionalOnLoadBalancerEnabled
- ConditionalOnMultipleRegistrationEnabled
- ConditionalOnUtilEnabled
- DefaultRegistration
- DiscoveryClientAutoConfiguration
- DiscoveryClientConstants
- DiscoveryUtils
- EventPublishingRegistrationAspect
- FaultTolerancePropertyConstants
- InMemoryServiceRegistry
- InstanceConstants
- LoadBalancerUtils
- MultipleAutoServiceRegistration
- MultipleRegistration
- MultipleServiceRegistry
- ReactiveDiscoveryClientAdapter
- ReactiveDiscoveryClientAutoConfiguration
- RegistrationCustomizer
- RegistrationDeregisteredEvent
- RegistrationEvent
- RegistrationMetaData
- RegistrationPreDeregisteredEvent
- RegistrationPreRegisteredEvent
- RegistrationRegisteredEvent
- ServiceDeregistrationEndpoint
- ServiceInstanceUtils
- ServiceInstancesChangedEvent
- ServiceRegistrationEndpoint
- ServiceRegistrationEndpointAutoConfiguration
- ServiceRegistryAutoConfiguration
- SimpleAutoServiceRegistration
- SimpleAutoServiceRegistrationAutoConfiguration
- SimpleServiceRegistry
- SpecificationAutoConfiguration
- SpecificationBeanPostProcessor
- SpecificationCustomizer
- SpringCloudPropertyConstants
- TomcatDynamicConfigurationListener
- TomcatFaultToleranceAutoConfiguration
- UnionDiscoveryClient
- WebFluxServiceRegistryAutoConfiguration
- WebMvcServiceRegistryAutoConfiguration
- WebServiceRegistryAutoConfiguration
- WeightedRoundRobin
spring-cloud-openfeign
- AutoRefreshCapability
- AutoRefreshCapabilityCustomizer
- CompositedRequestInterceptor
- DecoratedContract
- DecoratedDecoder
- DecoratedEncoder
- DecoratedErrorDecoder
- DecoratedFeignComponent
- DecoratedQueryMapEncoder
- DecoratedRetryer
- EnableFeignAutoRefresh
- FeignAutoConfiguration
- FeignClientAutoRefreshAutoConfiguration
- FeignClientConfigurationChangedListener
- FeignComponentRegistry
- NoOpRequestInterceptor
- Refreshable