This content has been marked as final. Show 2 replies
"firstname.lastname@example.org" [/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. :-)
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:
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);
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).