Create interceptor qualifier thats ignore annotation value()

Is there a way to create a interceptor qualifier annotation that ignores the annotation string value for qualifying?

for example:

Log.java

@Inherited
@InterceptorBinding
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Log {
    String value() default ""; // <---- ignore this
}

LogInterceptor.java

@Log
@Interceptor
public class LogInterceptor implements Serializable {

    ...
}

Usage.java

@Log("message for this log")
public String interceptedMethod(String param) {
    ...
}

This doesn't work because the annotation value("message for this log") works as qualifier but I want to use the value() not as qualifier, but message log.

Answers


You can use the @Nonbinding annotation for that purpose. You can force the container to ignore a member of a qualifier type by annotating the member @Nonbinding. Look at the following example:

@Qualifier
@Retention(RUNTIME)
@Target({METHOD, FIELD, PARAMETER, TYPE})
public @interface PayBy {
   PaymentMethod value();
   @Nonbinding String comment() default "";
}

Here the comment will be ignored when matching beans by the @PayBy qualifier. A reference to the CDI documentation describing this can be found here.


Need Your Help

Python unicode search not giving correct answer

python unicode unicode-string hindi

I am trying to search hindi words contained one line per file in file-1 and find them in lines in file-2. I have to print the line numbers with the number of words found.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.