Index

Interceptor Pattern

It looks like this,

class Invocation {
        public String method;
        public Array<Object> args;
    }
    
    Event = Invocation
    
    class Interceptor {
        public Interceptor next;
        public intercept(Invocation v);
        private dispatch(Invocation v);
        private delegate(Invocation v);
        intercept = trigger = execute
    }
    
    Interceptor = System = Command

When dealing with legacy code it becomes,

By composing multiple interceptors we get,

When combined with metadata meta-object-programming,

It can be combined with a Message Bus easily as well.
It can used as the System in Entity-Component-System pattern.