use of com.infiniteautomation.mango.util.CommonObjectMapper in project ma-core-public by infiniteautomation.
the class MockMangoLifecycle method initialize.
/**
* Startup a dummy Mango with a basic infrastructure
*/
public void initialize() {
Common.MA_HOME = System.getProperty("ma.home");
if (Common.MA_HOME == null)
Common.MA_HOME = ".";
// Add in modules
for (Module module : modules) ModuleRegistry.addModule(module);
Providers.add(IMangoLifecycle.class, this);
// TODO Licensing Providers.add(ICoreLicense.class, new CoreLicenseDefinition());
// TODO Licensing Providers.add(ITimedLicenseRegistrar.class, new TimedLicenseRegistrar());
Common.free = false;
// Startup a simulation timer provider
Providers.add(TimerProvider.class, getSimulationTimerProvider());
// Make sure that Common and other classes are properly loaded
Common.envProps = getEnvProps();
MangoRestSpringConfiguration.initializeObjectMapper();
Common.JSON_CONTEXT.addResolver(new EventTypeResolver(), EventType.class);
Common.JSON_CONTEXT.addResolver(new BaseChartRenderer.Resolver(), ChartRenderer.class);
Common.JSON_CONTEXT.addResolver(new BaseTextRenderer.Resolver(), TextRenderer.class);
Common.JSON_CONTEXT.addResolver(new EmailRecipientResolver(), EmailRecipient.class);
Common.JSON_CONTEXT.addResolver(new VirtualSerialPortConfigResolver(), VirtualSerialPortConfig.class);
Common.JSON_CONTEXT.addConverter(new MapWrapConverter(), MapWrap.class);
for (Module module : ModuleRegistry.getModules()) {
module.preInitialize(true, false);
}
// Start the Database so we can use Daos (Base Dao requires this)
if (Common.databaseProxy == null) {
Common.databaseProxy = getDatabaseProxy();
Common.databaseProxy.initialize(null);
}
// Ensure we start with the proper timer
Common.backgroundProcessing = getBackgroundProcessing();
Common.backgroundProcessing.initialize(false);
for (Module module : ModuleRegistry.getModules()) {
module.postDatabase(true, false);
}
// Utilities
// So we can add users etc.
EventType.initialize();
SystemEventType.initialize();
AuditEventType.initialize();
// Setup Common Object Mapper
Common.objectMapper = new CommonObjectMapper();
// Do this last as Event Types have listeners
for (SystemSettingsListenerDefinition def : ModuleRegistry.getSystemSettingListenerDefinitions()) def.registerListener();
// Event Manager
Common.eventManager = getEventManager();
Common.eventManager.initialize(false);
for (EventManagerListenerDefinition def : ModuleRegistry.getDefinitions(EventManagerListenerDefinition.class)) Common.eventManager.addListener(def);
Common.runtimeManager = getRuntimeManager();
Common.runtimeManager.initialize(false);
if (Common.serialPortManager == null)
Common.serialPortManager = getSerialPortManager();
for (Module module : ModuleRegistry.getModules()) {
module.postInitialize(true, false);
}
for (Runnable task : STARTUP_TASKS) {
try {
task.run();
} catch (Exception e) {
fail(e.getMessage());
}
}
}
Aggregations