|
Urbi SDK Remote for Java
2.7.5
|
00001 /* 00002 * Copyright (C) 2010-2011, Gostai S.A.S. 00003 * 00004 * This software is provided "as is" without warranty of any kind, 00005 * either expressed or implied, including but not limited to the 00006 * implied warranties of fitness for a particular purpose. 00007 * 00008 * See the LICENSE file for more information. 00009 */ 00010 00011 package urbi; 00012 00013 import java.lang.reflect.Method; 00014 import java.lang.reflect.Constructor; 00015 00016 import urbi.urbi; 00017 import urbi.URBIStarterJAVA; 00018 import urbi.UContextImpl; 00019 import urbi.UObjectCPP; 00020 00021 public class UObjectStarter extends URBIStarterJAVA 00022 { 00023 public UObjectStarter (String name, Constructor ctor) { 00024 super (name); 00025 uobject_ctor = ctor; 00026 uobject_name = name; 00027 } 00028 00029 public UObjectCPP instanciate(UContextImpl ctx, String n) 00030 { 00031 String rn = n; 00032 if (("").equals(rn)) 00033 rn = uobject_name; //getName(); 00034 urbi.setCurrentContext (ctx); 00035 UObjectCPP res = null; 00036 00037 try 00038 { 00039 Object[] ctor_params = { rn }; 00040 res = (UObjectCPP) uobject_ctor.newInstance(ctor_params); 00041 ctx.instanciated(res); 00042 res.setCloner(this); 00043 } 00044 catch (java.lang.InstantiationException e) 00045 { 00046 throw new RuntimeException (e); 00047 } 00048 catch (java.lang.IllegalAccessException e) 00049 { 00050 throw new RuntimeException (e); 00051 } 00052 catch (java.lang.reflect.InvocationTargetException e) 00053 { 00054 throw new RuntimeException (e); 00055 } 00056 return res; 00057 } 00058 00059 private Constructor uobject_ctor; 00060 private String uobject_name; 00061 00062 } 00063