aironman
aironman

Reputation: 869

how to modify an attribute of an annotation at runtime

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.

Upvotes: 0

Views: 935

Answers (1)

Andrés Oviedo
Andrés Oviedo

Reputation: 1428

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)

Upvotes: 2

Related Questions