Skip to content
Randgalt edited this page Oct 27, 2012 · 54 revisions

Yahhh – PostConstruct me now unt PreDestroy me lay-tuh

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

Features

Classpath scanning and automatic binding

Governator introduces the annotations @AutoBindSingleton and @AutoBind. See the Auto Binding wiki for details.

Lifecycle management

Governator adds support for the standard annotations: @PostConstruct and @PreDestroy. See the Lifecycle Management wiki for details.

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. See the Configuration Mapping wiki for details.

Field validation

Governator supports the javax.validation annotations (JSR 303). Fields annotated with validation annotations will get validated via the Hibernate Validator. See the Field Validation wiki for details.

Parallelized object warmup

Governator introduces the new annotation WarmUp. Methods annotated with WarmUp will get executed (in parallel) after injected by Guice. See the Warm Up wiki for details.

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. See the Lazy Singleton wiki for details.

Generic Binding Annotations

The com.netflix.governator.annotations.binding package contains a set of generic binding annotations that you might find useful. These might be more clear and more maintainable to users than using Guice’s @Named. The full set can be found here: binding-annotations

Requirements/Prerequisites

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

Maven / Artifacts

Governator binaries are published to Maven Central.

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