Class ChannelList
- java.lang.Object
-
- java.util.AbstractCollection<Channel>
-
- com.adaptris.core.ChannelList
-
- All Implemented Interfaces:
ComponentLifecycle
,ComponentLifecycleExtension
,java.lang.Iterable<Channel>
,java.util.Collection<Channel>
,java.util.List<Channel>
@ComponentProfile(summary="A Collection of Channels", tag="base") public class ChannelList extends java.util.AbstractCollection<Channel> implements ComponentLifecycle, java.util.List<Channel>, ComponentLifecycleExtension
Container for a collection of
Channel
objectsIn the adapter configuration file this class is aliased as channel-list which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Constructor Summary
Constructors Constructor Description ChannelList()
Creates a new instance.ChannelList(java.util.Collection<Channel> coll)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, Channel element)
boolean
add(Channel element)
boolean
addAll(int index, java.util.Collection<? extends Channel> c)
void
addChannel(Channel channel)
Adds aChannel
to the underlyingList
and validates its unique ID.void
clear()
void
close()
Uses the the configuredChannelLifecycleStrategy
to invokeStateManagedComponent.requestClose()
on the underlyingChannel
s in theList
.Channel
get(int index)
Channel
getChannel(int pos)
Returns theChannel
stored at the passedpos
in theList
.Channel
getChannel(java.lang.String uniqueId)
Returns theChannel
with the passeduniqueId
or null if no such channel exists.java.util.List<Channel>
getChannels()
Returns the underlyingList
ofChannel
s.ChannelLifecycleStrategy
getLifecycleStrategy()
int
indexOf(java.lang.Object o)
void
init()
Uses the the configuredChannelLifecycleStrategy
to invokeStateManagedComponent.requestInit()
on the underlyingChannel
s in theList
.java.util.Iterator<Channel>
iterator()
int
lastIndexOf(java.lang.Object o)
java.util.ListIterator<Channel>
listIterator()
java.util.ListIterator<Channel>
listIterator(int index)
void
prepare()
Make sure we are ready for initialisation.Channel
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeChannel(Channel channel)
Remove a channel from this channel list.Channel
set(int index, Channel element)
void
setChannels(java.util.List<Channel> l)
Set the underlyingList
ofChannel
s.void
setLifecycleStrategy(ChannelLifecycleStrategy css)
Specify the strategy to use when handling channel lifecycle.int
size()
Returns the number ofChannel
s in thisChannelList
.void
start()
Uses the the configuredChannelLifecycleStrategy
to invokeStateManagedComponent.requestStart()
on the underlyingChannel
s in theList
.void
stop()
Uses the the configuredChannelLifecycleStrategy
to invokeStateManagedComponent.requestStop()
on the underlyingChannel
s in theList
.java.util.List<Channel>
subList(int fromIndex, int toIndex)
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
-
-
-
-
Constructor Detail
-
ChannelList
public ChannelList()
Creates a new instance.
-
ChannelList
public ChannelList(java.util.Collection<Channel> coll)
-
-
Method Detail
-
prepare
public void prepare() throws CoreException
Make sure we are ready for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
init
public void init() throws CoreException
Uses the the configured
ChannelLifecycleStrategy
to invokeStateManagedComponent.requestInit()
on the underlyingChannel
s in theList
.- Specified by:
init
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
start
public void start() throws CoreException
Uses the the configured
ChannelLifecycleStrategy
to invokeStateManagedComponent.requestStart()
on the underlyingChannel
s in theList
.- Specified by:
start
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Uses the the configured
ChannelLifecycleStrategy
to invokeStateManagedComponent.requestStop()
on the underlyingChannel
s in theList
.- Specified by:
stop
in interfaceComponentLifecycle
-
close
public void close()
Uses the the configured
ChannelLifecycleStrategy
to invokeStateManagedComponent.requestClose()
on the underlyingChannel
s in theList
.- Specified by:
close
in interfaceComponentLifecycle
-
getChannels
public java.util.List<Channel> getChannels()
Returns the underlying
List
ofChannel
s.- Returns:
- the underlying
List
ofChannels
-
setChannels
public void setChannels(java.util.List<Channel> l)
Set the underlying
List
ofChannel
s.- Parameters:
l
- the underlyingList
ofChannels
-
addChannel
public void addChannel(Channel channel)
Adds a
Channel
to the underlyingList
and validates its unique ID.- Parameters:
channel
- theChannel
to add
-
getChannel
public Channel getChannel(int pos)
Returns the
Channel
stored at the passedpos
in theList
.- Parameters:
pos
- the position in theList
- Returns:
- the
Channel
stored at the passedpos
in theList
-
size
public int size()
Returns the number of
Channel
s in thisChannelList
.
-
getChannel
public Channel getChannel(java.lang.String uniqueId)
Returns the
Channel
with the passeduniqueId
or null if no such channel exists.- Parameters:
uniqueId
- the unique ID of the Channel to return, may not be null or empty- Returns:
- the requested Channel or null if it doesn't exist, will always be null unless
prepare()
has been called.
-
getLifecycleStrategy
public ChannelLifecycleStrategy getLifecycleStrategy()
- Returns:
- the startStrategy
-
setLifecycleStrategy
public void setLifecycleStrategy(ChannelLifecycleStrategy css)
Specify the strategy to use when handling channel lifecycle.If not explicitly specified, then
DefaultChannelLifecycleStrategy
will be used to handle the channel operations.- Parameters:
css
- the strategy to set- See Also:
DefaultChannelLifecycleStrategy
,NonBlockingChannelStartStrategy
-
iterator
public java.util.Iterator<Channel> iterator()
-
remove
public boolean remove(java.lang.Object o)
-
removeChannel
public boolean removeChannel(Channel channel)
Remove a channel from this channel list.- Parameters:
channel
-- Returns:
- true if the channel was removed successfully.
-
add
public boolean add(Channel element)
-
add
public void add(int index, Channel element)
- Specified by:
add
in interfacejava.util.List<Channel>
-
addAll
public boolean addAll(int index, java.util.Collection<? extends Channel> c)
- Specified by:
addAll
in interfacejava.util.List<Channel>
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOf
in interfacejava.util.List<Channel>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interfacejava.util.List<Channel>
-
clear
public void clear()
-
listIterator
public java.util.ListIterator<Channel> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<Channel>
-
listIterator
public java.util.ListIterator<Channel> listIterator(int index)
- Specified by:
listIterator
in interfacejava.util.List<Channel>
-
set
public Channel set(int index, Channel element)
- Specified by:
set
in interfacejava.util.List<Channel>
-
-