---- Starting the Tapestry IOC Registry ---- Starting the Tapestry IOC Registry Primarily, you will use the IOC Registry as part of a Tapestry application. In those situations, the {{{../apidocs/org/apache/tapestry/TapestryFilter.html}TapestryFilter}} will be responsible for starting and stopping the registry. However, you may want to do some integration testing using the Registry from within a test case, or you may even use Tapestry IOC separately from Tapestry. Building the Registry The class {{{../apidocs/org/apache/tapestry/ioc/RegistryBuilder.html}RegistryBuilder}} is used to create a Registry. +---+ RegistryBuilder builder = new RegistryBuilder(); builder.add(AppModule.class, UtilModule.class); Registry registry = builder.build(); +---+ You may invoke add() as many times as you wish, or pass as many module classes as you wish. Using this approach, you will form a Registry containing the builtin services from the {{{../apidocs/org/apache/tapestry/ioc/services/TapestryIOCModule.html}tapestry.ioc module}}, plus the modules you explicitly list. Building the Default Registry The default registry is available by invoking the static method {{{../apidocs/org/apache/tapestry/ioc/IOCUtilities.html#buildDefaultRegistry()}IOCUtilities.buildDefaultRegistry()}}. This method builds a Registry using {{{module.html#Autoloading modules}autoloading logic}}, where modules to load are identified via a JAR Manifest entry. Shutting down the Registry The method {{{../apidocs/org/apache/tapestry/ioc/Registry.html#shutdown()}Registry.shutdown()}} will shutdown the Registry. This immediately invalidates all service proxies. Some services may have chosen to register for shutdown notification (for example, to do cleanup work such as closing a database connection). Once the Registry is shutdown, it may not be used again: it will not be possible to access services within the Registry, or invoke methods on services previously acquired. All you can do is release the Registry to the garbage collector.