* @return The test Registry
* @throws Exception
*/
public org.apache.tapestry5.ioc.Registry getOrCreateRegistry() throws Exception {
if (registry == null) {
RegistryBuilder builder = new RegistryBuilder();
if (annotation.modules() != null) {
builder.add(annotation.modules());
}
for (Method moduleDefFactory : moduleDefFactories) {
try {
org.apache.tapestry5.ioc.def.ModuleDef moduleDef =
(org.apache.tapestry5.ioc.def.ModuleDef) moduleDefFactory.invoke(null);
builder.add(moduleDef);
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof Exception) {
throw (Exception) e.getTargetException();
}
throw e;
}
}
registry = builder.build();
registry.performRegistryStartup();
}
return registry;
}