|
|||||
|
|||||
Get Nuts Rolling
PrepareStarting up Nuts in Java is simple.
Wire upThen, call the jfun.yan.xml.NutsProcessor class to start up: final NutsProcessor processor = new NutsProcessor(); processor.processFile("myapp_nuts.xml"); //now instantiate the components final Container container = processor.getContainer(); final TopLevelApplication app = (TopLevelApplication)container.getInstance("application"); The above code assumes that the top level application object is named "application". Of course, the naming convention is all up to you. Instantiate eagerly initialized componentsNuts support eager-initialization via the "eager-init" attribute. Any global components marked as eager-init="true" is going to be eagerly instantiated even when it is not exported by the module. The NutsProcessor.preInstantiate() method is responsible for instantiating these eager components. The simplest form to instantiate eager components is: processor.preInstantiate(); This method has other overloaded versions to allow instantiation with dependencies resolved in an alternative container. For example, we may use a container hierarchy to resolve dependencies: pocessor.preInstantiate(processor.getContainer().inherit(some_parent_container)); |
|||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||