public class LifecycleAnnotationsBundle
extends ru.vyarus.dropwizard.guice.module.context.unique.item.UniqueGuiceyBundle
PostConstruct - same as Managed.start()PostStartup - called after server startup
(dropwizard ServerLifecycleListener used)PreDestroy - same as Managed.stop()
The main intention is to replace usages of Managed beans with annotations, because
registration of managed beans requires classpath scan usage or manual extensions registration.
Annotations may be applied to any method without arguments. Annotations in super classes would also be detected. One method could have multiple annotations. Multiple methods could be annotated with the same annotation.
If bean is registered after events processing (lazy bean, created by JIT) then event methods will be process immediately after bean creation (with warnings in log).
Bundle is installed automatically using guicey bundles lookup. If you need to limit the scope of beans to search annotations on then register bundle directly with declared custom matcher. For example:
builder.bundles(new LifecycleAnnotationsBundle("package.to.apply"))
(only one instance of bundle will be used)| Constructor and Description |
|---|
LifecycleAnnotationsBundle()
Default module constructor to check annotations on all beans.
|
LifecycleAnnotationsBundle(com.google.inject.matcher.Matcher<? super com.google.inject.TypeLiteral<?>> typeMatcher)
Constructs annotation module with custom bean matcher for annotations processing.
|
LifecycleAnnotationsBundle(java.lang.String pkg)
Constructs annotation module with annotation scan limited to provided package.
|
| Modifier and Type | Method and Description |
|---|---|
void |
run(ru.vyarus.dropwizard.guice.module.installer.bundle.GuiceyEnvironment environment) |
equals, hashCodepublic LifecycleAnnotationsBundle()
public LifecycleAnnotationsBundle(java.lang.String pkg)
pkg - package to limit beans, where annotations processedpublic LifecycleAnnotationsBundle(com.google.inject.matcher.Matcher<? super com.google.inject.TypeLiteral<?>> typeMatcher)
typeMatcher - matcher to select beans for annotations processingas example matcher implementation