Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.alien.enterpriseRFID.notify
Class MessageListenerService

    java.lang.Object
      com.alien.enterpriseRFID.notify.MessageListenerService

All Implemented Interfaces:
  MessageListener, java.lang.Runnable

public class MessageListenerService
extends java.lang.Object
implements java.lang.Runnable, MessageListener

MessageListenerService is a class for receiving notification messages from a Reader. This class will listen for incoming messages, and if found will hand off the socket to a MessageListenerEngine. The MessageListenerEngine parses the notification, packs the data into a `Message` object, and hands it off to a registered `MessageListener`.

This listener runs in the background on its own thread.

Version:
  3.0 Sep 2011
Author:
  David Krull

Constructor Summary
`MessageListenerService()` Constructs a MessageListenerService which listens for reader notifications on the default port, 3600.
`MessageListenerService(int listenerPort)` Constructs a MessageListenerService which listens for reader notifications on the port specified by `listenerPort`, using the default (chosen by ServerSocket) Ethernet interface.
`MessageListenerService(int listenerPort, java.net.InetAddress listenerInterface)` Constructs a MessageListenerService which listens for reader notifications on the port specified by `listenerPort`, using the specified Ethernet interface.

Method Summary
`java.net.InetAddress` | `getListenerInterface()` Returns the interface IP address that this `MessageListenerService` is listening on for reader notification messages.
`int` | `getListenerPort()` Returns the port number that this `MessageListenerService` is listening on for reader notification messages.
`MessageListener` | `getMessageListener()` Returns the `MessageListener` object that has been registered by this `MessageListenerService` to be notified when reader notifications arrive.
`boolean` | `isCustomTagList()` Returns the flag indicating whether this `MessageListenerService` should use the custom taglist decoder, or the standard "Text" format decoder.
`boolean` | `isRunning()` Indicates if this `MessageListenerService` is currently running.
`void` | `messageReceived(Message message)` Daughter MessageListenerEngines pass their message events up to the server, and the server hands them up to the user's MessageListener.
`void` | `run()` Runs the MessageListenerService.
`void` | `setDebug(boolean isDebug)` Sets the internal debug flag for this `MessageListenerService`.
`void` | `setIsCustomTagList(boolean isCustom)` Sets the flag indicating whether this `MessageListenerService` should use the custom taglist decoder, or the standard "Text" format decoder.
`void` | `setListenerInterface(java.net.InetAddress listenerInterface)` Specifies the interface IP address for this `MessageListenerService` to listen on for reader notification messages.
`void` | `setListenerPort(int listenerPort)` Specifies the port number for this `MessageListenerService` to listen on for reader notification messages.
`void` | `setMessageListener(MessageListener messageListener)` Registers a `MessageListener` with this `MessageListenerService` to be notified when a new notification message is received from a reader.
`void` | `startService()` Starts this `MessageListenerService`.
`void` | `stopService()` Stops this `MessageListenerService`.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MessageListenerService

    public MessageListenerService()

  Constructs a MessageListenerService which listens for reader notifications on the default port, 3600. The Java API picks one default Ethernet interface, if you have more than one. Once a MessageListenerService is constructed, it still requires starting. To specify a different listening port, use `MessageListenerService(int)`, or `setListenerPort(int)`.

See Also:
  `startService()`

### MessageListenerService

    public MessageListenerService(int listenerPort)

  Constructs a MessageListenerService which listens for reader notifications on the port specified by `listenerPort`, using the default (chosen by ServerSocket) Ethernet interface. Once a MessageListenerService is constructed, it still requires starting.

Parameters:
  `listenerPort` - the port to listen on for reader notifications
See Also:
  `startService()`

### MessageListenerService

    public MessageListenerService(int listenerPort,
                                  java.net.InetAddress listenerInterface)

  Constructs a MessageListenerService which listens for reader notifications on the port specified by `listenerPort`, using the specified Ethernet interface. Once a MessageListenerService is constructed, it still requires starting.

