Thanks Robert. Will explore these options.

On Wednesday, May 27, 2015 at 5:55:29 PM UTC+5:30, Robert Voliva wrote:
>
> There was a good response to a similar question a couple of weeks ago:
>
> Vyacheslav Rusakov <[email protected] <javascript:>>
> May 14 (13 days ago)
> to google-guice
> If you just want spring-like @PostConstruct and @PreDestroy methods 
> support then there are many libs that implements it like 
> https://github.com/mycila/guice, https://github.com/Netflix/governator
>  etc.
> I even wrote my own https://github.com/xvik/guice-ext-annotations.
>
> But, such things are against guice philosophy: 
> https://github.com/google/guice/wiki/ModulesShouldBeFastAndSideEffectFree
> In short, you should avoid implicit bootstrap logic and do some special 
> lifecycle service with start/stop methods which should be called from 
> outside world.
> For example, in web application it could be servlet context listener which 
> will call start / stop.
>
> On Wed, May 27, 2015 at 2:25 AM, Anurag Laddha <[email protected] 
> <javascript:>> wrote:
>
>> Greetings,
>>
>> I am creating objects in my application using following approach (using 
>> @Provides): https://github.com/google/guice/wiki/ProvidesMethods
>>
>> public class SomeClassProvider extends AbstractModule {
>>
>>    @Override
>>     protected void configure(){
>>     }
>>
>>    @Provides
>>    @Singleton
>>     SomeClass getSomeClass(){
>>         //Create object of SomeClass using new SomeClass()
>>         return someClassObject;
>>     }
>> }
>>
>> I access the instance of SomeClass using 
>> injector.getInstance(SomeClass.class). 
>>
>> (I know this is not the way Guice must ideally be used. I should be 
>> injecting SomeClass wherever it is needed.
>> I am using this approach since i cannot inject non serialisable objects 
>> in the constructor of the class where SomeClass needs to be used. SomeClass 
>> may be a non serialiazable class)
>>
>> Anyways, I want to know how do i dispose instance of SomeClass when the 
>> application shutsdown?
>>
>> Thanks!
>> Anurag
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "google-guice" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/google-guice.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/google-guice/f64d007e-f4ab-4553-8b08-e5655a3dd9e2%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/google-guice/f64d007e-f4ab-4553-8b08-e5655a3dd9e2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/99dce414-b82c-442f-9c5e-c2b25e86d2e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to