updated logs

This commit is contained in:
Francesco Mangiacrapa 2024-01-18 16:57:17 +01:00
parent 82e8505bdc
commit 94bb1b9315
2 changed files with 59 additions and 48 deletions

View File

@ -79,7 +79,9 @@ public class CatalogueBindingPlugin extends AbstractPlugin implements Initializa
report.setStatus(Report.Status.OK); report.setStatus(Report.Status.OK);
report.putMessage("Initialized " + DESCRIPTOR.getId() + " in the " + context); report.putMessage("Initialized " + DESCRIPTOR.getId() + " in the " + context);
} catch (Exception e) { } catch (Exception e) {
throw new InitializationException("Unable to initialize " + DESCRIPTOR.getId(), e); InitializationException exc = new InitializationException("Unable to initialize " + DESCRIPTOR.getId(), e);
log.error("initInContext error: {} ", exc);
throw exc;
} }
return report; return report;
} }
@ -129,70 +131,79 @@ public class CatalogueBindingPlugin extends AbstractPlugin implements Initializa
@Override @Override
public InitializationReport init() throws InitializationException { public InitializationReport init() throws InitializationException {
log.debug("Called init"); log.debug("Called init");
// Creating all listeners InitializationReport report = null;
EventListener<ItemObserved<Project>> listenerCreated = new EventListener<ItemObserved<Project>>() { try {
// Creating all listeners
EventListener<ItemObserved<Project>> listenerCreated = new EventListener<ItemObserved<Project>>() {
@Override @Override
public void updated(ItemObserved<Project> observerd) { public void updated(ItemObserved<Project> observerd) {
log.info("listenerCreated fired on item: {} " + observerd); log.info("listenerCreated fired on item: {} " + observerd);
boolean subscribed = checkIfSubscribedEvent(observerd); boolean subscribed = checkIfSubscribedEvent(observerd);
if (subscribed) {
doAction(observerd);
}
if (subscribed) {
doAction(observerd);
} }
};
} EventListener<ItemObserved<Project>> listenerUpdated = new EventListener<ItemObserved<Project>>() {
};
EventListener<ItemObserved<Project>> listenerUpdated = new EventListener<ItemObserved<Project>>() { @Override
public void updated(ItemObserved<Project> observerd) {
log.info("listenerUpdated fired on item: {} " + observerd);
boolean subscribed = checkIfSubscribedEvent(observerd);
@Override if (subscribed) {
public void updated(ItemObserved<Project> observerd) { doAction(observerd);
log.info("listenerUpdated fired on item: {} " + observerd); }
boolean subscribed = checkIfSubscribedEvent(observerd);
if (subscribed) {
doAction(observerd);
} }
};
} EventListener<ItemObserved<Project>> listenerDeleted = new EventListener<ItemObserved<Project>>() {
};
EventListener<ItemObserved<Project>> listenerDeleted = new EventListener<ItemObserved<Project>>() { @Override
public void updated(ItemObserved<Project> observerd) {
log.info("listenerDeleted fired on item: {} " + observerd);
boolean subscribed = checkIfSubscribedEvent(observerd);
@Override if (subscribed) {
public void updated(ItemObserved<Project> observerd) { doAction(observerd);
log.info("listenerDeleted fired on item: {} " + observerd); }
boolean subscribed = checkIfSubscribedEvent(observerd);
if (subscribed) {
doAction(observerd);
} }
} };
};
EventListener<ItemObserved<Project>> listenerLCStepPerformed = new EventListener<ItemObserved<Project>>() { EventListener<ItemObserved<Project>> listenerLCStepPerformed = new EventListener<ItemObserved<Project>>() {
@Override @Override
public void updated(ItemObserved<Project> observerd) { public void updated(ItemObserved<Project> observerd) {
log.info("listenerLCStepPerformed fired on item: {} " + observerd); log.info("listenerLCStepPerformed fired on item: {} " + observerd);
boolean subscribed = checkIfSubscribedEvent(observerd); boolean subscribed = checkIfSubscribedEvent(observerd);
if (subscribed) { if (subscribed) {
doAction(observerd); doAction(observerd);
}
} }
} };
};
// Subscribing all events // Subscribing all events
EventManager eventMngInst = EventManager.getInstance(); EventManager eventMngInst = EventManager.getInstance();
eventMngInst.subscribe(Event.PROJECT_CREATED, listenerCreated); eventMngInst.subscribe(Event.PROJECT_CREATED, listenerCreated);
eventMngInst.subscribe(Event.PROJECT_UPDATED, listenerUpdated); eventMngInst.subscribe(Event.PROJECT_UPDATED, listenerUpdated);
eventMngInst.subscribe(Event.PROJECT_DELETED, listenerDeleted); eventMngInst.subscribe(Event.PROJECT_DELETED, listenerDeleted);
eventMngInst.subscribe(Event.LIFECYCLE_STEP_PERFORMED, listenerLCStepPerformed); eventMngInst.subscribe(Event.LIFECYCLE_STEP_PERFORMED, listenerLCStepPerformed);
return new InitializationReport(Status.OK, PLUGIN_ID + " init performed"); report = new InitializationReport(Status.OK, PLUGIN_ID + " init performed");
} catch (Exception e) {
InitializationException exc = new InitializationException("Unable to initialize " + DESCRIPTOR.getId(), e);
log.error("init error: {} ", exc);
throw exc;
}
return report;
} }

View File

@ -26,10 +26,10 @@ public class PluginsReflections {
.filterInputsBy(new FilterBuilder().includePackage("org.gcube.application.cms"))); .filterInputsBy(new FilterBuilder().includePackage("org.gcube.application.cms")));
reflections.getSubTypesOf(Plugin.class).iterator().forEachRemaining(pluginClass->{ reflections.getSubTypesOf(Plugin.class).iterator().forEachRemaining(pluginClass->{
log.trace("Evaluating class {}",pluginClass); log.debug("Evaluating class {}",pluginClass);
if(!pluginClass.isInterface() && !Modifier.isAbstract(pluginClass.getModifiers())){ if(!pluginClass.isInterface() && !Modifier.isAbstract(pluginClass.getModifiers())){
try { try {
log.debug("Found implementation {} ",pluginClass); log.debug("\nFound implementation {} ",pluginClass);
Plugin plugin = pluginClass.newInstance(); Plugin plugin = pluginClass.newInstance();
log.debug("Loading {} description : {}", plugin, plugin.getDescriptor()); log.debug("Loading {} description : {}", plugin, plugin.getDescriptor());