Package org.atmosphere.config.managed
Class AnnotatedLifecycle
java.lang.Object
org.atmosphere.config.managed.AnnotatedLifecycle
Shared lifecycle and injection support for annotated endpoint classes
(
@ManagedService, @AiEndpoint). Scans for @Ready,
@Disconnect, and @PathParam annotations,
and handles field injection via InjectableObjectFactory.-
Method Summary
Modifier and TypeMethodDescriptionstatic MethodfindMethod(Class<?> clazz, Class<? extends Annotation> annotation) Finds the first method annotated with the given annotation.static booleanhasPathParamFields(Class<?> clazz) Checks whether the class has any@PathParam-annotated fields.booleanstatic voidinjectFields(AtmosphereFramework framework, Object instance) Injects@Inject-annotated fields on the target instance at registration time using Atmosphere'sInjectableObjectFactory.voidinjectPathParams(Object target, AtmosphereResource resource, String pathTemplate, AtmosphereConfig config) Injects@PathParam-annotated fields on the target instance for the current request.voidonDisconnect(Object target, AtmosphereResourceEvent event) Invokes the@Disconnect-annotated method if present.voidonHeartbeat(Object target, AtmosphereResourceEvent event) Invokes the@Heartbeat-annotated method if present.voidonReady(Object target, AtmosphereResource resource) Invokes the@Ready-annotated method if present.static AnnotatedLifecycle
-
Method Details
-
scan
- Parameters:
clazz- the annotated endpoint class- Returns:
- an immutable lifecycle descriptor
-
onReady
Invokes the@Ready-annotated method if present. Supports signatures:(),(AtmosphereResource). -
onDisconnect
Invokes the@Disconnect-annotated method if present. Supports signatures:(),(AtmosphereResourceEvent). -
onHeartbeat
Invokes the@Heartbeat-annotated method if present. Supports signatures:(),(AtmosphereResourceEvent). -
readyMethod
-
disconnectMethod
-
heartbeatMethod
-
hasPathParams
public boolean hasPathParams() -
injectPathParams
public void injectPathParams(Object target, AtmosphereResource resource, String pathTemplate, AtmosphereConfig config) Injects@PathParam-annotated fields on the target instance for the current request. Sets the request attribute thatPathParamIntrospectorexpects, then delegates toUtils.inject(Object, Class, AtmosphereResource).- Parameters:
target- the endpoint instanceresource- the current atmosphere resourcepathTemplate- the path template (e.g."/chat/{room}")config- the atmosphere configuration
-
injectFields
Injects@Inject-annotated fields on the target instance at registration time using Atmosphere'sInjectableObjectFactory.- Parameters:
framework- the atmosphere frameworkinstance- the endpoint instance to inject into
-
findMethod
Finds the first method annotated with the given annotation. Checks all public methods (including inherited) viaClass.getMethods().- Parameters:
clazz- the class to scanannotation- the annotation to look for- Returns:
- the annotated method, or
nullif not found
-
hasPathParamFields
Checks whether the class has any@PathParam-annotated fields.- Parameters:
clazz- the class to scan- Returns:
- true if at least one field is annotated with
@PathParam
-