[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Obtain Kernel from unspecified Context (Repost)

adrian@jboss.org do-not-reply at jboss.com
Fri May 16 11:07:11 EDT 2008


"ALRubinger" wrote : 
  | What are the fundamental arguments against the following construct:
  | 

* Security - if you have two kernels in the same JVM with an api
to get access to both, how do you stop one user playing with the other user's kernel?

* API - why is name appropriate?
e.g. for scoped kernels we use a scope key since the kernels are not independent
and have a structure

* An invalid assumption in your argument
anonymous wrote : 
  | However, this introduces a precondition that all POJOs with dependencies on MC Beans are installed into the MC itself. In many cases, this is not possible.
  | 

There are at least four ways to inject objects that are not managed by the MC.
1) Using a factory (the factory knows how to get a reference to the object
and it is then registered in the MC)
2) Using a value-factory (a more general approach where the object
is not registered in the MC - e.g. this can be used to inject things like system properties
or get information from an ldap server, etc.
3) Inject a locator - this is like (2) but less declartive. You inject an object
that can be used to locate the relevant object in some arbitrary way
4) Using a KernelRegistryPlugin - maps some other "namespace"s into the
MC injection namespace

* Philosophy
This isn't pure IOC. You now depend upon the API and not just that, you have
to agree a name which probably isn't going to work in some arbitrary environment.
e.g. look at the horrible hack where we locate the MBeanServer by seeing
which has a default domain of "jboss" - which isn't even necessarily unique

The kernel is only really required for specialised cases where
some component wants to manage the state of another component.
e.g. the service controller managing jmx lifecycle or the deployers
managing the deployment lifecycle
Other uses are generally hacks because you haven't thought out how to
do IOC properly.

* Summary

In general the building of such a registry is something a user can do according
their usecase. e.g. in the appserver the singleton kernel can be located using
ServiceController.getKernel(). But there's nothing to stop a web-app
creating its own kernel for its own internal use.
The retrieval/availablity of the relevant kernel(s) is best left whoever created it,
since only they know how it should be used. But this is really for "super users",
most users should use plain IOC.


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

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



More information about the jboss-dev-forums mailing list