@Retention(value=RUNTIME) @Target(value=METHOD) public @interface AppConfiguredAccessor
Configured
objects.
The annotated method must take a Set
as its sole method parameter and
populate it with objects containing Configured
annotations.
Note: Consider using @AppIntrospectionPoints
annotation as an alternative to this annotation. The @AppConfiguredAccessor
is useful in cases where finer grained control of which objects in application should
be scanned for @EventHandler annotations. For large application this
can improve load time, but for smaller applications using @AppIntrospectionPoints
results in less boilerplate code.
@AppHAPolicy(HAPolicy.StateReplication) public class MyApp { private class AdminCommandHandlers { @Configured("myapp.admin.gcCount", defaultValue="1") private int gcCount; @Command(name="triggerGC") public String triggerGC() { for(int i = 0; i < gcCount; i++) { System.gc(); } } } @Configured("myapp.enableAdminCommands", defaultValue="false") private boolean enableAdminCommands; private final AdminCommandHandlers adminCommandHandler = AdminCommandHandlers(); @AppConfiguredAccessor public void getConfiguredObjects(final Set<Object> objectsToConfigure) { objectsToConfigure.add(adminCommandHandler); } @AppCommandHandlerContainersAccessor public void getCommandHandlerContainers(final Set<Object> objectsToConfigure) { if(enableAdminCommands) { introspectionPoints.addAll(objectsToConfigure); } } }
Configured
,
AppIntrospectionPoints
Copyright © 2019 Neeve Research, LLC. All Rights Reserved.