org.qi4j.api.common
Annotation Type AppliesTo


@Retention(value=RUNTIME)
@Target(value={TYPE,METHOD})
@Documented
public @interface AppliesTo

Fragments that implement InvocationHandler and which should only be applied to methods that have a particular annotation or implement a known interface should use this annotation.

@AppliesTo can specify one of;

Example with annotation:



 @AppliesTo( Sessional.class )   // Tells Qi4j to apply this concern on methods with @Sessional annotation
 public class SessionConcern extends GenericConcern
 {
     public Object invoke( Object proxy, Method method, Object[] args )
         throws Throwable
     {
         ... do session stuff ...
     }
 }

 @Retention( RetentionPolicy.RUNTIME )
 @Target( ElementType.METHOD )
 @Documented
 @Inherited
 public @interface Sessional
 {
 }

 public class MyMixin
     implements My
 {
     @Sessional
     public void doSomethingSessional()
     {
        // ... do your logic wrapped in a session
     }

     public void doSomethingWithoutSession()
     {
        // ... do stuff that are not wrapped in session.
     }
 }

 public interface My
 {
     void doSomethingSessional();

     void doSomethingWithoutSession();
 }

 @Concerns( SessionConcern.class )
 @Mixins( MyMixin.class )
 public interface MyComposite extends My, TransientComposite
 {}
 

The doSomethingWithoutSession method do not have the @Sessional annotation, therefore the SessionConcern will not be placed into the call sequence of these methods, and vice-versa. The @Sessional annotation can be placed either on the interface method or the implementation method, depending on whether it is a contract or implementation detail.


Required Element Summary
 Class<?>[] value
          List of interfaces, annotations or AppliesToFilter implementation classes.
 

Element Detail

value

public abstract Class<?>[] value
List of interfaces, annotations or AppliesToFilter implementation classes. If one of them matches the current element it will be accepted, so this list can be considered an "or".

Returns:
array of classes or interfaces to be used by the filter