I started looking at Scoped Deployments as part of some work surrounding the Spring
Deployer. To wit, this means allowing Spring-instantiated beans to be registered as MC
beans, essentially hiding their Spring nature from the rest of the application, and then
allowing them to be injected in other application-server deployed objects, most notably
EJBs. One desirable behaviour would be to allow for deploying these beans in a distinct
scope, so that they don't start polluting the whole MC bean namespace. This would be
useful in the case of EAR deployments, where the Spring-related beans would be visible
only for the current EAR, but to nobody else.
The way I am seeing the scenario working is this:
1) Every Deployment could get an associated ScopedKernelController (one ScopeKey per
Deployment).
2) A Deployer (AbstractRealDeployer) could have access to this Controller and could
deploy/register beans into it
3) This way, deployers that are supposed to create instances through a third-party managed
process (such as Spring AppContext bootstrapping, but this is really a particular case)
can register their own MC beans, and there is a certain degree of isolation between the
different deployments.
Now, one thing that I was trying to figure out was how much of this is currently supported
by the current implementation, and how much is still there to be done. So, the beginning
question is, what are the current thoughts regarding the Scoped Deployments feature, and
if there is a list of outstanding TODOs?
As much as I could figure out from the current implementation, there is the possibility of
deploying individual beans with scoping information, provided that the appropriate
annotations are added on the metadata, as well as looking them up via the
ScopeKeyLookupStrategy. However, there is no generic "deploy in XYZ scope"
operation or "get the Controller corresponding to the XYZ scope", or "get
Bean from XYZ scope". As well, every deployment gets some scope associated with it,
but I can't see this being used in any practical fashion.
Also, while injection works properly with scoping (i.e. beans will be injected into other
beans only if found in the appropriate scope), consuming scoped beans is somehow
inconsistent, in that getBean("someBean") called on a Kernel will return the
first encountered bean with a given name, defined in the global Kernel controller, or any
of its children. If there are multiple beans with the same name defined in the Kernel, in
different scopes, an arbitrary bean (first encountered) is chosen and returned.
Again, what I am looking here is:
a) some confirmation that things work in the way I described them (or some correction if
they aren't), since there is no actual documentation to accompany the code;
b) some input on the what the current thinking is wrt Scoped Deployments, and the action
items that are currently known as necessary (especially in the light of JBKERNEL-12 being
still open)
c) some input regarding the action items necessary this context. For now, what I think it
is needed is:
- on the MC side, allow for a more streamlined "deploy in context" API
(essentially wrapping the existing scoping features)
- on the jboss-deployers side, make sure that every Deployment gets an associated
ScopedKernelController and that this ScopedKernelController is available at deployment
time
- all MC-registered beans created by a deployment are created in the Scope of the
Deployment
- Kernel-aware beans that live in a particular deployment context can have access to the
Controller that corresponds to their particular scope and can consume other MC beans (if
they are visible from that particular scope)
Thanks for not giving up on reading this already ;) and I am looking forward to your
comments,
Marius
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4244152#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...