tag:blogger.com,1999:blog-1306958590608174053.post8763323581659819468..comments2024-03-21T08:28:12.966+01:00Comments on Musings of a Programming Addict: Guice Tutorial part 3 – Integrating Guice with EJBAnonymoushttp://www.blogger.com/profile/16910067065508493885noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-1306958590608174053.post-248695809665145012021-02-10T10:43:53.275+01:002021-02-10T10:43:53.275+01:00our blog
our blog<a href="https://hotmailgermany.blogspot.com/2021/02/Hotmaicom%20Anmelde%20Mitsingen.html" rel="nofollow">our blog</a><br /><a href="https://hotmailgermany.wordpress.com/2021/02/03/hotmail-anmeldung-login-www-hotmail-com/" rel="nofollow">our blog</a><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-59605791418002771492010-10-19T09:08:40.492+02:002010-10-19T09:08:40.492+02:00Extremely crisp and well written article. I borrow...Extremely crisp and well written article. I borrowed this for my project. I am struggling in using this to inject into @Singleton bean annotated with @Startup. Any ideas on how to inject into these bean types? Thanks in advance.Adminhttps://www.blogger.com/profile/12025131773691993583noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-72804965907413854982010-09-27T11:21:10.364+02:002010-09-27T11:21:10.364+02:00The solution you've exposed is very elegant, b...The solution you've exposed is very elegant, but what is to be done in the situation that i don't have a @Singleton bean at hand. The solution i'm working with is based on EJB3.0 standard (Websphere 7.0) and not EJB3.1, reason why i'd like to know if there is any workaround for having guice's injector being instantiated in another manner.Marius Gramahttps://www.blogger.com/profile/16103009014533864648noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-92201076729021772812010-06-22T23:14:20.948+02:002010-06-22T23:14:20.948+02:00Günter, you could also store the language in a Thr...Günter, you could also store the language in a ThreadLocal variable and access it from there whenever needed. Just don't forget to clean up the ThreadLocal at the end of the request.Anonymoushttps://www.blogger.com/profile/16910067065508493885noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-43754958091568262872010-06-22T12:28:04.781+02:002010-06-22T12:28:04.781+02:00I wanted to have the accept-languages HTTP header ...I wanted to have the accept-languages HTTP header (from a request to a servlet) available in stateless EJBs which are called by the servlet<br />(to e.g. set properties of returned objects to localized strings).<br /><br />Because there is no request scope for EJBs I couldn't find a nice solution for that (e.g. set the language in a request scoped EJB and have this bean injected to stateless EJBs wherever the accept-language is needed).<br /><br />My unsatisfying solution is to pass accept-language as parameter through each method in the call chain.<br /><br />Guice supports request scope.<br />Do you think it is a good idea to use a request scoped (by Guice) object to hold the accept-language (initialized by the servlet) and than inject this object to statless EJBs wherever needed?<br /><br />Anyway - very helpful post.Günter Zöchbauerhttps://www.blogger.com/profile/11437488755301998747noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-60667534519501880232009-11-27T01:19:37.836+01:002009-11-27T01:19:37.836+01:00you may want to look at vtd-xml, the latest and mo...you may want to look at vtd-xml, the latest and most advanced xml processing api<br /><br /><a href="http://vtd-xml.sf.net" rel="nofollow">vtd-xml</a>anon_anonhttps://www.blogger.com/profile/14424619310452413715noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-33100242004379278102009-03-14T22:34:00.000+01:002009-03-14T22:34:00.000+01:00Hi Paweł,that sounds good. What do you think about...Hi Paweł,<BR/><BR/>that sounds good. What do you think about calling the attribute of the @UsesGuices annotation value() instead of policy()? That way one can use the shorter style when using the annotation:<BR/><BR/>@UsesGuice(InjectionPolicy.AroundInvokePolicy)<BR/><BR/>Why did you choose to use two interceptors instead of one? You could have a method annotated with @PostConstruct and one with @AroundInvoke within one class.<BR/><BR/>Greets, GunnarAnonymoushttps://www.blogger.com/profile/16910067065508493885noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-39248044578696406372009-03-14T13:50:00.000+01:002009-03-14T13:50:00.000+01:00Gunnar I made some modifications:two interceptors:...Gunnar I made some modifications:<BR/><BR/>two interceptors: AroundInvocationGuiceInterceptor and PostConstructGuiceInterceptor also @UsesGuice changed syntax accrodingly two your advise and looks like this:<BR/><BR/>@Target(ElementType.TYPE)<BR/>@Retention(RetentionPolicy.RUNTIME)<BR/>public @interface UsesGuice {<BR/> InjectionPolicy policy() default InjectionPolicy.PostConstructPolicy;<BR/>}<BR/><BR/><BR/>so defult injection is postconstruct since it will be moste used case (stateful beans will use it and stateless beans as well (does hat do not have stateful dependencies)<BR/><BR/>for the stateless beans with stateful dependencies one cane use aroundinvocation policyPawełhttps://www.blogger.com/profile/07160103602401451907noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-87154095079658916352009-03-13T17:07:00.000+01:002009-03-13T17:07:00.000+01:00@Anonymous: Thanks for pointing out that one. I've...@Anonymous: Thanks for pointing out that one. I've corrected it.Anonymoushttps://www.blogger.com/profile/16910067065508493885noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-29354333462638982522009-03-13T13:15:00.000+01:002009-03-13T13:15:00.000+01:00Hey Gunnar!Nice post, no question about it. Maybe ...Hey Gunnar!<BR/><BR/>Nice post, no question about it. Maybe you could privatize the injector in the GuiceInjectorHolderBean. From my point of view, there's no need for the package visibility.<BR/><BR/>Thx for that post!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-55557484515640348442009-03-12T22:19:00.000+01:002009-03-12T22:19:00.000+01:00"But I think this would be wrong for stateless ses...<I>"But I think this would be wrong for stateless session beans, if the injeced dependencies are stateful, as they would be shared between multiple requests to one bean."</I><BR/><BR/>I dont know.. I hardly can think of stateful dependencies in stateless bean in a real world scenario. Would that even make sens?<BR/><BR/><I>"but I am thinking about extending the @UsesGuice annotation with an attribute, that allows to specify, whether the dependencies should be injected only once or for each request"</I><BR/><BR/>hmm I guess it is a good solution. I mean we are giving the possibility for stateful dependencies in stateless bean if someone wish to have this sort of object graph.<BR/>The problem might still arise when u have one stateless session bean with two dependencies which of one is stateful and one is stateless. But in this scenario the staless dependency would have to live with the fact that it will be re-injected with each business method invocation. However it should not be a serious scalable problem, since this scenario would rarely happen in the real world.Pawełhttps://www.blogger.com/profile/07160103602401451907noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-72957362558785075432009-03-12T20:06:00.000+01:002009-03-12T20:06:00.000+01:00Hi Paweł,great - I am looking forward to you prese...Hi Paweł,<BR/><BR/>great - I am looking forward to you presentation.<BR/><BR/>I considered using the @PostConstruct callback, too. But I think this would be wrong for stateless session beans, if the injeced dependencies are stateful, as they would be shared between multiple requests to one bean.<BR/><BR/>It is another thing with stateful session beans, where exactly this behaviour might be wished. <BR/><BR/>For a beginning I decided to implement it conservative, re-injecting the dependencies with each call, but I am thinking about extending the @UsesGuice annotation with an attribute, that allows to specify, whether the dependencies should be injected only once or for each request.<BR/><BR/>Does that make sense?<BR/><BR/>Greets, GunnarAnonymoushttps://www.blogger.com/profile/16910067065508493885noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-4145024309001686962009-03-12T11:35:00.000+01:002009-03-12T11:35:00.000+01:00gunnar: wouldn't it be better to create intercepto...gunnar: wouldn't it be better to create interceptor for PostConstruct lifecycle callback? This way guice will inject memebers only one (when the creation is of the bean is done, not when each bussines method is invoked). What do you thing?Pawełhttps://www.blogger.com/profile/07160103602401451907noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-30864957509414014152009-03-10T22:16:00.000+01:002009-03-10T22:16:00.000+01:00sure thing, I will let everyone know about your bl...sure thing, I will let everyone know about your blog so be aware of upcoming webtraffic from Wroclaw in Poland :)<BR/><BR/>I will let you know when the whole presentation is ready<BR/><BR/>do you use jabber maybe? if so catch me on blackrabbit@jabber.wroc.plPawełhttps://www.blogger.com/profile/07160103602401451907noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-41402944399428199862009-03-10T20:48:00.000+01:002009-03-10T20:48:00.000+01:00Hi Paweł,great to hear, that you like the post.Fee...Hi Paweł,<BR/><BR/>great to hear, that you like the post.<BR/><BR/>Feel free to take the post as input for your JUG presentation, just recommend the audience to visit my blog :-)<BR/><BR/>Where is your JUG, maybe you can publish the slides of your presentation on the web?<BR/><BR/>I'm reading Miskos blog, too. He's writing really good stuff.<BR/><BR/>Greets, GunnarAnonymoushttps://www.blogger.com/profile/16910067065508493885noreply@blogger.comtag:blogger.com,1999:blog-1306958590608174053.post-89141482541062805072009-03-10T14:42:00.000+01:002009-03-10T14:42:00.000+01:00One of the best articles I've seen on the java-blo...One of the best articles I've seen on the java-blog-world for a long time. Taken from expreince, not keeping knowledge for yourself, very well written.<BR/><BR/>I will soon do a presentation on my local JUG about testing EJB. I am fan of http://misko.hevery.com, and it always was problem with EJB-DI since one needs to use new operators for the nonmanged objects. That resultet in code with higher test-cost. I was thinging about expreimenting with GUICE + EJB, but as always before sch experiments I used google to see if anywone else did that before. Google pointed your site :)<BR/><BR/>Hope you dont mind I will use your post in my presntaion keeping the refence.Pawełhttps://www.blogger.com/profile/07160103602401451907noreply@blogger.com