org.fosstrak.llrp.adaptor
Class AdaptorWorker

java.lang.Object
  extended by org.fosstrak.llrp.adaptor.AdaptorWorker
All Implemented Interfaces:
java.lang.Runnable

public class AdaptorWorker
extends java.lang.Object
implements java.lang.Runnable

an LLRPAdaptorWorker holds an Adaptor and a callback. the worker enqueues messages and dispatches them to the corresponding reader. through the callback it can retrieve messages that then will be dispatched to the MessageRepository.

Author:
sawielan

Field Summary
static int MAX_CONN_FAILURES
          the number of allowed connection failures between adaptor and client.
static int QUEUE_THRESHOLD
          the worker does not accept more messages in the queue than this threshold.
 
Constructor Summary
AdaptorWorker(AdaptorCallback callback, Adaptor adaptor)
          creates a new LLRPAdaptorWorker.
 
Method Summary
 void cleanConnFailure()
          resets the connection failure counter to zero.
 void enqueue(QueueEntry e)
          enqueues a message to be sent.
 Adaptor getAdaptor()
          the adaptor holding the connection to the readers.
 java.lang.String getAdaptorIpAddress()
          returns the ip address of this adaptor. if its the local adaptor it returns null.
 AdaptorCallback getCallback()
          returns the callback for asynchronous message retrieval.
 boolean isReady()
          signals whether this worker is ready to accept messages.
 boolean ok()
           
 void reportConnFailure()
          increases the connection failure counter by one.
 void run()
           
 void setAdaptor(Adaptor adaptor)
          sets the adaptor holding the connection to the readers.
 void setAdaptorIpAddress(java.lang.String adaptorIpAddress)
          sets the address of this adaptor. if its the local adaptor set null.
 void setCallback(AdaptorCallback callback)
          sets the callback for asynchronous message retrieval.
 void tearDown()
          call this method if you want to stop the worker thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUEUE_THRESHOLD

public static final int QUEUE_THRESHOLD
the worker does not accept more messages in the queue than this threshold.

See Also:
Constant Field Values

MAX_CONN_FAILURES

public static final int MAX_CONN_FAILURES
the number of allowed connection failures between adaptor and client.

See Also:
Constant Field Values
Constructor Detail

AdaptorWorker

public AdaptorWorker(AdaptorCallback callback,
                     Adaptor adaptor)
creates a new LLRPAdaptorWorker.

Parameters:
callback - the callback for asynchronous message retrieval.
adaptor - the adaptor holding the connection to the readers.
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

tearDown

public void tearDown()
call this method if you want to stop the worker thread.


getCallback

public AdaptorCallback getCallback()
returns the callback for asynchronous message retrieval.

Returns:
the callback for asynchronous message retrieval.

setCallback

public void setCallback(AdaptorCallback callback)
sets the callback for asynchronous message retrieval.

Parameters:
callback - the callback for asynchronous message retrieval.

getAdaptor

public Adaptor getAdaptor()
the adaptor holding the connection to the readers.

Returns:
the adaptor holding the connection to the readers.

setAdaptor

public void setAdaptor(Adaptor adaptor)
sets the adaptor holding the connection to the readers.

Parameters:
adaptor - the adaptor holding the connection to the readers.

isReady

public boolean isReady()
signals whether this worker is ready to accept messages.

Returns:
true if ok, else otherwise.

enqueue

public void enqueue(QueueEntry e)
             throws LLRPRuntimeException
enqueues a message to be sent.

Parameters:
e - the queue element holding the message.
Throws:
LLRPRuntimeException - when worker is not ready or queue is full

getAdaptorIpAddress

public java.lang.String getAdaptorIpAddress()
returns the ip address of this adaptor. if its the local adaptor it returns null.

Returns:
null if local adaptor else the address of the adaptor.

setAdaptorIpAddress

public void setAdaptorIpAddress(java.lang.String adaptorIpAddress)
sets the address of this adaptor. if its the local adaptor set null.

Parameters:
adaptorIpAddress - the address of the adaptor.

reportConnFailure

public void reportConnFailure()
increases the connection failure counter by one.


cleanConnFailure

public void cleanConnFailure()
resets the connection failure counter to zero.


ok

public boolean ok()
Returns:
true if connection to adaptor is alright, false otherwise.


Copyright © 2009. All Rights Reserved.