0

i have two annotations located in a file like this:

**file package-info.java**

@CallService(name ="My first kurento app")
@SipApplication(name = "default-name-sip-app", description = "default description of the   SipApplication", displayName = "default-displayName")
package com.kurento.kmf.sip;

import javax.servlet.sip.annotation.SipApplication;
import com.kurento.kmf.sip.annotation.CallService;

I need that the value of name attribute from CallService goes to name attribute of @SipApplication in runtime.

I have some code inspired from this link and it looks like the value of the attribute has changed, but it doesnt work. The code is on pastebin. Please help.

Community
  • 1
  • 1
aironman
  • 837
  • 5
  • 26
  • 55

1 Answers1

2

Java Annotations are designed to associate static metadata to classes as Oracle says here.

Anyway, if you still want to associate this variable metadata to an annotation, you could achieve this associating a custom class to both annotations that is holding the value you want to be variable.

Working example here:

// annotate your class with you custom class
@CallService(name=MyVariableMetadata.class)
Andrés Oviedo
  • 1,388
  • 1
  • 13
  • 28
  • Hi Andres, thanks for the response, but your nice code does not solve my problem, and i think i cannot resolve it. I need to change the value of a third party anotation tag with the value of my custom anotation at runtime before the value of the third party anotation is procesed. Thanks anyway – aironman Oct 31 '13 at 09:34
  • 1
    And what about using Aspects or Instrumenting your third party class? – Andrés Oviedo Oct 31 '13 at 12:15
  • finally, we have discover that we can use a Mbean exposed by JMX in order to resolve this problem. – aironman Nov 19 '13 at 15:34