This content has been marked as final.
Show 2 replies
-
1. Re: scoped contexts example
adrian.brock Mar 21, 2007 9:07 AM (in response to tom.baeyens)"tom.baeyens@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);
-
2. Re: scoped contexts example
adrian.brock Mar 21, 2007 9:15 AM (in response to tom.baeyens)On the first example, you don't have to use an MC BeanFactory.
You can use anything that implements BeanMetaDataFactory to express
its dependencies (i.e. what it wants to be injected).