[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: scoped contexts example

adrian@jboss.org do-not-reply at jboss.com
Wed Mar 21 09:07:02 EDT 2007


"tom.baeyens at jboss.com" [/quote wrote : 
  | Adrian, this might be interesting for you to have a look at before you start implementing/adding the real thing in the MC.
  | 

It's already being implemented in the MC, but I've already expressed
concerns that it is being done without reference to the use cases. :-)
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=102686

The other parts of your requirement (passing scopes under the wire)
was done last year, although it is still a very internal/mechanistic api
that needs some helpers/wrappers to make it look pretty. :-)

e.g. Your create a bean from the scoped information:

  | "Helper".createBean("name");
  | 
would translated into something like:

  | // Get the scoped metadata attached to the thread
  | MetaData scopedMetaData = MetaDataStack.peek();
  | // Get the scoped controller
  | KernelController controller = scopedMetaData.getMetaData(KernelController.class);
  | // Get the factory for the bean from this scope
  | BeanFactory factory = controller.getInstalledContext("name").getTarget();
  | // Create the bean (do all the inject wiring in the current scope, etc.
  | return factory.create()
  | 
or alternatively you can do more work yourself, e.g.

  | // Get the scoped metadata attached to the thread
  | MetaData scopedMetaData = MetaDataStack.peek();
  | // Get the wiring implementation for this context
  | MyWiring wiring = scopedMetaData.getMetaData(MyWiring.class);
  | // Do any custom wiring based on the controller and scoped metadata
  | KernelController controller = scopedMetaData.getMetaData(KernelController.class);
  | return wiring.createBean(controller, scopedMetaData);
  | 


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

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



More information about the jboss-dev-forums mailing list