I have a bunch of WebServices running on plain JDK and I need to intercept all public methods in order to do something. Some methods are using @WebParam annotation. Subclassing the WebService with ByteBuddy drops the @WebParam annotation from the overriding method and the service doesn't work anymore as expected.
Here's a sample signature
public Something fetch( @WebParam( name="Query" ) QueryCriteria query )
And here's how I'm using ByteBuddy
new ByteBuddy( )
.subclass( implementationClass )
.method( isPublic( ).and( isDeclaredBy( implementationClass ) ) )
.intercept(
MethodDelegation.to( new WebServiceInterceptor( ) )
.andThen( SuperMethodCall.INSTANCE ) )
.annotateType( implementationClass.getAnnotations( ) )
.make( )
I know there's a way to annotate parameters, but it requires special knowledge about the method parameters (because only some params are annotated). What I'd would like to do is just to ask ByteBuddy to annotate my class exactly the same way as superclass including all parameters of all overridden methods.
subclass( implementationClass )
.annotateType( LIKE_SUPERCLASS )
.method( )
.intercept( ... )
.annotateMethod( LIKE_SUPER_INCLUDING_PARAMS )
Any ideas?
BR, Paci