| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.core.ojb; |
| 17 | |
|
| 18 | |
import java.util.Collection; |
| 19 | |
|
| 20 | |
import org.apache.ojb.broker.PBKey; |
| 21 | |
import org.apache.ojb.broker.PersistenceBrokerException; |
| 22 | |
import org.apache.ojb.broker.core.proxy.SetProxyDefaultImpl; |
| 23 | |
import org.apache.ojb.broker.query.Query; |
| 24 | |
import org.kuali.rice.core.util.ClassLoaderUtils; |
| 25 | |
import org.kuali.rice.core.util.ContextClassLoaderBinder; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
public class ContextClassLoaderSetProxy extends SetProxyDefaultImpl { |
| 48 | |
|
| 49 | |
private static final long serialVersionUID = -2274968495694456744L; |
| 50 | |
|
| 51 | |
private ClassLoader contextClassLoader; |
| 52 | |
|
| 53 | |
public ContextClassLoaderSetProxy(PBKey aKey, Class aCollClass, Query aQuery) { |
| 54 | 0 | super(aKey, aCollClass, aQuery); |
| 55 | 0 | this.contextClassLoader = ClassLoaderUtils.getDefaultClassLoader(); |
| 56 | 0 | } |
| 57 | |
|
| 58 | |
public ContextClassLoaderSetProxy(PBKey aKey, Query aQuery) { |
| 59 | 0 | super(aKey, aQuery); |
| 60 | 0 | this.contextClassLoader = ClassLoaderUtils.getDefaultClassLoader(); |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
@Override |
| 64 | |
protected void beforeLoading() { |
| 65 | 0 | ContextClassLoaderBinder.bind(this.contextClassLoader); |
| 66 | 0 | super.beforeLoading(); |
| 67 | 0 | } |
| 68 | |
|
| 69 | |
@Override |
| 70 | |
protected Collection loadData() throws PersistenceBrokerException { |
| 71 | |
try { |
| 72 | 0 | return super.loadData(); |
| 73 | 0 | } catch (Throwable t) { |
| 74 | 0 | ContextClassLoaderBinder.unbind(); |
| 75 | 0 | if (t instanceof PersistenceBrokerException) { |
| 76 | 0 | throw (PersistenceBrokerException)t; |
| 77 | 0 | } else if (t instanceof Error) { |
| 78 | 0 | throw (Error)t; |
| 79 | 0 | } else if (t instanceof RuntimeException) { |
| 80 | 0 | throw (RuntimeException)t; |
| 81 | |
} else { |
| 82 | 0 | throw new PersistenceBrokerException("Invalid exception type thrown!", t); |
| 83 | |
} |
| 84 | |
} |
| 85 | |
} |
| 86 | |
|
| 87 | |
@Override |
| 88 | |
protected void afterLoading() { |
| 89 | 0 | super.afterLoading(); |
| 90 | 0 | ContextClassLoaderBinder.unbind(); |
| 91 | 0 | } |
| 92 | |
|
| 93 | |
|
| 94 | |
} |