The Apache Aries subclass proxy generates a subclass at runtime to be able 
to proxy a class. This has the limitation of not being able to work on 
final classes or final methods. The newer Apache Aries weaving based proxy 
is able to generate proxies for these types of classes. The weaving proxy 
is enabled by default if you are using an environment where OSGi weaving 
hooks are supported (spec level 4.3 or higher). If weaving hooks aren't 
supported or weaving has been disabled then the proxy will fall back to 
sub-classing.

Rich



From:   Roger Stocker <[email protected]>
To:     [email protected], 
Date:   16/08/2013 11:31
Subject:        Problem with service-reference with proxy-method="classes"



I try to track a list of services. Here is the definition:
     <reference-list id="applicationServices" 
interface="org.restlet.Application" ext:proxy-method="classes">
         <reference-listener bind-method="onApplicationRegistered" 
unbind-method="onApplicationUnregistered" ref="virtualHostListener"/>
     </reference-list>

The org.restlet.Application is a class and therefore I put 
ext:proxy-method="classes" to the reference. All dependencies to 
objectweb-asm are satisfied and org.apache.aries.proxy is bound to it.

Now I get this stacktrace:
org.apache.aries.proxy.FinalModifierException: The methods public final 
void 
org.restlet.Restlet.handle(org.restlet.Request,org.restlet.Uniform), 
public final org.restlet.Response 
org.restlet.Restlet.handle(org.restlet.Request), public final void 
org.restlet.Restlet.handle(org.restlet.Request,org.restlet.Response,org.restlet.Uniform)
 

in class org.restlet.Application are final.
     at 
org.apache.aries.proxy.impl.gen.ProxySubclassGenerator.getProxySubclass(ProxySubclassGenerator.java:106)
     at 
org.apache.aries.proxy.impl.gen.ProxySubclassGenerator.newProxySubclassInstance(ProxySubclassGenerator.java:159)
     at 
org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:103)
     at 
org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingInterceptingProxy(AbstractProxyManager.java:75)
     at 
org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingProxy(AbstractProxyManager.java:40)
     at 
org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.createProxy(AbstractServiceReferenceRecipe.java:306)
     at 
org.apache.aries.blueprint.container.ReferenceListRecipe.track(ReferenceListRecipe.java:124)
     at 
org.apache.aries.blueprint.container.ReferenceListRecipe.retrack(ReferenceListRecipe.java:89)
     at 
org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.updateListeners(AbstractServiceReferenceRecipe.java:422)
     at 
org.apache.aries.blueprint.container.ReferenceListRecipe.internalCreate(ReferenceListRecipe.java:75)
     at 
org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
     at java.util.concurrent.FutureTask.run(FutureTask.java:166)
     at 
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)
     at 
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)
     at 
org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)
     at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:668)
     at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:370)
     at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:261)
     at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
     at java.util.concurrent.FutureTask.run(FutureTask.java:166)
     at 
org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
     at 
org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
     at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
     at java.util.concurrent.FutureTask.run(FutureTask.java:166)
     at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
     at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
     at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
     at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
     at java.lang.Thread.run(Thread.java:724)

Does that mean, that I cannot use org.restlet.Application as the 
referenced interface?
Any workaround?

The same thing works with the Gemini Blueprint-Extender 
(spring-extender). Why? Is it because the spring-extender uses another 
bytecode weaving library (cglib)?








Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU





Reply via email to