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;
+import org.simantics.db.request.AsyncRead;
public class ReflectionAdapter2<T> implements Adapter<T, Resource> {
} else {
- g.asyncRequest(new ReadRequest() {
-
+ g.asyncRequest(new AsyncRead() {
+
@Override
- public void run(ReadGraph graph) throws DatabaseException {
-
+ public void perform(AsyncReadGraph graph, AsyncProcedure p) {
+
Object[] args = new Object[parameters.length];
try {
- for(int i=0;i<parameters.length;++i)
- args[i] = parameters[i].adapt(graph, r);
- procedure.execute(g, constructor.newInstance(args));
- } 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();
- } catch (DatabaseException e) {
- procedure.exception(g, e);
- e.printStackTrace();
- } catch (Throwable t) {
- procedure.exception(g, t);
- t.printStackTrace();
- }
+ for(int i=0;i<parameters.length;++i)
+ args[i] = parameters[i].adapt(graph, r);
+ p.execute(graph, constructor.newInstance(args));
+ } catch (IllegalArgumentException e) {
+ p.exception(g, e);
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ p.exception(g, e);
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ p.exception(g, e);
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ p.exception(g, e.getCause());
+ e.getCause().printStackTrace();
+ } catch (DatabaseException e) {
+ p.exception(g, e);
+ e.printStackTrace();
+ } catch (Throwable t) {
+ p.exception(g, t);
+ t.printStackTrace();
+ }
+
}
@Override
return "ReflectionAdapter$1" + constructor + "$" + Arrays.toString(parameters);
}
- });
+ }, procedure);
}