]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/changeset/GenericChangeListener.java
Use Logger in DependencyChanges & related mechanisms
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / changeset / GenericChangeListener.java
index a971e02ca77bd87494084f7b1d567ebd6dd9c2e1..a1d2b888ccea0b7d0d4404318acf4e8894175664 100644 (file)
@@ -19,12 +19,12 @@ import org.simantics.db.MetadataI;
 import org.simantics.db.ReadGraph;
 import org.simantics.db.Session;
 import org.simantics.db.common.procedure.adapter.TransientCacheListener;
-import org.simantics.db.common.utils.Logger;
 import org.simantics.db.event.ChangeEvent;
 import org.simantics.db.event.ChangeListener;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.request.Read;
 import org.simantics.utils.ReflectionUtils;
+import org.slf4j.LoggerFactory;
 
 /**
  * A listener added to a Session for receiving notifications for completed
@@ -43,16 +43,13 @@ abstract public class GenericChangeListener<Request, Result> implements ChangeLi
             Class<Read<Result>> clazz = ReflectionUtils.getSingleParameterTypeExtending(getClass());
             this.constructor = clazz.getConstructor(ChangeSet.class);
             return;
-        } catch (SecurityException e) {
-            Logger.defaultLogError(e);
-        } catch (NoSuchMethodException e) {
-            Logger.defaultLogError(e);
+        } catch (SecurityException | NoSuchMethodException e) {
+            LoggerFactory.getLogger(getClass()).error("Could not get constructor with param {}", ChangeSet.class.getSimpleName(), e);
+            throw new IllegalArgumentException(e);
         }
-        throw new IllegalArgumentException();
-
     }
 
-    final public void graphChanged(ChangeEvent e) throws DatabaseException {
+    public final void graphChanged(ChangeEvent e) throws DatabaseException {
 
         try {
             if (!preEventRequest())
@@ -60,14 +57,9 @@ abstract public class GenericChangeListener<Request, Result> implements ChangeLi
 
             Result event = e.getGraph().syncRequest(constructor.newInstance(e.getChanges()), TransientCacheListener.<Result>instance());
             onEvent(e.getGraph(), e.getMetadataI(), event);
-        } catch (IllegalArgumentException e1) {
-            Logger.defaultLogError(e1);
-        } catch (InstantiationException e1) {
-            Logger.defaultLogError(e1);
-        } catch (IllegalAccessException e1) {
-            Logger.defaultLogError(e1);
-        } catch (InvocationTargetException e1) {
-            Logger.defaultLogError(e1.getCause());
+        } catch (IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException ex) {
+            LoggerFactory.getLogger(getClass()).error("Could not construct new instance with {}", e.getChanges(), ex);
+            throw new DatabaseException(ex);
         }
 
     }
@@ -76,7 +68,7 @@ abstract public class GenericChangeListener<Request, Result> implements ChangeLi
      * Invoked before performing the event request with the received change
      * event and sending the result to {@link #onEvent(ReadGraph, Object)}. Can
      * be used to veto processing of an event.
-     * 
+     *
      * @return <code>true</code> if the event request shall be performed and the
      *         result sent to {@link #onEvent(ReadGraph, Object)},
      *         <code>false</code> to disable any further processing of the