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=251cb764296ca486421cd51a4f300056f4a8ab69;hb=refs%2Fchanges%2F38%2F238%2F2;hp=f8ec0f81a7f11dc05d102d81ce7ef2feeccdaf34;hpb=8ada31c956ee02aef38627ba4deaaae3eecb623a;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 f8ec0f81a..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,126 +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