rci.getDefinedInModule().addRunContextItem(rci);
}
}
else if (def instanceof Controller){
Controller controller = (Controller) def;
// controller.getDMO().addUsesRunContextItem("eventBus");
controllers.put(def.getCamelCaseName(), controller);
components.put(def.getCamelCaseName(), controller);
RunContextItem controllerRCI = null;
if (controller.isAddedToRunContext()){
// All Controllers run for the life of the application and so, are added to the run context
// so that they are created on start up
controllerRCI = new RunContextItem();
controllerRCI.setAutoCreated(true);
RunContextItemCollection rcic = contexts.get(controllerRCI.getContextImpl());
controllerRCI.setItemName(controller.getControllerName().getNameString() + "RCI");
controllerRCI.setDescription("The auto generated run context item for the " + controller.getControllerName());
if (controller.getSubpackage() == null)
controllerRCI.setUseClass(currentModule.getGenPackage() + ".extended." + controller.getControllerName());
else
controllerRCI.setUseClass(currentModule.getGenPackage() + ".extended." + controller.getSubpackage() + "." + controller.getControllerName());
if (controller.usesRunContext())
controllerRCI.setConstruction("new " + controller.getControllerName() + "(this)");
else
controllerRCI.setConstruction("new " + controller.getControllerName() + "()");
controllerRCI.setDefinedInModule(controller.getDefinedInModule());
if (controller.getItemOrder() != null)
controllerRCI.setItemOrder(controller.getItemOrder());
if (rcic == null){
rcic = new RunContextItemCollection(controllerRCI.getContextImpl());
contexts.put(controllerRCI.getContextImpl(), rcic);
}
rcic.addItem(controllerRCI);
// Add the item to its module
controllerRCI.getDefinedInModule().addRunContextItem(controllerRCI);
//DebugInfo.debug("\n" + rci.toOIF());
// Tell the controller its item
controller.setRunContextItem(controllerRCI);
// Add to all definitions so that references can be resolved
controllerRCI.setCamelCaseName(controllerRCI.getObjectName());
checkAndAdd(controllerRCI,allDefs);
}
if (controller.isCentralRPCErrorHandler()){
if (centralRpcErrorHandler != null){
ResultException ex = new ResultException();
ex.addError("Multiple controllers are specified as the central RPC error handler.");
ex.result.lastResult().moreMessages(centralRpcErrorHandler.getControllerName() + " in " + centralRpcErrorHandler.getDefinedInModule().getFile() + " at line " + centralRpcErrorHandler.getDefinedInModule().getLineNumber());
ex.result.lastResult().moreMessages(controller.getControllerName() + " in " + controller.getDefinedInModule().getFile() + " at line " + controller.getDefinedInModule().getLineNumber());
throw(ex);
}
centralRpcErrorHandler = controller;
}
if (controller.isCentralDMPErrorHandler()){
if (centralDmpErrorHandler != null){
ResultException ex = new ResultException();
ex.addError("Multiple controllers are specified as the central DMP error handler.");
ex.result.lastResult().moreMessages(centralDmpErrorHandler.getControllerName() + " in " + centralDmpErrorHandler.getDefinedInModule().getFile() + " at line " + centralDmpErrorHandler.getDefinedInModule().getLineNumber());
ex.result.lastResult().moreMessages(controller.getControllerName() + " in " + controller.getDefinedInModule().getFile() + " at line " + controller.getDefinedInModule().getLineNumber());
throw(ex);
}
centralDmpErrorHandler = controller;
}
if (controller.isCentralAsyncErrorHandler()){
if (centralAsyncErrorHandler != null){
ResultException ex = new ResultException();
ex.addError("Multiple controllers are specified as the central asynchronous code loading error handler.");
ex.result.lastResult().moreMessages(centralAsyncErrorHandler.getControllerName() + " in " + centralAsyncErrorHandler.getDefinedInModule().getFile() + " at line " + centralDmpErrorHandler.getDefinedInModule().getLineNumber());
ex.result.lastResult().moreMessages(controller.getControllerName() + " in " + controller.getDefinedInModule().getFile() + " at line " + controller.getDefinedInModule().getLineNumber());
throw(ex);
}
centralAsyncErrorHandler = controller;
centralAsyncErrorHandlerRCI = controllerRCI;
//