use of org.apache.aries.proxy.weavinghook.ProxyWeavingController in project aries by apache.
the class WeavingProxyTest method checkProxyController.
@Test(expected = FinalModifierException.class)
public void checkProxyController() throws Exception {
bundleContext.registerService(ProxyWeavingController.class.getName(), new ProxyWeavingController() {
public boolean shouldWeave(WovenClass arg0, WeavingHelper arg1) {
return false;
}
}, null);
Bundle b = bundleContext.getBundle();
Callable<Object> c = new TestCallable();
Collection<Class<?>> classes = new ArrayList<Class<?>>();
// Don't use anonymous inner class in this test as IBM and Sun load it at a different time
// For IBM JDK, the anonymous inner class will be loaded prior to the controller is registered.
Callable<?> callable = new TestFinalDelegate();
classes.add(callable.getClass());
Object o = mgr.createDelegatingProxy(b, classes, c, callable);
if (o instanceof WovenProxy)
fail("Proxy should not have been woven!");
}
use of org.apache.aries.proxy.weavinghook.ProxyWeavingController in project aries by apache.
the class ProxyWeavingHook method shouldWeave.
private boolean shouldWeave(WovenClass wovenClass) {
// assume we weave
boolean result = true;
Object[] cs = controllers.getServices();
// if we have at least 1 weaving controller
if (cs != null && cs.length > 0) {
// first of all set to false.
result = false;
for (Object obj : cs) {
ProxyWeavingController c = (ProxyWeavingController) obj;
if (c.shouldWeave(wovenClass, this)) {
// exit as soon as we get told to weave, otherwise keep going.
return true;
}
}
}
return result;
}
Aggregations