Peter Karich
2008-04-17 12:22:29 UTC
Hi,
I am relatively new to the 'dependency injection' stuff, but I would
really like to use PicoContainer in my application to make test driven
development easier.
At the moment I use the lookup API of NetBeans, which is easy to use as
a service-locator.
Here is an example of one usage in my application:
ISerializer xs = Lookup.getDefault().lookup(ISerializer.class);
Object obj = xs.fromXML(new FileInputStream("xmlFile"));
where an implementation of ISerializer constructs an object from a xml file:
public interface ISerializer {
void toXML(Object o, OutputStream os) throws IOException;
Object fromXML(InputStream is) throws IOException;
}
to be implemented with the help of e.g. XStream.
Now my questions are:
Can I use PicoContainer as a service-locator like the Lookup API?
If yes, is it recommended to use such a replaceable singleton like the
NetBeans folks did it?
E.g.: MutablePicoContainer pico = Container.getDefault();
I am unsure to use singletons at all, because of this article:
http://www.picocontainer.org/singleton-antipattern.html
But with the singleton approach I need to configure the container only
one time e.g. on startup. Or is this the right way to do it:
http://jaxor.sourceforge.net/?q=pico
(see PicoInstanceFactory)
Regards,
Peter.
PS: Why isn't there a link on the picocontainer homepage to the mailing
list (on the left side)? And to some use cases (real world apps) or to
nanocontainer? Maybe I am to stupid to find the links ...
PSS: Which one is the latest release of PicoContainer? If 2.1 is, then
http://www.picocontainer.org/downloads.html
is out of date.
PSSS: Thanks a lot for all the work on picocontainer and of course on
nanocontainer where I can use Java to set-up the container - this is
really great. You should have mentioned them MegaContainer are sth.else ;-)
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
I am relatively new to the 'dependency injection' stuff, but I would
really like to use PicoContainer in my application to make test driven
development easier.
At the moment I use the lookup API of NetBeans, which is easy to use as
a service-locator.
Here is an example of one usage in my application:
ISerializer xs = Lookup.getDefault().lookup(ISerializer.class);
Object obj = xs.fromXML(new FileInputStream("xmlFile"));
where an implementation of ISerializer constructs an object from a xml file:
public interface ISerializer {
void toXML(Object o, OutputStream os) throws IOException;
Object fromXML(InputStream is) throws IOException;
}
to be implemented with the help of e.g. XStream.
Now my questions are:
Can I use PicoContainer as a service-locator like the Lookup API?
If yes, is it recommended to use such a replaceable singleton like the
NetBeans folks did it?
E.g.: MutablePicoContainer pico = Container.getDefault();
I am unsure to use singletons at all, because of this article:
http://www.picocontainer.org/singleton-antipattern.html
But with the singleton approach I need to configure the container only
one time e.g. on startup. Or is this the right way to do it:
http://jaxor.sourceforge.net/?q=pico
(see PicoInstanceFactory)
Regards,
Peter.
PS: Why isn't there a link on the picocontainer homepage to the mailing
list (on the left side)? And to some use cases (real world apps) or to
nanocontainer? Maybe I am to stupid to find the links ...
PSS: Which one is the latest release of PicoContainer? If 2.1 is, then
http://www.picocontainer.org/downloads.html
is out of date.
PSSS: Thanks a lot for all the work on picocontainer and of course on
nanocontainer where I can use Java to set-up the container - this is
really great. You should have mentioned them MegaContainer are sth.else ;-)
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email