X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.services%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fservices%2Fadaption%2Freflection%2FReflectionAdapter2.java;h=42eb3d8bee0cf2cfd7fed0b8e47555665341931f;hb=refs%2Fchanges%2F15%2F3115%2F4;hp=187fc52199a390f37b68b3a48a940d20faa4d359;hpb=342a2b006b88330280060c16c2ab50374468a4c6;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java index 187fc5219..42eb3d8be 100644 --- a/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java +++ b/bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java @@ -18,12 +18,16 @@ import java.util.Arrays; import org.simantics.db.AsyncReadGraph; import org.simantics.db.Resource; import org.simantics.db.adaption.Adapter; -import org.simantics.db.common.request.AsyncReadRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.db.request.AsyncRead; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ReflectionAdapter2 implements Adapter { + private static final Logger LOGGER = LoggerFactory.getLogger(ReflectionAdapter2.class); + Constructor constructor; IDynamicAdapter2[] parameters; @@ -40,22 +44,20 @@ public class ReflectionAdapter2 implements Adapter { if(parameters.length == 0) { -// System.out.println("ReflectionAdapter2 " + ReflectionAdapter2.this); - try { procedure.execute(g, constructor.newInstance()); } catch (IllegalArgumentException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (InstantiationException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (IllegalAccessException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (InvocationTargetException e) { procedure.exception(g, e.getCause()); - e.getCause().printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e.getCause()); } } else if( parameters.length == 1 && parameters[0] instanceof ThisResource2) { @@ -64,49 +66,50 @@ public class ReflectionAdapter2 implements Adapter { procedure.execute(g, constructor.newInstance(r)); } catch (IllegalArgumentException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (InstantiationException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (IllegalAccessException e) { procedure.exception(g, e); - e.printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e); } catch (InvocationTargetException e) { procedure.exception(g, e.getCause()); - e.getCause().printStackTrace(); + LOGGER.error("Unexpected exception during adapter creation", e.getCause()); } } else { - g.asyncRequest(new AsyncReadRequest() { - + g.asyncRequest(new AsyncRead() { + @Override - public void run(AsyncReadGraph graph) { - + public void perform(AsyncReadGraph graph, AsyncProcedure p) { + Object[] args = new Object[parameters.length]; try { - for(int i=0;i implements Adapter { return "ReflectionAdapter$1" + constructor + "$" + Arrays.toString(parameters); } - }); + }, procedure); }