If we want to provide auditing in our application, such as a sequence of particular events that occur, then we can use interceptors to help us. First off, we need to define an interceptor binding type that we can use to inform Weld about which beans we want to audit:
@InterceptorBinding @Target( { METHOD, TYPE } ) @Retention( RUNTIME ) public @interface Audited {}
With the interceptor binding type created, we can set our AccountManagement
to be an audited bean:
@Audited public class AccountManagement { ... }
Though, if we only want a specific method to be audited, we can specify:
public class AccountManagement { @Audited public void createAccount() { ... } }