1 package org.apache.ojb.jdori.sql; 2 3 import java.lang.reflect.Field ; 4 5 import javax.jdo.JDOFatalInternalException; 6 7 import com.sun.jdori.StateManagerInternal; 8 import com.sun.jdori.common.model.jdo.JDOModelFactoryImpl; 9 import com.sun.jdori.common.model.runtime.RuntimeJavaModelFactory; 10 import com.sun.jdori.model.java.JavaModel; 11 import com.sun.jdori.model.java.JavaModelFactory; 12 import com.sun.jdori.model.jdo.JDOClass; 13 import com.sun.jdori.model.jdo.JDOModel; 14 15 29 30 35 class Helper 36 { 37 43 static JDOClass getJDOClass(Class c) 44 { 45 JDOClass rc = null; 46 try 47 { 48 JavaModelFactory javaModelFactory = RuntimeJavaModelFactory.getInstance(); 49 JavaModel javaModel = javaModelFactory.getJavaModel(c.getClassLoader()); 50 JDOModel m = JDOModelFactoryImpl.getInstance().getJDOModel(javaModel); 51 rc = m.getJDOClass(c.getName()); 52 } 53 catch (RuntimeException ex) 54 { 55 throw new JDOFatalInternalException("Not a JDO class: " + c.getName()); 56 } 57 return rc; 58 } 59 60 66 static Object getLCState(StateManagerInternal sm) 67 { 68 try 71 { 72 Field myLC = sm.getClass().getDeclaredField("myLC"); 73 myLC.setAccessible(true); 74 return myLC.get(sm); 75 } 76 catch (NoSuchFieldException e) 77 { 78 return e; 79 } 80 catch (IllegalAccessException e) 81 { 82 return e; 83 } 84 } 85 86 } 87 | Popular Tags |