Interface ApplicationInfo
public interface ApplicationInfo
Monitoring configuration of an application.
Application info instance can be injected, e.g:
@Path("resource") public static class ApplicationInfoTest { @Inject Provider<ApplicationInfo> applicationInfoProvider; @GET public String getAppName() throws InterruptedException { final ApplicationInfo applicationInfo = appInfoProvider.get(); final String name = applicationInfo.getResourceConfig().getApplicationName(); return name; } }Note usage of
Provider
to retrieve application info. Info changes over time and this will
inject the latest info. In the case of singleton resources usage of Provider
is the only way how
to inject application info that are up to date.
Application info retrieved from Jersey runtime might be mutable and thanks to it might provide inconsistent data
as not all attributes are updated in the same time. To retrieve the immutable and consistent
data the method snapshot()
should be used.- Since:
- 2.12
- Author:
- Miroslav Fuksa, Libor Kramolis
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGet registered providers available in the runtime.Get resource classes registered by the user in the current application.Get resource instances registered by the user in the current application.Get the resource config.Get the start time of the application.snapshot()
Get the immutable consistent snapshot of the application info.
-
Method Details
-
getResourceConfig
ResourceConfig getResourceConfig()Get the resource config.- Returns:
- Resource config.
-
getStartTime
Date getStartTime()Get the start time of the application.- Returns:
- Time when an application initialization has been finished.
-
getRegisteredClasses
Get resource classes registered by the user in the current application. The set contains only user resource classes and not resource classes added by Jersey or byModelProcessor
. User resources are resources that were explicitly registered by the configuration, discovered by the class path scanning or that constructs explicitly registeredprogrammatic resource
.- Returns:
- Resource user registered classes.
-
getRegisteredInstances
Get resource instances registered by the user in the current application. The set contains only user resources and not resources added by Jersey or byModelProcessor
. User resources are resources that were explicitly registered by the configuration, discovered by the class path scanning or that constructs explicitly registeredprogrammatic resource
.- Returns:
- Resource instances registered by user.
-
getProviders
Get registered providers available in the runtime. The registered providers are providers likefilters
,reader
andwriter
interceptors which are explicitly registered by configuration, or annotated by@Provider
or registered in META-INF/services. The set does not include providers that are by default built in Jersey.- Returns:
- Set of provider classes.
-
snapshot
ApplicationInfo snapshot()Get the immutable consistent snapshot of the application info. Working with snapshots might have negative performance impact as snapshot must be created but ensures consistency of data over time. However, the usage of snapshot is encouraged to avoid working with inconsistent data. Not all attributes must be updated in the same time on mutable version of info.- Returns:
- Snapshot of application info.
-