[jboss-user] [JBoss Seam] - Re: Injection woes

texan do-not-reply at jboss.com
Wed Aug 16 10:48:03 EDT 2006


I really have gone through the Seam Reference, but the @Unwrap and @Factory methods still confuse me.  I'm just not clear on what they do.  I think that @Factory is just an initializer method so that the first time an instance variable is accessed and is null, if there is a @Factory method it will be called.  (is that right?)

@Unwrap baffles me, though.  The description in the reference implies that if I have an @Unwrap method in a BlogService component named "blog", then whenever I reference "blog" I'm actually getting an instance of a Blog instead (I'm using an example from the tutorial).  In a later example, the @Unwrap method returns a list of BlogEntity objects, which is even stranger.

Tell me if I have this right: the "component manager pattern" is being used in the Blog example as a way to magically initialize data without explicitly doing so.  So, if I reference the component "blog", the BlogServer actually fetches the "real" component from the database and that is what is returned.  Similarly with the search: rather than the client getting a reference to the SearchService, it's actually getting a reference to the search results List.

Hmm, I think I just answered all of my questions about that.

In my original example, I think I will edit those classes that are within my project to make them Seam objects (@Name) and just move on with my life, and those outside of my project I may just subclass since they're not entity beans.

Or maybe I'll give up on my quest for the @Singleton annotation (which I still say would be really useful) and just use MyClass.getInstance().whatever().  I was mostly trying to see whether the injection hammer would be a good tool for banging the singleton nail (which turned out to be a staple and was just mangled).

However, the @Unwrap annotation is pretty slick!  Somehow I passed right over it on my initial pass through the tutorial.
 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3965493#3965493

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3965493



More information about the jboss-user mailing list