From: Adrian B. <ej...@us...> - 2002-10-25 09:42:27
|
User: ejort Date: 02/10/24 17:11:38 Modified: src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge Tag: Branch_3_0 JDBCCMRFieldBridge.java Log: Set the context classloader for CMR invocations otherwise java:comp doesn't work Revision Changes Path No revision No revision 1.31.2.12 +26 -1 jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java Index: JDBCCMRFieldBridge.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java,v retrieving revision 1.31.2.11 retrieving revision 1.31.2.12 diff -u -r1.31.2.11 -r1.31.2.12 --- JDBCCMRFieldBridge.java 15 Oct 2002 05:46:46 -0000 1.31.2.11 +++ JDBCCMRFieldBridge.java 25 Oct 2002 00:11:38 -0000 1.31.2.12 @@ -64,7 +64,7 @@ * One for each role that entity has. * * @author <a href="mailto:da...@da...">Dain Sundstrom</a> - * @version $Revision: 1.31.2.11 $ + * @version $Revision: 1.31.2.12 $ */ public class JDBCCMRFieldBridge implements JDBCFieldBridge, CMRFieldBridge { /** @@ -629,6 +629,11 @@ * invocation interceptor chain. */ private Object invokeGetRelatedId(Transaction tx, Object myId) { + + Thread thread = Thread.currentThread(); + ClassLoader oldCL = thread.getContextClassLoader(); + thread.setContextClassLoader(manager.getContainer().getClassLoader()); + try { EntityInstanceCache instanceCache = (EntityInstanceCache)manager.getContainer().getInstanceCache(); @@ -650,6 +655,10 @@ } catch(Exception e) { throw new EJBException("Error in getRelatedId", e); } + finally + { + thread.setContextClassLoader(oldCL); + } } /** @@ -659,6 +668,10 @@ private void invokeAddRelation( Transaction tx, Object myId, Object relatedId) { + Thread thread = Thread.currentThread(); + ClassLoader oldCL = thread.getContextClassLoader(); + thread.setContextClassLoader(manager.getContainer().getClassLoader()); + try { EntityInstanceCache instanceCache = (EntityInstanceCache)manager.getContainer().getInstanceCache(); @@ -680,6 +693,10 @@ } catch(Exception e) { throw new EJBException("Error in addRelation", e); } + finally + { + thread.setContextClassLoader(oldCL); + } } /** @@ -689,6 +706,10 @@ private void invokeRemoveRelation( Transaction tx, Object myId, Object relatedId) { + Thread thread = Thread.currentThread(); + ClassLoader oldCL = thread.getContextClassLoader(); + thread.setContextClassLoader(manager.getContainer().getClassLoader()); + try { EntityInstanceCache instanceCache = (EntityInstanceCache)manager.getContainer().getInstanceCache(); @@ -709,6 +730,10 @@ throw e; } catch(Exception e) { throw new EJBException("Error in removeRelation", e); + } + finally + { + thread.setContextClassLoader(oldCL); } } |