public class Environment extends java.lang.Object implements java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.util.List<Dispatcher>>>
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
EVENT_LOOP
The name of the default event loop dispatcher
|
static int |
PROCESSORS
The number of processors available to the runtime
|
static java.lang.String |
RING_BUFFER
The name of the default ring buffer dispatcher
|
static java.lang.String |
THREAD_POOL
The name of the default thread pool dispatcher
|
static java.lang.String |
WORK_QUEUE
The name of the default work queue dispatcher
|
| Constructor and Description |
|---|
Environment()
Creates a new Environment that will use a
PropertiesConfigurationReader to obtain its initial
configuration. |
Environment(ConfigurationReader configurationReader)
Creates a new Environment that will use the given
configurationReader to obtain its initial configuration. |
Environment(java.util.Map<java.lang.String,java.util.List<Dispatcher>> dispatchers,
ConfigurationReader configurationReader)
Creates a new Environment that will contain the given
dispatchers, will use the given configurationReader to obtain additional configuration. |
| Modifier and Type | Method and Description |
|---|---|
Environment |
addDispatcher(java.lang.String name,
Dispatcher dispatcher)
Adds the
dispatcher to the environment, storing it using the given name. |
Dispatcher |
getDefaultDispatcher()
Returns the default dispatcher for this environment.
|
Dispatcher |
getDispatcher(java.lang.String name)
Returns the dispatcher with the given
name. |
<T> T |
getProperty(java.lang.String key,
java.lang.Class<T> type,
T defaultValue)
Gets the property with the given
key, converting it to the required type using the standard converters. |
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
Gets the property with the given
key. |
Reactor |
getRootReactor()
Returns this environments root Reactor, creating it if necessary.
|
Timer |
getRootTimer()
Get the
Environment-wide SimpleHashWheelTimer. |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List<Dispatcher>>> |
iterator() |
Environment |
removeDispatcher(java.lang.String name)
Removes the Dispatcher, stored using the given
name from the environment. |
void |
shutdown()
Shuts down this Environment, causing all of its
Dispatchers to be shut down. |
public static final java.lang.String EVENT_LOOP
public static final java.lang.String RING_BUFFER
public static final java.lang.String THREAD_POOL
public static final java.lang.String WORK_QUEUE
public static final int PROCESSORS
Runtime.availableProcessors()public Environment()
PropertiesConfigurationReader to obtain its initial
configuration. The configuration will be read from the classpath at the location META-INF/reactor/default.properties.public Environment(ConfigurationReader configurationReader)
configurationReader to obtain its initial configuration.configurationReader - The configuration reader to use to obtain initial configurationpublic Environment(java.util.Map<java.lang.String,java.util.List<Dispatcher>> dispatchers, ConfigurationReader configurationReader)
dispatchers, will use the given configurationReader to obtain additional configuration.dispatchers - The dispatchers to add include in the EnvironmentconfigurationReader - The configuration reader to use to obtain additional configurationpublic java.lang.String getProperty(java.lang.String key,
java.lang.String defaultValue)
key. If the property does not exist defaultValue will be
returned.key - The property keydefaultValue - The value to return if the property does not existpublic <T> T getProperty(java.lang.String key,
java.lang.Class<T> type,
T defaultValue)
key, converting it to the required type using the standard converters. fF the property does not exist defaultValue will be
returned.key - The property keytype - The type to convert the property todefaultValue - The value to return if the property does not existpublic Dispatcher getDefaultDispatcher()
PropertiesConfigurationReader is
being used. This default dispatcher is specified by the value of the reactor.dispatchers.default property.public Dispatcher getDispatcher(java.lang.String name)
name.name - The name of the dispatchernull.java.lang.IllegalArgumentException - if the dispatcher does not existpublic Environment addDispatcher(java.lang.String name, Dispatcher dispatcher)
dispatcher to the environment, storing it using the given name.name - The name of the dispatcherdispatcher - The dispatcherpublic Environment removeDispatcher(java.lang.String name)
name from the environment.name - The name of the dispatcherpublic Reactor getRootReactor()
getDefaultDispatcher()public Timer getRootTimer()
Environment-wide SimpleHashWheelTimer.public void shutdown()
Dispatchers to be shut down.Dispatcher.shutdown()public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.util.List<Dispatcher>>> iterator()
iterator in interface java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.util.List<Dispatcher>>>