use of org.motechproject.mds.annotations.internal.MDSProcessorOutput in project motech by motech.
the class MdsBundleWatcher method processSingleBundle.
private void processSingleBundle(final Bundle bundle) {
SchemaHolder schemaHolder = lockAndGetSchema();
final MDSProcessorOutput output = process(bundle, schemaHolder);
if (hasNonEmptyOutput(output)) {
TransactionTemplate tmpl = new TransactionTemplate(transactionManager);
tmpl.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
schemaChangeLockManager.acquireLock(MdsBundleWatcher.class.getName() + " - saving output of bundle processing");
processAnnotationScanningResults(output);
schemaChangeLockManager.releaseLock(MdsBundleWatcher.class.getName() + " - saving output of bundle processing");
}
});
schemaHolder = lockAndGetSchema();
// if we found annotations, we will refresh the bundle in order to start weaving the
// classes it exposes
refreshBundle(bundle, schemaHolder);
}
}
use of org.motechproject.mds.annotations.internal.MDSProcessorOutput in project motech by motech.
the class MdsBundleWatcher method start.
// called by the initializer after the initial entities bundle was generated
public void start() {
LOGGER.info("Scanning for MDS annotations");
bundlesToRefresh = new ArrayList<>();
StopWatch stopWatch = new StopWatch();
SchemaHolder schemaHolder = lockAndGetSchema();
final List<MDSProcessorOutput> mdsProcessorOutputs = processInstalledBundles(schemaHolder);
stopWatch.start();
new TransactionTemplate(transactionManager).execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
schemaChangeLockManager.acquireLock(MdsBundleWatcher.class.getName() + " - start annotation processing");
for (MDSProcessorOutput output : mdsProcessorOutputs) {
processAnnotationScanningResults(output);
}
schemaChangeLockManager.releaseLock(MdsBundleWatcher.class.getName() + " - start annotation processing");
}
});
stopWatch.stop();
LOGGER.info("Annotation processing finished in {} ms", stopWatch.getTime());
// classes it exposes
if (!bundlesToRefresh.isEmpty()) {
LOGGER.info("Starting bundle refresh process");
schemaHolder = lockAndGetSchema();
LOGGER.info("Refreshing bundles: {}", bundlesToRefresh);
StopWatchHelper.restart(stopWatch);
refreshBundles(bundlesToRefresh, schemaHolder);
stopWatch.stop();
LOGGER.info("Bundle refresh finished in {} ms", stopWatch.getTime());
} else {
LOGGER.info("No bundles to refresh, proceeding");
}
bundleContext.addBundleListener(this);
}
use of org.motechproject.mds.annotations.internal.MDSProcessorOutput in project motech by motech.
the class EditableLookupsLoaderTest method prepareOutput.
private void prepareOutput() {
EntityProcessorOutput entityProcessorOutput = new EntityProcessorOutput();
entityProcessorOutput.setEntityProcessingResult(prepareEntityDto());
List<EntityProcessorOutput> entityProcessorOutputs = new ArrayList<>();
entityProcessorOutputs.add(entityProcessorOutput);
output = new MDSProcessorOutput(entityProcessorOutputs, new HashMap<>(), bundle);
}
use of org.motechproject.mds.annotations.internal.MDSProcessorOutput in project motech by motech.
the class MdsBundleWatcher method processInstalledBundles.
private List<MDSProcessorOutput> processInstalledBundles(SchemaHolder schemaHolder) {
List<MDSProcessorOutput> outputs = new ArrayList<>();
for (Bundle bundle : bundleContext.getBundles()) {
MDSProcessorOutput output = process(bundle, schemaHolder);
if (hasNonEmptyOutput(output)) {
outputs.add(output);
bundlesToRefresh.add(bundle);
}
}
return outputs;
}
Aggregations