Parameters:
  `listenerPort` - the port to listen on for reader notifications
  `listenerInterface` - the InetAddress of the interface to listen on
See Also:
  `startService()`

Method Detail

### setDebug

    public void setDebug(boolean isDebug)

  Sets the internal debug flag for this `MessageListenerService`. Setting the debug flag `true` causes diagnostic messages to be sent to System.out.

  Parameters:
    `isDebug` - the new setting for the internal debug flag

### getListenerPort

    public int getListenerPort()

  Returns the port number that this `MessageListenerService` is listening on for reader notification messages.

  Returns:
    the port number to listen on
  See Also:
    `setListenerPort(int)`

### setListenerPort

    public void setListenerPort(int listenerPort)

  Specifies the port number for this `MessageListenerService` to listen on for reader notification messages.

  Parameters:
    `listenerPort` - the port number to listen on
  See Also:
    `getListenerPort()`

### getListenerInterface

    public java.net.InetAddress getListenerInterface()

  Returns the interface IP address that this `MessageListenerService` is listening on for reader notification messages.

  Returns:
    the interface IP to listen on
  See Also:
    `setListenerInterface(InetAddress)`

### setListenerInterface

    public void setListenerInterface(java.net.InetAddress listenerInterface)

  Specifies the interface IP address for this `MessageListenerService` to listen on for reader notification messages.

  Parameters:
    `listenerInterface` - the IP address to listen on
  See Also:
    `getListenerInterface()`

### getMessageListener

    public MessageListener getMessageListener()

  Returns the `MessageListener` object that has been registered by this `MessageListenerService` to be notified when reader notifications arrive.

  Returns:
    the registered MessageListener object
  See Also:
    `setMessageListener(MessageListener)`

### setMessageListener

    public void setMessageListener(MessageListener messageListener)

  Registers a `MessageListener` with this `MessageListenerService` to be notified when a new notification message is received from a reader.

  Parameters:
    `messageListener` - the MessageListener object to be registered
  See Also:
    `getMessageListener()`

### isCustomTagList

    public boolean isCustomTagList()

  Returns the flag indicating whether this `MessageListenerService` should use the custom taglist decoder, or the standard "Text" format decoder.

  Returns:
    the boolean isCustomTagList flag
  See Also:
    `setIsCustomTagList(boolean)`

### setIsCustomTagList

    public void setIsCustomTagList(boolean isCustom)

  Sets the flag indicating whether this `MessageListenerService` should use the custom taglist decoder, or the standard "Text" format decoder.

  Parameters:
    `isCustom` - the boolean flag
  See Also:
    `isCustomTagList()`

### startService

    public void startService()
                      throws java.io.IOException

  Starts this `MessageListenerService`. Once started, it waits for messages to arrive on its listener port, decodes them, and passes the resulting `Message` object to any registered `MessageListener`.

  Throws:
    `java.io.IOException` - if the service could not bind to the given port
  See Also:
    `stopService()`

### stopService

    public void stopService()

  Stops this `MessageListenerService`. It will no longer react to notification messages sent to its listener port by readers, and these messages will be lost. The `MessageListenerService` can be restarted by calling its `startService()` method.

  See Also:
    `startService()`

### run

    public void run()

  Runs the MessageListenerService.

  Specified by:
    `run` in interface `java.lang.Runnable`
  See Also:
    `isRunning()`

### isRunning

    public boolean isRunning()

  Indicates if this `MessageListenerService` is currently running.

  Returns:
    `true` if the service is running, `false` otherwise

### messageReceived

    public void messageReceived(Message message)

  Daughter MessageListenerEngines pass their message events up to the server, and the server hands them up to the user's MessageListener.

  Specified by:
    `messageReceived` in interface `MessageListener`
  Parameters:
    `message` - the Message received from a reader

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD