Overview
In an ideal world we see PicoContainer principles being applied to a lot of different container/component aspects of Java:
Servlets
Currently the servlet spec advises that a servlet should:
- Have a public empty contructor
- On instantiation, not spawn threads, or mount its own socket servers.
- Only be able to load classes distributed in its WAR file, present in the Servlet API, or J2SE (parent classloaders).
It would be quite cool, if the servlet container could determine the needs of a servlet as a component before instantiation. The servlet was allowed to get dependant component instances via one of its constructors. The need for servlet developers to break (2) above would be diminished because there is some place hier up the container tree for fatter components, that can provide services to request oriented servlets. The class visibity advice (for servlet container writers), would be relaxed too, allowing classes not supplied in the WAR file to be compiled against and delivered by the containing environment.
This may seem far fetched, but it is entirely possible given the number of Open Source Servlet containers.
Applets
As for the servlet example, it would be nice for Applet to require that their container resolves component dependencies. This rather than have to do a fairly open ended JNDI or RMI lookup of a remote service. The implemetation is a component that may have several manifestations. A RMI Remote real example is where you might be headed as you write the application In the interim, the team may code and deliver various quick win solutions - a) Hard coded fake StockQuoteService, b) some real implementation that steals data from http://quotes.nasdaq.com for display in the applet, c) some centralized/proxied version of (b), d) a MockStockQuteService for Unit testing (not withstanding the fact that AppletUnit has not been written yet).
Sadly, this remains far fetched, due to a couple of reasons:
- The dearth of Open Source Applet containers
- the marginal status of Applets since Microsoft froze support for Java in Internet Explorer at the JDK 1.1 stage.
Enterprise Java Beans
The same story as above:
Desktop Operating System
Getting pedictable now:
Yo you Eclipse guys, why'd ya have to adopt the OSGi stuff rather than CDI ?

3 Comments
Hide/Show CommentsJan 17, 2005
Archimedes Trajano
I think OSGi is language independent and the idea being why have more than one plugin framework?
Mar 18, 2005
Archimedes Trajano
To implement Nirvana for servlets, I have created PicoServlet http://cvs.sourceforge.net/viewcvs.py/twiff/twiff/twiff-core/src/java/net/trajano/twiff/internal/servlet/PicoServlet.java?view=markup which is extended by a "configuration" servlet in my case ViewServlet http://cvs.sourceforge.net/viewcvs.py/twiff/twiff/twiff-core/src/java/net/trajano/twiff/web/ViewServlet.java?view=markup and an actual implementation of the servlet which is also named ViewServlet http://cvs.sourceforge.net/viewcvs.py/twiff/twiff/twiff-core/src/java/net/trajano/twiff/internal/servlet/ViewServlet.java?view=markup in my framework.
Mar 23, 2005
Archimedes Trajano
I have separated PicoServlet into a separate project and can be downloaded independent of the framework. http://twiff.sourceforge.net/modules/picoservlet/index.html