question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lifecycle support

See original GitHub issue

From hani@formicary.net on March 14, 2007 09:22:31

Support for JSR-250 (javax.annotation) would also be very useful for all those people using init() methods and the list.

The mapping I think is:

@PostConstruct -> Called right after construction @Resource -> Analogous to @Inject @PreDestroy -> No concept of destruction, is there? @Generated -> Doesn’t apply

_Original issue: http://code.google.com/p/google-guice/issues/detail?id=62_

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:117 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
samebcommented, Jun 26, 2015

We have no plans of implementing lifecycle support.

You can use Guava’s Service + ServiceManager(https://github.com/google/guava/wiki/ServiceExplained) to have services with a lifecycle. The simplest way is to bind a multiset of Set<Service> and construct a ServiceManager with that set.

For things where you want to do something after creation/injection (otherwise known as provisioning), you can use a ProvisionListener (http://google.github.io/guice/api-docs/latest/javadoc/index.html?com/google/inject/spi/ProvisionListener.html, bound with Binder.bindListener).

Guice has no concept of “finishing” a scope or object, so anything where you want to do something on-destroy must be done through a separate framework that’s better suited to lifecycle management.

1reaction
gissuebotcommented, Jul 7, 2014

From crazyboblee on March 15, 2007 14:03:26

I’m inclined to lean on garbage collection for finalization logic. Or to delegate responsibility to something like OSGi.

We really need an external post-injection/pre-scoping hook. Then you could do whatever you want in a generic fashion:

  1. Call an init() method or some annotated method.
  2. Create a phantom reference to an object so you can close its resources before garbage collection when the scope goes away.
  3. Peform ad hoc injections. For example, Struts calls setters on interceptors with parameters from the config file.

Maybe something like this:

interface ProviderInterceptor<T> {   T intercept(Key<T> key, Provider<T> next);   }

Then you could apply them like this:

void bindInterceptor(Matcher<Key<…>> keyMatcher, ProviderInterceptor<…> interceptor);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Search Product and Services Lifecycle Information
Search below for a list of Microsoft commercial products and services and then select your result to find support and servicing timelines, required...
Read more >
Lifecycle Support Services | Honeywell Intelligrated
Lifecycle Support Services can take complete ownership of lifecycle management via a contractual agreement designed to achieve your defined critical business ...
Read more >
Overview - Product lifecycle - IBM Support
IBM's support lifecycle policy specifies how long support will be available for IBM products, from when the product is available for purchase to...
Read more >
Support Life Cycle Policy - Check Point Software
Check Point's Enterprise Support Lifecycle policies outline the product support guidelines for a product's lifecycle.
Read more >
Product Support Lifecycle | Micro Focus
AAI versions 1, 2, 4, 5 Extended 30 Nov 2010 Access Governance 7 Extended 30 Apr 2020 Access Manager 4 Committed 31 Jul 2023 Access Manager...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found