X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.services%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fservices%2Fadaption%2Freflection%2FReflectionAdapter2.java;h=251cb764296ca486421cd51a4f300056f4a8ab69;hp=ae76dac4750530e2c783a2aba1474b795105fc56;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 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 ae76dac47..251cb7642 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 @@ -1,129 +1,129 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.db.services.adaption.reflection; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; - -import org.simantics.db.AsyncReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.ReadGraph; -import org.simantics.db.adaption.Adapter; -import org.simantics.db.common.request.ReadRequest; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.procedure.AsyncProcedure; - -public class ReflectionAdapter2 implements Adapter { - - Constructor constructor; - IDynamicAdapter2[] parameters; - - public ReflectionAdapter2(Class clazz, IDynamicAdapter2 ... parameters) throws SecurityException, NoSuchMethodException, DatabaseException { - Class[] parameterTypes = new Class[parameters.length]; - for(int i=0;i procedure) { - - 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(); - } catch (InstantiationException e) { - procedure.exception(g, e); - e.printStackTrace(); - } catch (IllegalAccessException e) { - procedure.exception(g, e); - e.printStackTrace(); - } catch (InvocationTargetException e) { - procedure.exception(g, e.getCause()); - e.getCause().printStackTrace(); - } - - } else if( parameters.length == 1 && parameters[0] instanceof ThisResource2) { - - try { - procedure.execute(g, constructor.newInstance(r)); - } catch (IllegalArgumentException e) { - procedure.exception(g, e); - e.printStackTrace(); - } catch (InstantiationException e) { - procedure.exception(g, e); - e.printStackTrace(); - } catch (IllegalAccessException e) { - procedure.exception(g, e); - e.printStackTrace(); - } catch (InvocationTargetException e) { - procedure.exception(g, e.getCause()); - e.getCause().printStackTrace(); - } - - } else { - - g.asyncRequest(new ReadRequest() { - - @Override - public void run(ReadGraph graph) throws DatabaseException { - - Object[] args = new Object[parameters.length]; - try { - for(int i=0;i implements Adapter { + + Constructor constructor; + IDynamicAdapter2[] parameters; + + public ReflectionAdapter2(Class clazz, IDynamicAdapter2 ... parameters) throws SecurityException, NoSuchMethodException, DatabaseException { + Class[] parameterTypes = new Class[parameters.length]; + for(int i=0;i procedure) { + + 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(); + } catch (InstantiationException e) { + procedure.exception(g, e); + e.printStackTrace(); + } catch (IllegalAccessException e) { + procedure.exception(g, e); + e.printStackTrace(); + } catch (InvocationTargetException e) { + procedure.exception(g, e.getCause()); + e.getCause().printStackTrace(); + } + + } else if( parameters.length == 1 && parameters[0] instanceof ThisResource2) { + + try { + procedure.execute(g, constructor.newInstance(r)); + } catch (IllegalArgumentException e) { + procedure.exception(g, e); + e.printStackTrace(); + } catch (InstantiationException e) { + procedure.exception(g, e); + e.printStackTrace(); + } catch (IllegalAccessException e) { + procedure.exception(g, e); + e.printStackTrace(); + } catch (InvocationTargetException e) { + procedure.exception(g, e.getCause()); + e.getCause().printStackTrace(); + } + + } else { + + g.asyncRequest(new ReadRequest() { + + @Override + public void run(ReadGraph graph) throws DatabaseException { + + Object[] args = new Object[parameters.length]; + try { + for(int i=0;i