autohit.common.channels
Class SimpleChannel

java.lang.Object
  extended byautohit.common.channels.SimpleChannel
All Implemented Interfaces:
Channel

public class SimpleChannel
extends java.lang.Object
implements Channel

Channel implementation Supports a simple, exclusive channel. There is no routing, but just a single priority level and type. Everything less than or equal to the priority set will match. Type is unimportant. It will accept multiple injectors, but only one Drain. Registering a new drain will replace the old. Only injection is thread safe. Nothing else is.

The injectors are unimporant. We'll just toss them in a table and let them rot.

Version:
1.0 Version History EPG - Initial - 25Apr03
Author:
Erich P. Gatejen

Field Summary
 
Fields inherited from interface autohit.common.channels.Channel
BAD_RECEIPT
 
Constructor Summary
SimpleChannel()
          Default constructor
 
Method Summary
 java.util.Enumeration enumInjector()
          Enumerate injectors
 Drain getDrain(java.lang.String name)
          Get a drain by name
 Injector getInjector(java.lang.String name)
          Get an injector by name
 Receipt inject(Atom a)
          Typically called by an injector
 void register(java.lang.String name, Drain d)
          Register a drain
 void register(java.lang.String name, Injector i)
          Register an injector
 void removeDrain(java.lang.String name)
          Remove a drain
 Receipt removeExclusive(java.lang.String name)
          Remove exclusive
 void removeInjector(java.lang.String name)
          Remove an injector
 Receipt removeLevel(java.lang.String name, int level)
          Remove level for named Drain
 Receipt removeType(java.lang.String name, int type)
          Request type
 Receipt requestLevel(java.lang.String name, int level)
          Request priority level for named Drain
 Receipt requestType(java.lang.String name, int type)
          Request type
 Receipt setExclusive(java.lang.String name)
          Set exclusive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleChannel

public SimpleChannel()
Default constructor

Method Detail

register

public void register(java.lang.String name,
                     Injector i)
              throws ChannelException
Register an injector

Specified by:
register in interface Channel
Parameters:
name - reference
i - An injector
Throws:
ChannelException
See Also:
Injector

register

public void register(java.lang.String name,
                     Drain d)
              throws ChannelException
Register a drain

Specified by:
register in interface Channel
Parameters:
name - reference
d - A drain
Throws:
ChannelException
See Also:
Drain

getDrain

public Drain getDrain(java.lang.String name)
               throws ChannelException
Get a drain by name

Specified by:
getDrain in interface Channel
Parameters:
name - Name reference to the drain
Returns:
Drain reference or null if not found
Throws:
ChannelException
See Also:
Drain

getInjector

public Injector getInjector(java.lang.String name)
                     throws ChannelException
Get an injector by name

Specified by:
getInjector in interface Channel
Parameters:
name - Name reference to the injector
Returns:
Injector reference or null if not found
Throws:
ChannelException
See Also:
Drain

removeInjector

public void removeInjector(java.lang.String name)
                    throws ChannelException
Remove an injector

Specified by:
removeInjector in interface Channel
Parameters:
name - reference
Throws:
ChannelException
See Also:
Injector

removeDrain

public void removeDrain(java.lang.String name)
                 throws ChannelException
Remove a drain

Specified by:
removeDrain in interface Channel
Parameters:
name - reference
Throws:
ChannelException
See Also:
Drain

inject

public Receipt inject(Atom a)
               throws ChannelException
Typically called by an injector

Specified by:
inject in interface Channel
Parameters:
a - An item
Returns:
receipt or null if failed
Throws:
ChannelException

requestLevel

public Receipt requestLevel(java.lang.String name,
                            int level)
                     throws ChannelException
Request priority level for named Drain

Specified by:
requestLevel in interface Channel
Parameters:
name - Drain's name
level - the level as specifies in an Atom
Throws:
ChannelException
See Also:
Atom

removeLevel

public Receipt removeLevel(java.lang.String name,
                           int level)
                    throws ChannelException
Remove level for named Drain

Specified by:
removeLevel in interface Channel
Parameters:
name - Drain's name
level - the level as specifies in an Atom
Throws:
ChannelException
See Also:
Atom

requestType

public Receipt requestType(java.lang.String name,
                           int type)
                    throws ChannelException
Request type

Specified by:
requestType in interface Channel
Parameters:
name - Drain's name
type - the type as specified in Atom
Throws:
ChannelException
See Also:
Atom

removeType

public Receipt removeType(java.lang.String name,
                          int type)
                   throws ChannelException
Request type

Specified by:
removeType in interface Channel
Parameters:
name - Drain's name
type - the type as specified in Atom
Throws:
ChannelException
See Also:
Atom

setExclusive

public Receipt setExclusive(java.lang.String name)
                     throws ChannelException
Set exclusive

Specified by:
setExclusive in interface Channel
Parameters:
name - Drain's name
Throws:
ChannelException

removeExclusive

public Receipt removeExclusive(java.lang.String name)
                        throws ChannelException
Remove exclusive

Specified by:
removeExclusive in interface Channel
Parameters:
name - Drain's name
Throws:
ChannelException

enumInjector

public java.util.Enumeration enumInjector()
                                   throws ChannelException
Enumerate injectors

Specified by:
enumInjector in interface Channel
Returns:
an enumeration of injectors
Throws:
ChannelException
See Also:
Injector


Test.