BatchingAuditTrail auditTrail = new BatchingAuditTrail();
auditTrail.setBatcher(batcher);
auditTrail.setDataSource(databaseData.dataSource);
auditTrail.setMessagePostProcessor(new CompressedBase64PostProcessor());
try {
auditTrail.startup();
} catch (Exception e) {
throw new RuntimeException(e);
}
PojoDependencyInjector dependyInjector = new PojoDependencyInjector();
MonitoringDataStorage monitoringDataStorage;
try {
monitoringDataStorage = new MonitoringDataStorage(File.createTempFile("test", ".tmp").getParentFile(), "copperMonitorLog");
} catch (IOException e1) {
throw new RuntimeException(e1);
}
final MonitoringDataAccessQueue monitoringQueue = new MonitoringDataAccessQueue(new MonitoringDataAccesor(monitoringDataStorage),new MonitoringDataAdder(monitoringDataStorage));
final MonitoringDataCollector monitoringDataCollector = new MonitoringDataCollector(monitoringQueue);
MonitoringDependencyInjector monitoringDependencyInjector= new MonitoringDependencyInjector(dependyInjector, monitoringDataCollector);
BillAdapterImpl billAdapterImpl = new BillAdapterImpl(monitoringDataCollector);
billAdapterImpl.initWithEngine(new MonitoringAdapterProcessingEngine(billAdapterImpl,persistentengine,monitoringDataCollector));
dependyInjector.register("billAdapter", billAdapterImpl);
dependyInjector.register("auditTrail", auditTrail);
persistentengine.setDependencyInjector(monitoringDependencyInjector);
persistentengine.startup();
try {
persistentengine.run("BillWorkflow", "");
} catch (CopperException e) {
throw new RuntimeException(e);
}
List<ProcessingEngineMXBean> engines = new ArrayList<ProcessingEngineMXBean>();
engines.add(persistentengine);
WorkflowInstanceIntrospector introspector = new WorkflowInstanceIntrospector(persistentdbStorage, wfRepository);
final MonitoringLogbackDataProvider monitoringLogbackDataProvider = new MonitoringLogbackDataProvider(monitoringDataCollector);
final MonitoringDataProviderManager monitoringDataProviderManager = new MonitoringDataProviderManager(new SystemRessourceDataProvider(monitoringDataCollector),monitoringLogbackDataProvider,new GcDataProvider(monitoringDataCollector));
monitoringDataProviderManager.startAll();
CopperMonitoringService copperMonitoringService = new DefaultCopperMonitoringService(
new MonitoringDbStorage(txnController,new DerbyMonitoringDbDialect(new StandardJavaSerializer(),new CompressedBase64PostProcessor(),auditTrail)),
runtimeStatisticsCollector,
engines,
monitoringQueue,
true,
introspector,