use of org.apache.aries.proxy.UnableToProxyException in project aries by apache.
the class ProxyClassLoader method createProxyClass.
public Class<?> createProxyClass(Class<?> superclass, SortedSet<Class<?>> interfaces) throws UnableToProxyException {
LinkedHashSet<Class<?>> createSet = new LinkedHashSet<Class<?>>(interfaces);
//Even a null superclass helps with key uniqueness
createSet.add(superclass);
String className = classes.get(createSet);
if (className != null) {
try {
return Class.forName(className, false, this);
} catch (ClassNotFoundException cnfe) {
//This is odd, but we should be able to recreate the class, continue
classes.remove(createSet);
}
}
Lock wLock = ifacesLock.writeLock();
wLock.lock();
try {
//We want the superclass, but only if it isn't null
ifaces.addAll(interfaces);
if (superclass != null)
ifaces.add(superclass);
} finally {
wLock.unlock();
}
className = "Proxy" + AbstractWovenProxyAdapter.getSanitizedUUIDString();
InterfaceCombiningClassAdapter icca = new InterfaceCombiningClassAdapter(className, this, superclass, interfaces);
try {
byte[] bytes = icca.generateBytes();
Class<?> c = defineClass(className, bytes, 0, bytes.length, PROXY_PROTECTION_DOMAIN);
String old = classes.putIfAbsent(createSet, className);
if (old != null) {
c = Class.forName(className, false, this);
}
return c;
} catch (ClassFormatError cfe) {
throw new UnableToProxyException(createSet.iterator().next(), cfe);
} catch (ClassNotFoundException e) {
throw new UnableToProxyException(createSet.iterator().next(), e);
}
}
use of org.apache.aries.proxy.UnableToProxyException in project aries by apache.
the class BeanRecipe method createProxyBean.
private Object createProxyBean(ReferenceRecipe rr) {
try {
VoidableCallable vc = new VoidableCallable();
rr.addVoidableChild(vc);
return blueprintContainer.getProxyManager().createDelegatingProxy(blueprintContainer.getBundleContext().getBundle(), rr.getProxyChildBeanClasses(), vc, vc.call());
} catch (UnableToProxyException e) {
throw new ComponentDefinitionException(e);
}
}
Aggregations