java - How to extract annotation arguments into external file? -


i have following class.

public class multipartfilewrapper {     @extensions({".jpg",".png",".gif",".bmp",".mp4"})     multipartfile multipartfile;       ... } 

now want extract formats configuration file. don't understand how replace

@extensions({".jpg",".png",".gif",".bmp",".mp4"}) 

i want rewrite this:

public class multipartfilewrapper {         @extensions(readformatsfromfile())         multipartfile multipartfile;           ...     } 

formats should takes external file following content:

.jpg,.png,.gif,.bmp,.mp4 

does java allow this?

attribute values must constant.

from java language specification, section 9.7.1, emphasis mine:

java not allow runtime annotation arguments: annotation parameters stored @ compile-time, , hence cannot dynamic.

if t primitive type or string, , v constant expression (§15.28).

v not null.

if t class, or invocation of class, , v class literal (§15.8.2).

if t enum type, , v enum constant.

in case, v not constant expression.

aside this, many annotations may not preserved in compiled code unless explicitly specified via @retention(retentionpolicy.runtime).


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -