On Dec 21, 2007, at 7:15 AM, wesley wrote:

> To implement a com.opensymphony.xwork2.ObjectFactory, we should  
> override
> method
>     public Object buildBean(Class clazz, Map extraContext);
> and create/obtain a bean instance of specified bean class (provided  
> by param
> "clazz").
>
> I think I may get a WebBeansContainer instance as follow
>     WebBeansContainer container = WebBeansContainer.create();
> and then use it to create/obtain bean instance.

You can treat it as:

javax.webbeans.Container container = WebBeansContainer.create();

Then use

javax.webbeans.ComponentFactory component = container.resolveByType 
(clazz);

And then

   return component.get();

(or component.create(); if you want to force a creation)

The API piece of the webbeans draft spec/implementation is sketchy by  
the way.  So it's very likely the specifics will change in the next  
version of Resin.  In other words, it's fine as a temporary bridge  
for things like structs2/xwork2.

For example, the spec seems to define javax.webbeans.Component  
instead of ComponentFactory, but that conflicts with the  
@javax.webbeans.Component annotation.   In other words, the spec  
can't possibly be correct.

The annotations and <bean>/<component> are solid.  It's just the API  
that's a bit of a mess.

-- Scott
>
> How could I do this?
>
> ----- Original Message -----
> From: "wesley" <[EMAIL PROTECTED]>
> To: "General Discussion for the Resin application server"
> <resin-interest@caucho.com>
> Sent: Friday, December 21, 2007 8:06 PM
> Subject: [Resin-interest] How Resin/Ioc used for struts2/ 
> xwork2,need an
> ObjectFactory implementation
>
>
>> I'm using Struts2 in nearly every new projects these days, with  
>> Guice as
>> the
>> IoC injector.
>> I want to switch to Resin's WebBeans implementation and Resin/IoC.
>> One of the main concerns is that I could not figure out how to  
>> write a
>> ObjectFactory implementation using
>> Resin/IoC/WebBeans infrastucture, like Guice/Spring did.
>>
>> Could anyone provide me an example or some instructions/tips for  
>> me to
>> follow?
>> Thanks very much.
>>
>> Wesley
>
>
>
> _______________________________________________
> resin-interest mailing list
> resin-interest@caucho.com
> http://maillist.caucho.com/mailman/listinfo/resin-interest



_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to