java.lang.Object
cl.netswitch.lib.client.LogicalChannels
Pool of reusable thread-safe
logical channels
. This
pool is intended to be used in multithreaded environments. Each pool is
identified by a unique name (case insensitive), and provides a logical channel
to a channel
executor
. When the channel executor
completes
execution, the logical channel
is returned to the
pool, so it can be reused by other channel executors.
Property | Description | Type | Default |
---|---|---|---|
logical.channels.props.file |
Full path of the property file of logical channels | String |
LogicalChannels.properties |
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
clear()
Closes and releases all existing channel pools, and clears the properties of logical channels.static <T> T
execute
(ChannelExecutor<T> executor) Allocates a logical channel from the default channel pool and executes the supplied channel executor.static <T> T
execute
(String poolName, ChannelExecutor<T> executor) Allocates a logical channel from the specified channel pool and executes the supplied channel executor.static Properties
Returns the properties of all logical channels.
-
Method Details
-
getProperties
Returns the properties of all logical channels.- Returns:
- the properties of all logical channels.
-
execute
Allocates a logical channel from the default channel pool and executes the supplied channel executor. The logical channel is returned to the pool when the executor completes execution, either successfully or by throwing an exception.The default channel pool is called "default", so this convenience method produces the same result as the following invocation:
execute("default", executor);
- Type Parameters:
T
- the type of the value returned by theexecutor
.- Parameters:
executor
- the channel executor to be executed.- Returns:
- the value returned by the
executor
. - Throws:
NullPointerException
- ifexecutor
isnull
.Exception
- if another error occurs.
-
execute
Allocates a logical channel from the specified channel pool and executes the supplied channel executor. The logical channel is returned to the pool when the executor completes execution, either successfully or by throwing an exception.- Type Parameters:
T
- the type of the value returned by theexecutor
.- Parameters:
poolName
- the name of the channel pool.executor
- the channel executor to be executed.- Returns:
- the value returned by the
executor
. - Throws:
NullPointerException
- if an argument isnull
.Exception
- if another error occurs.
-
clear
public static void clear()Closes and releases all existing channel pools, and clears the properties of logical channels. This is useful when the property file has been modified, and new values need to be loaded.When a channel pool is closed, all it's associatted
logical channels
are closed and released. If achannel executor
is using one of theselogical channels
, it may terminate throwing an exception.
-