[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: KernelRegistryPlugins and dependencies

adrian@jboss.org do-not-reply at jboss.com
Fri Sep 7 08:13:51 EDT 2007


"adrian at jboss.org" wrote : 
  | More importantly, you don't know when the jndi binding disappears without the
  | naming events!

That is unless the you can resolve the jndi binding to a real controller context name,
i.e. update the iDependOn from "UNKNOWN" to the context name that provides it.

That's why I've always advocated doing the jndi binding via a real registry
which would know the cross reference between the context providing the binding
and its real name.


  | @JNDIBinding(name="java:/whatever")
  | public MyService {}
  | 

Where @JNDIBinding adds an advice to the controller context that registers
with the jndi registry the cross reference between the binding and real name.

Then a JNDIDependencyItem does something like:

  | public boolean isResolved()
  | {
  |    Object realName = jndiRegistry.getRealName(jndiBinding);
  |    if (realName != null) 
  |    {
  |       setIDependOn(realName);
  |       setResolved(true); 
  |    }
  |    return super.isResolved();
  | }
  | 

Now the iDependOn is set, we know when the providing service is removed
so we need to be removed/recycled.

A poor man's way to do it would be add an alias to the context that represents
the jndi binding and use the controller itself as that registry.

e.g. psuedo code

  | ControllerContext ctx = new ServiceControllerContext("jboss.jca:service=DataSourceBInding,jndiName=DefaultDS");
  | ctx.setAlias("java:/DefaultDS");
  | 

But then its more difficult to implement the hypothetical valve processing 
where you differentiate dependency injection from the public entry points.

i.e. the advice that also implements the jndi binding to the registry can
also trigger the valve advice that waits for in flight requests to finish before
allowing undeployment/stop().

But like I said, the valve advice is hypothetical. :-)

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

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



More information about the jboss-dev-forums mailing list