Interface Channel
- All Superinterfaces:
Eligible
- All Known Subinterfaces:
Channel.Default
,IOSubchannel
,MailChannel
,Self
,SocketIOChannel
,Subchannel
- All Known Implementing Classes:
ClassChannel
,Component
,ComponentCollector
,ComponentCollector
,ComponentProvider
,ComponentProxy
,ComponentVertex
,ConfigurationStore
,ConnectionManager
,ConnectionManager.Connection
,FileStorage
,FileSystemWatcher
,FreeMarkerRequestHandler
,Handler.NoChannel
,HttpConnector
,HttpServer
,InMemorySessionManager
,InputStreamMonitor
,IOSubchannel.DefaultIOSubchannel
,JsonConfigurationStore
,LanguageSelector
,LinkedIOSubchannel
,MailConnectionManager
,MailConnectionManager.AbstractMailChannel
,MailMonitor
,MailMonitor.MonitorChannel
,MailSender
,MailSender.SenderChannel
,NamedChannel
,NightConfigStore
,NioDispatcher
,PreferencesStore
,ProcessManager
,ProcessManager.ProcessChannel
,PurgeTerminator
,SessionManager
,SocketConnectionManager
,SocketConnectionManager.SocketChannelImpl
,SocketConnector
,SocketServer
,SslCodec
,StaticContentDispatcher
,Subchannel.DefaultSubchannel
,TomlConfigurationStore
,YamlConfigurationStore
The instances work
as identifiers of channels. Their only functionality is defined
by the Eligible
interface, which allows a channel
(used as attribute of an Event
) to be matched against
a criterion specified in a Handler
.
The need to use the Eligible
interface for comparison
arises from the fact that we cannot use objects as values in
annotations. It must therefore be possible to match channels
(objects) against criteria that can be expressed as constant
values.
Some values have been defined to represent special criteria.
-
If the value
Channel.class
is specified as criterion in a handler, all channel instances match. It is the “catch-all” criterion. -
If the value
is specified as criterion in a handler, the channels from anChannel.Default
.classEvent
are matched agains the criterion from the component’s channel (returned by thechannel()
method).
The predefined BROADCAST
channel is a channel instance
that implements the Eligible
interface in such a way that
all criteria match. Events fired on the BROADCAST
channel
will therefore be accepted by all handlers (as its name suggests).
For ordinary usage, the implementing classes ClassChannel
and NamedChannel
should be sufficient. If another type of
Channel
is needed, its implementation must make sure that
Eligible.isEligibleFor(Object)
returns
true
if called with Channel.class
as parameter, else channels
of the new type will not be delivered to “catch-all” handlers.
Objects of type Channel
must be immutable.
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
This interface’s class can be used to specify the component’s channel (seeComponent.channel()
) as criterion in handler annotations. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Channel
A special channel instance that can be used to send events to all components.static final Channel
A special channel object that can be passed as argument to the constructor ofComponent(Channel)
. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
criterionToString
(Object criterion) Returns a textual representation of a channel’s criterion.default boolean
isEligibleFor
(Object criterion) By default, a channel is eligible for a broadcast and for its own default criterion (seeEligible.defaultCriterion()
.static String
Returns a textual representation of a channel.static String
Returns a textual representation of an array of channels.Methods inherited from interface org.jgrapes.core.Eligible
defaultCriterion
-
Field Details
-
SELF
A special channel object that can be passed as argument to the constructor ofComponent(Channel)
.Doing this sets the component’s channel to the component (which is not available as argument when calling the constructor).
- See Also:
-
BROADCAST
A special channel instance that can be used to send events to all components.
-
-
Method Details
-
isEligibleFor
By default, a channel is eligible for a broadcast and for its own default criterion (seeEligible.defaultCriterion()
.- Specified by:
isEligibleFor
in interfaceEligible
- Parameters:
criterion
- the criterion- Returns:
- true, if is eligible for
-
criterionToString
Returns a textual representation of a channel’s criterion.- Parameters:
criterion
- the criterion- Returns:
- the representation
-
toString
Returns a textual representation of a channel.- Parameters:
channel
- the channel- Returns:
- the representation
-
toString
Returns a textual representation of an array of channels.- Parameters:
channels
- the channels- Returns:
- the representation
-