Inclusion
A Concern declared via the @Concerns annotation is only a candidate. The decision if it is included in the Invocation Stack for each method is determined by;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation is used by composites and mixins to declare what Concerns
* should be applied to the type or specific method.
*/
@Retention( RetentionPolicy.RUNTIME )
@Target( { ElementType.TYPE, ElementType.METHOD } )
@Documented
public @interface Concerns
{
Class<?>[] value();
}
@Concerns( { AuthorizationConcern.class } )
public interface BankAccountEntity extends BankAccount, EntityComposite
{}
import org.qi4j.library.auth.RequiresPermission;
public interface BankAccount
{
@RequiresPermission
Money checkBalance();
@RequiresPermission
void transfer( BankAccount toAccount, Money amount );
}
public class BankAccountMixin
implements BankAccount
{
@This private BankAccountBalance accountBalance;
public Money checkBalance()
{
return accountBalance.amount().get();
}
}
public interface BankAccountBalance
{
Property<Money> amount();
}
The Authorization library contains the building blocks to hook in any authentication and authorization mechanism, but the AuthorizationConcern defined in the EntityComposite above stays the same.