Skip to content
Randgalt edited this page Sep 12, 2012 · 54 revisions

Yah – PostConstruct me now unt PreDestroy me later

What is Governator?

Governator is a library of extensions and utilities that extend Google Guice to provide:

  • Classpath scanning and automatic binding
  • Lifecycle management
  • Configuration to field mapping
  • Field validation
  • Parallelized object warmup/cooldown

Features

Classpath scanning and automatic binding

Governator introduces a new annotation @AutoBindSingleton. Governator will scan the Classpath to find classes annotated with AutoBindSingleton and bind them as eager Singletons.

Lifecycle management

Governator adds support for the standard annotations: @PostConstruct and @PreDestroy.

Configuration to field mapping

Governator introduces a new annotation @Configuration that can be used to annotate class fields. Governator will assign the fields using configuration from property files, etc. Another annotation is also introduced, @PreConfiguration, for methods to be called prior to configuration assignment.

Field validation

Governator supports the javax.validation annotations (JSR 303). Fields annotated with validation annotations will get validated via the Hibernate Validator library.

Parallelized object warmup/cooldown

Governator introduces two new annotations WarmUp and CoolDown. Methods annotated with WarmUp will get executed (in parallel) after injected by Guice. Methods annotated with CoolDown will get executed (in parallel) when the Governator Lifecycle is shut down.

Lazy Singletons

Governator adds a LazySingleton annotation and scope. This is the opposite of Guice’s Eager Singletons. Lazy singletons are not created until just before they are to be injected regardless of Guice’s Stage.

Requirements/Prerequisites

It’s assumed that you are familiar with Google Guice.

Acknowledgements

Governator is based on ideas developed for the Proofpoint Platform library.

Maven / Artifacts

Governator binaries are published to Maven Central.

GroupID/Org com.netflix.governator
ArtifactID/Name governator