Skip to content

remove lifecycle methods from Managed objects and PostConstruct/Predestroy objects from Guice #360

@jknack

Description

@jknack

Today, Guice objects that implements the org.jooby.Managed interface and/or objects that are annotated with PostConstruct/PreDestroy annotations are automatically discovered and invoked at application startup or shutdown time.

In the next release we are going to remove that from Jooby and replace it by explicit calls to onStart/onStop/managed methods.

We need this to effectively apply start/stop callbacks in the order they were defined or added it. Unfortunately, this order can't be ensure by doing this via Guice. Actual implementation was more a hack than everything else.

You shouldn't worry or care about this change bc jooby internals (including all the available modules) will be updated to the new model. Except, of course if you implement a custom org.jooby.Managed object or use custom PostConstruct/PreDestroy annotated method. In case you do, then you must follow these instructions to upgrade to the new model:

  1. If you were binding org.jooby.Managed guice objects then:
void configure(Env env, Config conf, Binder binder) {
   env.managed(new MyManaged());
}
  1. If you were binding PostConstruct/PreDestroy guice objects then:
void configure(Env env, Config conf, Binder binder) {
   env.managed(MyManaged.class);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions