Package org.jcsp.net.dynamic
Class MigratableAltingChannelInputImpl
- java.lang.Object
-
- org.jcsp.lang.Guard
-
- org.jcsp.lang.AltingChannelInput<T>
-
- org.jcsp.lang.AltingChannelInputWrapper
-
- org.jcsp.net.NetAltingChannelInput
-
- org.jcsp.net.dynamic.MigratableAltingChannelInput
-
- org.jcsp.net.dynamic.MigratableAltingChannelInputImpl
-
- All Implemented Interfaces:
java.io.Serializable,ChannelInput,Poisonable,MigratableChannelInput,NetChannelInput,Networked,FilteredChannelInput,ReadFiltered
class MigratableAltingChannelInputImpl extends MigratableAltingChannelInput
Implements a migratable input channel end that can be used in anAlternative.
-
-
Field Summary
Fields Modifier and Type Field Description private NetAltingChannelInputactualInThe actual channel input.(package private) static FilteredChannelEndFactoryFACTORYFactory for creating filtered channel ends.private FilteredChannelInputfilteredInA filtered channel input wrapper that wraps theactualInchannel.private java.util.VectorfiltersA Vector ofFilterobjects that is used during serialization.private InputReconnectionManagermgrThe reconnection manager for the channel.
-
Constructor Summary
Constructors Constructor Description MigratableAltingChannelInputImpl(InputReconnectionManager mgr)Constructs a newMigratableAltingChannelInputImplwith a specified reconnection manager object.MigratableAltingChannelInputImpl(NetAltingChannelInput in)Constructor for MigratableAltingChannelInputImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReadFilter(Filter filter)Installs a read filter defining a transformation to be applied by thereadmethod of the channel end.voidaddReadFilter(Filter filter, int index)Installs a read filter defining a transformation to be applied by thereadmethod of the channel end at a specific index.voiddestroyReader()Destroys the channel end and frees any resources within the JCSP.NET infrastructure.NetChannelLocationgetChannelLocation()Returns the location of theNetworkedChannelInput.java.lang.ClassgetFactoryClass()Returnsnull.FiltergetReadFilter(int index)Returns the read filter installed at the given index.intgetReadFilterCount()Returns the number of read filters currently installed.voidprepareToMove()Prepares the channel end for movement to another node.java.lang.Objectread()Reads an object from the underlying channel.private voidreadObject(java.io.ObjectInputStream in)Reads the serialized object from an input stream.voidremoveReadFilter(int index)Removes the read filter installed at the given index.voidremoveReadFilter(Filter filter)Removes the first read filter (lowest index) matching the filter given as a parameter.private voidwriteObject(java.io.ObjectOutputStream out)When serializing object to the output stream, the filters from the underlying channel are extracted so that they too get serialized.-
Methods inherited from class org.jcsp.lang.AltingChannelInputWrapper
endRead, getChannel, pending, poison, setChannel, startRead
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jcsp.lang.ChannelInput
endRead, startRead
-
Methods inherited from interface org.jcsp.lang.Poisonable
poison
-
-
-
-
Field Detail
-
FACTORY
static FilteredChannelEndFactory FACTORY
Factory for creating filtered channel ends.
-
actualIn
private transient NetAltingChannelInput actualIn
The actual channel input. This should not be read from. Use thefilteredInchannel.
-
filteredIn
private transient FilteredChannelInput filteredIn
A filtered channel input wrapper that wraps theactualInchannel.
-
mgr
private InputReconnectionManager mgr
The reconnection manager for the channel.
-
filters
private java.util.Vector filters
A Vector ofFilterobjects that is used during serialization.
-
-
Constructor Detail
-
MigratableAltingChannelInputImpl
public MigratableAltingChannelInputImpl(NetAltingChannelInput in)
Constructor for MigratableAltingChannelInputImpl. This takes aNetAltingChannelInputand constructs a defaultInputReconnectionManagerobject and then uses the constructor taking a singleInputReconnectionManagerobject.MigratableAltingChannelInputImplobjects constructed with this constructor make use of the default channel name service.- Parameters:
in- the actualNetAltingChannelInputobject to use.
-
MigratableAltingChannelInputImpl
public MigratableAltingChannelInputImpl(InputReconnectionManager mgr)
Constructs a newMigratableAltingChannelInputImplwith a specified reconnection manager object. This should have been given the channel when it was constructed.- Parameters:
mgr- the reconnection manager.
-
-
Method Detail
-
getChannelLocation
public NetChannelLocation getChannelLocation()
Description copied from interface:NetworkedReturns the location of theNetworkedChannelInput.- Returns:
- the
NetChannelLocationobject. - See Also:
Networked.getChannelLocation()
-
read
public java.lang.Object read()
Reads an object from the underlying channel.- Specified by:
readin interfaceChannelInput- Overrides:
readin classAltingChannelInputWrapper- Returns:
- the object read.
-
addReadFilter
public void addReadFilter(Filter filter)
Description copied from interface:ReadFilteredInstalls a read filter defining a transformation to be applied by thereadmethod of the channel end. The filter will be appended to the end of the current list, making it the last to be applied.- Parameters:
filter- the filter to be installed; may not be null.- See Also:
ReadFiltered.addReadFilter(Filter)
-
addReadFilter
public void addReadFilter(Filter filter, int index)
Description copied from interface:ReadFilteredInstalls a read filter defining a transformation to be applied by thereadmethod of the channel end at a specific index. If there is already a filter at that index position the existing filters are shifted to make room. If the index is greater than the number of filters already installed the filter is placed at the end.- Parameters:
filter- the filter to be installed; may not be null.index- the zero based index; may not be negative.- See Also:
ReadFiltered.addReadFilter(Filter, int)
-
removeReadFilter
public void removeReadFilter(Filter filter)
Description copied from interface:ReadFilteredRemoves the first read filter (lowest index) matching the filter given as a parameter. The filter removed,r, will satisfy the conditionr.equals (filter). The remaining filters are shifted to close the gap in the index allocation.- Parameters:
filter- the filter to be removed; may not be null.- See Also:
ReadFiltered.removeReadFilter(Filter)
-
removeReadFilter
public void removeReadFilter(int index)
Description copied from interface:ReadFilteredRemoves the read filter installed at the given index. The remaining filters are shifted to close the gap in the index allocation.- Parameters:
index- zero-based index of the filter to be removed.- See Also:
ReadFiltered.removeReadFilter(int)
-
getReadFilter
public Filter getReadFilter(int index)
Description copied from interface:ReadFilteredReturns the read filter installed at the given index.- Parameters:
index- zero-based index of the filter to return.- Returns:
- the filter at that position.
- See Also:
ReadFiltered.getReadFilter(int)
-
getReadFilterCount
public int getReadFilterCount()
Description copied from interface:ReadFilteredReturns the number of read filters currently installed.- See Also:
ReadFiltered.getReadFilterCount()
-
destroyReader
public void destroyReader()
Description copied from interface:NetChannelInputDestroys the channel end and frees any resources within the JCSP.NET infrastructure.
- See Also:
org.jcsp.net.NetChannelInputManager#destroyReader()
-
getFactoryClass
public java.lang.Class getFactoryClass()
Returnsnull.- Returns:
- the
Classof the factory class.
-
prepareToMove
public void prepareToMove()
Description copied from interface:MigratableChannelInputPrepares the channel end for movement to another node.- See Also:
org.jcsp.dynamic.MigratableChannelInput#prepareToMove()
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOExceptionWhen serializing object to the output stream, the filters from the underlying channel are extracted so that they too get serialized.- Parameters:
out- the stream to write the object to.- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundExceptionReads the serialized object from an input stream. The default read implementation is used.- Parameters:
in- object source stream.- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-