I would like to use Byte-Buddy to generate annotations and I am able to accomplish this for simple annotations. What is the correct Byte-Buddy syntax to generate nested annotations?
For example I would like to generate the following annotation @MessageDriven
which contains nested annotations:
@MessageDriven(
activationConfig={
@ActivationConfigProperty(propertyName="destination", propertyValue="remoteBidsWantedJMS/TOPIC.BIDSWANTED.QUOTEWANTEDSEVENT"),
@ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/RemoteBidsWantedJMSProvider"),
@ActivationConfigProperty(propertyName="reconnectAttempts", propertyValue="60"),
@ActivationConfigProperty(propertyName="reconnectInterval", propertyValue="10"),
@ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="Auto-acknowledge"),
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic"),
@ActivationConfigProperty(propertyName="subscriptionDurability", propertyValue="NonDurable"),
@ActivationConfigProperty(propertyName="maxSession", propertyValue="1")
})
What is wrong with my current syntax?
DynamicType.Unloaded dynamicTypeBuilder2 = new ByteBuddy()
.redefine(QuoteWantedsEventProcessorBean.class)
.name("com.tmcbonds.messaging.QuoteWantedsEventProcessorBean_BYTEBUDDY_REDEFINE_" + i)
.annotateType(AnnotationDescription.Builder.ofType(Pool.class)
.define("value", "TESTVALUE")
.build())
.annotateType(AnnotationDescription.Builder.ofType(MessageDriven.class)
.defineTypeArray("activationConfig", ActivationConfigProperty.class)
.define("propertyName", "destination")
.define("propertyValue", "remoteBidsWantedJMS/TOPIC.BIDSWANTED.QUOTEWANTEDSEVENT")
.build())
.make();
Exception is this:
Exception in thread "main" java.lang.IllegalArgumentException: [interface javax.ejb.ActivationConfigProperty] cannot be assigned to activationConfig at net.bytebuddy.description.annotation.AnnotationDescription$Builder.define(AnnotationDescription.java:852) at net.bytebuddy.description.annotation.AnnotationDescription$Builder.defineTypeArray(AnnotationDescription.java:1041) at net.bytebuddy.description.annotation.AnnotationDescription$Builder.defineTypeArray(AnnotationDescription.java:1029)
Thanks!