Hey, so I was a bit confused before, now I am using your suggested solution - it works great and out of the box the way I want it to :) Even the feature stuff! I will build on top of that - keep up the good work! I really appreciated it!
Thanks, artur On Thu, Sep 17, 2015 at 10:10 AM, Vyacheslav Rusakov <vya...@gmail.com> wrote: > Environment and Configuration are not available in time of bundle > registration (due to initialization phase), but they are available inside > guice module (in time of guice context configuration) if module implements > (*AwareModule interfaces, e.g. EnvironmentAwareModule). > Features/Filters support was added in the last version. > > Sorry for offtopic, but I can't avoid mentioning that :) > > > I love guice philosophy "I'm DI and that's all" because it brings many > benefits. > For example, it simplifies tests because you always have just context and > could init(run) just what you need. > Usually, you have a single service/whatever_place to run all required > services which makes init process much more clear and predictable. > > четверг, 17 сентября 2015 г., 14:40:16 UTC+6 пользователь Artur kronenberg > написал: >> >> Hi, >> >> thanks for the help. The managed bean approach looks interesting. >> >> I tried guicy, however I ran into a few problems with dropwizard 0.8.4. >> * The environment and configuration is not injectable at the time the >> GuiceModule is registered >> * I couldn't register Features/Filters automatically with jersey so I >> had to do this programatically in the end as well >> >> This is the reason I went back to regular guice and simply use the >> injector in the run method to register the things I need. Other than that >> guicy was actually quite nice to use. >> >> So I think I saw guice wrong, where I expected more similarities with >> Springs lifecycle management etc. >> >> Thanks! >> >> >> On Thu, Sep 17, 2015 at 5:11 AM, Vyacheslav Rusakov <vya...@gmail.com> >> wrote: >> >>> I'm using dw Manged object to start db services and synchronize schema. >>> It's the default dw point for lifecycle-related staff. >>> Also, I wrote https://github.com/xvik/dropwizard-guicey which registers >>> managed objects for me, so I'm always on "guice side" (no direct injector >>> usage required for manual integration) >>> >>> четверг, 17 сентября 2015 г., 4:12:00 UTC+6 пользователь scl написал: >>>> >>>> Guice is a dependency injection framework. Its nothing more. >>>> >>>> The scenario 1 can be summarized as: >>>> "Run some code once at application startup." >>>> Then do it. Run the code at application startup. Don't try to make >>>> Guice run the code for you. >>>> i.e. in the dropwizard application class there is a method initialize(). >>>> >>>> For your scenario 2 you want some timer task. >>>> You won't find this in Guice. But there are extensions which provide >>>> such functionality. >>>> One would be: http://onami.apache.org/scheduler/ >>>> There are more out there. Pick the one that suits your needs best. >>>> >>>> >>>> >>>> >>>> On 09/16/2015 04:20 PM, artur.kr...@capmedia.io wrote: >>>> >>>> Hi, >>>> >>>> I am currently working with guice and dropwizard. I am NOT using the >>>> dropwizard-guice dependency since this is somewhat broken with the latest >>>> dropwizard version. Fortunatelly I found a nice tutorial explaining how to >>>> get this set up so I can use guice. I however have a few issues now, where >>>> coming from spring, I am struggling to find the alternative/best practise >>>> for it. >>>> >>>> Scenario 1: >>>> I have a bean that simply checks at startup that the schema of my >>>> database is present. I solved this by doing: >>>> >>>> @Provides @Singleton public bla() { >>>> // object >>>> // init >>>> } >>>> >>>> The issue is, that I now have to run guice in production. I am feeling >>>> that I am abusing the eager singleton creation in production and not doing >>>> the right thing here. >>>> How do I create standalone beans that get created and do some work. In >>>> spring I would create this and then call an init method on it. In guice I >>>> am not sure how to solve this. >>>> >>>> >>>> Scenario 2: >>>> Timer Tasks that are scheduled or simply threads. E.g. a Monitoring >>>> thread that gets metric in and pokes them to a reporting server once a >>>> minute. I have the same issue here, >>>> i can create the bean, but I can't call run on it. Also, if I am not in >>>> production, since the bean itself is not used anywhere, it won't get >>>> created and won't do any work. >>>> >>>> It'd be great if someone could give me some pointer for this :) >>>> >>>> Thanks, >>>> >>>> Artur >>>> -- >>>> 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 google-guice...@googlegroups.com. >>>> To post to this group, send email to google...@googlegroups.com. >>>> 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/2cf2b64e-38fb-416d-a1ff-dd56618b9b99%40googlegroups.com >>>> <https://groups.google.com/d/msgid/google-guice/2cf2b64e-38fb-416d-a1ff-dd56618b9b99%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 a topic in the >>> Google Groups "google-guice" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/google-guice/p52elK3pjrw/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> google-guice...@googlegroups.com. >>> To post to this group, send email to google...@googlegroups.com. >>> 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/1fd13f21-5a02-4eca-ad34-0a38297ac319%40googlegroups.com >>> <https://groups.google.com/d/msgid/google-guice/1fd13f21-5a02-4eca-ad34-0a38297ac319%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 a topic in the > Google Groups "google-guice" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/google-guice/p52elK3pjrw/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > google-guice+unsubscr...@googlegroups.com. > To post to this group, send email to google-guice@googlegroups.com. > 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/8d22f8cc-2131-4c06-bf37-bba3bfad300c%40googlegroups.com > <https://groups.google.com/d/msgid/google-guice/8d22f8cc-2131-4c06-bf37-bba3bfad300c%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 google-guice+unsubscr...@googlegroups.com. To post to this group, send email to google-guice@googlegroups.com. 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/CADHzgUTNdhRCm56-26DKQkfuK-6MehznCoGS%2BH3bbjOkzsuEOQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.