Hello,
thanks for the answer, Scott.
Its confusing. For example, as suggested by you:
@Singleton
public class MyFactory {
@Produces
public SearchService searchService() { ... }
}
SearchFilter implements Filter {
@Inject SearchService service;
public void doFilter(req,resp) {...}
}
}
1) I get an exception:
Can't find a bean for 'class ServiceService'
Do i need to register the MyFactory anywhere manually?
2)
I have a listener, that starts/stops the ComponentProvider (like pico) and
put/removes it into/from the servlet context.
Can MyFactory already be given the @inject ServletContext"? So that
filters/servlets can be given @inject stuff from MyFactory, that would now
implicitly depend on ServletContext?
3)
Do i really have to write explicitly, what MyFactory can produce? I have
hundreds of components in my provider, that potentially could be used.
I would like to be able to define a chain, like, look first in my own
ComponentProvider, and then maybe lookup somewhere else.
Hm. That all is very confusing. :-)
Thx
-------- Original-Nachricht --------
> Datum: Mon, 25 Feb 2013 10:53:08 -0800
> Von: Scott Ferguson <[email protected]>
> An: [email protected]
> Betreff: Re: [Resin-interest] custom component providers for injection
> On 2/24/13 2:06 PM, Olaf Krische wrote:
> > Hello,
> >
> > by the way, about injection, is there an tutorial out there on how to
> > bind custom component providers to Resin's CDI? For example, i use
> > picocontainer and i would like to have Resin ask picocontainer as well
> > (mostly singletons)
> >
> > For Jersey, which also uses Injection, i have created a bridge, so that
> > it can ask picocontainer, which is stored in the servlet context.
>
> @Produces is probably what you need. You can create a factory/bridge class
> to return CDI objects. Resin itself does this for the predefined objects.
>
> @Singleton
> public class MyFactory { // it doesn't have to be a @Singleton, but
> probably would be
> @Produces
> public static MyObject _myField; // you can use static methods
>
> @Produces
> public MyObject myBuilder() { ... } // or methods (I'd prefer methods)
> }
>
> MyFactory would need to know how to get the picocontainer objects.
>
_______________________________________________
resin-interest mailing list
[email protected]
http://maillist.caucho.com/mailman/listinfo/resin-interest