This package allows you to create Commandable interfaces, which are completely universal. Thus, for example, if an object extends ICommandable and returns a CommandSet, then you can implement a commandable client for this object, using various technologies and with minimal code.
The package main components are:
- Commandable Interfaces – used to make classes with a certain logic and, which are capable of receiving and processing commands in this universal form.
- Command interceptors – modify the message execution pipeline. Command interceptors are used to intercept calls, perform a set of actions, and, optionally, cancel the command’s actual execution by simply returning a result. This logic is used in aspect-oriented programming. Aspect-oriented programming contains perpendicular logic (aspects, such as logging, caching, blocking), which can be removed from the business logic and added to these perpendicular calls.
Moreover, when using interceptors, a command can pass through an execution chain, consisting of interceptors, which can:
- simply take note of the command, notify, log, get metrics, or do some other passive task;
- intercept the command completely and, for example, return a previous record of the call from the cache.
- intercept a command’s return value and, for example, cache the result, so that the next call doesn’t have to be made.
- Intercepted commands are used as pattern decorators that allow behavior to be added to an individual object, dynamically and without affecting the behavior of other objects from the same class. They are represented as regular commands, but run their own logic before calling the actual command.
Typical uses of this package would be intercepting messages and various logging implementations.
Implements a command wrapped by an interceptor. It allows to build command call chains. The interceptor can alter execution and delegate calls to a following command, which can be intercepted or concrete.
An interface for Commands, which are part of the Command design pattern. Each command wraps a method or function and allows to call them in a uniform and safe manner.
An interface for commandable objects, which are part of the command design pattern. The commandable object exposes its functonality as commands and events grouped into a CommandSet. This interface is typically implemented by controllers and is used to auto generate external interfaces.
An interface for listener objects that receive notifications on fired events.
An interface for Events, which are part of the Command design pattern. Events allows to send asynchronious notifications to multiple subscribed listeners.
Contains a set of commands and events supported by a commandable object.
The CommandSet supports command interceptors to extend and the command call chain.
CommandSets can be used as alternative commandable interface to a business object. It can be used to auto generate multiple external services for the business object without writing much code.
Concrete implementation of ICommand interface. Command allows to call a method or function using Command pattern.
Concrete implementation of IEvent interface. It allows to send asynchronous notifications to multiple subscribed listeners.