T - The type to proxypublic class DynamicReactorFactory<T extends DynamicReactor>
extends java.lang.Object
Proxy based on the given interface, that
intercepts calls to the interface and translates them into the appropriate Reactor.on(reactor.event.selector.Selector, reactor.function.Consumer) or Reactor.notify(Object, Event)
calls. Methods that are translated to on calls should take a single argument that is a Consumer,
Function, Runnable, or Callable. Methods that are translated to notify calls should
take zero or one arguments. If the method takes zero arguments it will be translated to Reactor.notify(Object). IF the method takes one argument it will be translated to Reactor.notify(Object,
Event), wrapping the argument in an Event if necessary.
The translation of calls on the interface to calls to on and the selector that is used is determined by the
MethodSelectorResolvers. The translation of calls on the interface to calls to notify is determined by the MethodNotificationKeyResolvers.
By default, the creation of the selector for on calls will look for the On annotation. In its
absence, if the method name begins with on, the method name minus the on prefix and with the first character
lower-cased, will be used to create the selector. For example, the selector for a method named onAlpha will
be "alpha".
By default, the translation for notify calls will look for the Notify annotation. In its absence, if
the method name begins with notify, the method name minus the notify prefix and with the first character
lower-cased, will be used to create the notification key. For example, the notification key for a method named
notifyAlpha will be "alpha".| Constructor and Description |
|---|
DynamicReactorFactory(Environment env,
java.lang.Class<T> type)
Creates a new DynamicReactorFactory that will use the given
env when creating its Reactor. |
DynamicReactorFactory(Environment env,
java.lang.Class<T> type,
java.util.List<MethodSelectorResolver> selectorResolvers,
java.util.List<MethodNotificationKeyResolver> notificationKeyResolvers,
ConsumerInvoker consumerInvoker,
Converter converter)
Creates a new DynamicReactorFactory that will use the given
env when creating its Reactor. |
| Modifier and Type | Method and Description |
|---|---|
T |
create()
Generate a
Proxy based on the type used to create this factory. |
ConsumerInvoker |
getConsumerInvoker()
Get the
ConsumerInvoker to use when invoking Consumers. |
Converter |
getConverter()
Get the
Converter to use when coercing arguments. |
java.util.List<MethodSelectorResolver> |
getSelectorResolvers()
Get the list of
MethodSelectorResolvers in use. |
public DynamicReactorFactory(Environment env, java.lang.Class<T> type)
env when creating its Reactor. The
proxy
that is generated will be based upon the given type. A SimpleMethodSelectorResolver will be used to
create selectors for proxied methods. A SimpleMethodNotificationKeyResolver will be used to create
notification keys for proxied methods.env - The Environment to use when creating the underlying Reactor.type - The type of the proxypublic DynamicReactorFactory(Environment env, java.lang.Class<T> type, java.util.List<MethodSelectorResolver> selectorResolvers, java.util.List<MethodNotificationKeyResolver> notificationKeyResolvers, ConsumerInvoker consumerInvoker, Converter converter)
env when creating its Reactor. The
proxy
that is generated will be based upon the given type. The selectorResolvers will be used to create
selectors for proxied methods and the notificationKeyResolvers will be used to create notification keys for
proxied methods.env - The Environment to use when creating the underlying Reactor.type - The type of the proxyselectorResolvers - used to resolve the selectors for proxied methodsnotificationKeyResolvers - used to resolve the notification keys for proxied methodspublic java.util.List<MethodSelectorResolver> getSelectorResolvers()
MethodSelectorResolvers in use.MethodSelectorResolvers in use.public ConsumerInvoker getConsumerInvoker()
ConsumerInvoker to use when invoking Consumers.ConsumerInvoker in use.public Converter getConverter()
Converter to use when coercing arguments.Converter to use.public T create()
Proxy based on the type used to create this factory.