org.fosstrak.llrp.adaptor
Class AdaptorImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.fosstrak.llrp.adaptor.AdaptorImpl
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, Adaptor

public class AdaptorImpl
extends java.rmi.server.UnicastRemoteObject
implements Adaptor

This adaptor implements the Adaptor interface.

Author:
sawielan
See Also:
Serialized Form

Field Summary
protected  java.lang.String adaptorName
          the name of this adaptor.
protected  java.util.Map<java.lang.String,ReaderImpl> readers
          a map holding all the readers contained in this adaptor.
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
AdaptorImpl(java.lang.String adaptorName)
          Constructor for a adaptor.
 
Method Summary
 boolean containsReader(java.lang.String readerName)
          checks whether a readerName already exists.
 void define(java.lang.String readerName, java.lang.String readerAddress, boolean clientInitiatedConnection, boolean connectImmediately)
          defines a new LLRP reader on this adaptor.
 void define(java.lang.String readerName, java.lang.String readerAddress, int port, boolean clientInitiatedConnection, boolean connectImmediately)
          defines a new LLRP reader on this adaptor.
 void deregisterFromAsynchronous(AsynchronousNotifiable receiver)
          deregister from the asynchronous messages. the receiver will no more receive asynchronous llrp messages.
 void disconnectAll()
          disconnects all the LLRP readers from this adaptor.
 void errorCallback(LLRPRuntimeException e, java.lang.String readerName)
          callback interface for asynchronous error messages from the reader.
 java.lang.String getAdaptorName()
          returns the name of this adaptor.
 Reader getReader(java.lang.String readerName)
          returns a requested reader.
 java.util.List<java.lang.String> getReaderNames()
          returns a list of all currently registered LLRP readers.
 void messageReceivedCallback(byte[] message, java.lang.String readerName)
          when a asynchronous message arrives from the reader this method will be invoked. the message then gets dispatched to the registered receivers.
 void registerForAsynchronous(AsynchronousNotifiable receiver)
          register for asynchronous messages from the reader.
 void sendLLRPMessage(java.lang.String readerName, byte[] message)
          sends a llrp message to the specified reader.
 void sendLLRPMessageToAllReaders(byte[] message)
          sends a llrp message to all the readers.
 void setAdaptorManagement(AdaptorManagement management)
           
 void setAdaptorName(java.lang.String adaptorName)
          sets the name of the adaptor.
 void undefine(java.lang.String readerName)
          removes a LLRP reader from this adaptor.
 void undefineAll()
          removes all the LLRP readers from this adaptor.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

readers

protected java.util.Map<java.lang.String,ReaderImpl> readers
a map holding all the readers contained in this adaptor.


adaptorName

protected java.lang.String adaptorName
the name of this adaptor.

Constructor Detail

AdaptorImpl

public AdaptorImpl(java.lang.String adaptorName)
            throws java.rmi.RemoteException
Constructor for a adaptor.

Parameters:
adaptorName - the name of this adaptor.
Throws:
java.rmi.RemoteException - whenever there is an rmi exception.
Method Detail

containsReader

public boolean containsReader(java.lang.String readerName)
                       throws java.rmi.RemoteException
Description copied from interface: Adaptor
checks whether a readerName already exists.

Specified by:
containsReader in interface Adaptor
Parameters:
readerName - the name of the reader.
Returns:
true if the reader exists else false.
Throws:
java.rmi.RemoteException - when there was an rmi exception.

define

public void define(java.lang.String readerName,
                   java.lang.String readerAddress,
                   boolean clientInitiatedConnection,
                   boolean connectImmediately)
            throws java.rmi.RemoteException,
                   LLRPRuntimeException
Description copied from interface: Adaptor
defines a new LLRP reader on this adaptor.

Specified by:
define in interface Adaptor
Parameters:
readerName - the name of the LLRP reader.
readerAddress - the address where to contact the LLRP reader.
clientInitiatedConnection - LLRP allows two different ways how to create a connection to a reader.
  1. client initiated connection: in this model the client tries to establish the connection to the reader
  2. reader initiated connection: in this model the client waits for a reader to establish the connection
when you specify true a client initiated connection is established. otherwise a reader initiated connection.
connectImmediately - tells whether the reader shall establish connection immediately or not
  1. true: the reader tries to build up the connection immediately
  2. false: the reader is just created, but the connection to the physical reader will not be established yet. you need to run the connect command on the reader before you can use it!
Throws:
java.rmi.RemoteException - when there was an rmi exception.
LLRPRuntimeException - if a runtime exception occurs (like duplicate reader name etc. ...).

define

public void define(java.lang.String readerName,
                   java.lang.String readerAddress,
                   int port,
                   boolean clientInitiatedConnection,
                   boolean connectImmediately)
            throws java.rmi.RemoteException,
                   LLRPRuntimeException
Description copied from interface: Adaptor
defines a new LLRP reader on this adaptor.

Specified by:
define in interface Adaptor
Parameters:
readerName - the name of the LLRP reader.
readerAddress - the address where to contact the LLRP reader.
port - the port where to connect to.
clientInitiatedConnection - LLRP allows two different ways how to create a connection to a reader.
  1. client initiated connection: in this model the client tries to establish the connection to the reader
  2. reader initiated connection: in this model the client waits for a reader to establish the connection
when you specify true a client initiated connection is established. otherwise a reader initiated connection.
connectImmediately - tells whether the reader shall establish connection immediately or not
  1. true: the reader tries to build up the connection immediately
  2. false: the reader is just created, but the connection to the physical reader will not be established yet. you need to run the connect command on the reader before you can use it!
Throws:
java.rmi.RemoteException - when there was an rmi exception.
LLRPRuntimeException - if a runtime exception occurs (like duplicate reader name etc. ...).

getAdaptorName

public java.lang.String getAdaptorName()
                                throws java.rmi.RemoteException
Description copied from interface: Adaptor
returns the name of this adaptor.

Specified by:
getAdaptorName in interface Adaptor
Returns:
the name of this adaptor.
Throws:
java.rmi.RemoteException - when there was an rmi exception.

getReaderNames

public java.util.List<java.lang.String> getReaderNames()
                                                throws java.rmi.RemoteException
Description copied from interface: Adaptor
returns a list of all currently registered LLRP readers.

Specified by:
getReaderNames in interface Adaptor
Returns:
a list of all currently registered LLRP readers.
Throws:
java.rmi.RemoteException - when there was an rmi exception.

undefine

public void undefine(java.lang.String readerName)
              throws java.rmi.RemoteException,
                     LLRPRuntimeException
Description copied from interface: Adaptor
removes a LLRP reader from this adaptor.

Specified by:
undefine in interface Adaptor
Parameters:
readerName - the name of the LLRP reader to remove.
Throws:
java.rmi.RemoteException - when there was an rmi exception.
LLRPRuntimeException - if a runtime exception occurs (eg reader does not exist etc. ...).

undefineAll

public void undefineAll()
                 throws java.rmi.RemoteException,
                        LLRPRuntimeException
Description copied from interface: Adaptor
removes all the LLRP readers from this adaptor.

Specified by:
undefineAll in interface Adaptor
Throws:
java.rmi.RemoteException - when there was an rmi exception.
LLRPRuntimeException - if a runtime exception occurs (eg reader does not exist etc. ...).

disconnectAll

public void disconnectAll()
                   throws java.rmi.RemoteException,
                          LLRPRuntimeException
Description copied from interface: Adaptor
disconnects all the LLRP readers from this adaptor.

Specified by:
disconnectAll in interface Adaptor
Throws:
java.rmi.RemoteException - when there was an rmi exception.
LLRPRuntimeException - if a runtime exception occurs (eg reader does not exist etc. ...).

sendLLRPMessage

public void sendLLRPMessage(java.lang.String readerName,
                            byte[] message)
                     throws java.rmi.RemoteException,
                            LLRPRuntimeException
Description copied from interface: Adaptor
sends a llrp message to the specified reader.

Specified by:
sendLLRPMessage in interface Adaptor
Parameters:
readerName - the name of the reader where to send the message.
message - the llrp message.
Throws:
java.rmi.RemoteException - when there was an rmi exception.
LLRPRuntimeException - whever a runtime error occurs.

sendLLRPMessageToAllReaders

public void sendLLRPMessageToAllReaders(byte[] message)
                                 throws java.rmi.RemoteException,
                                        LLRPRuntimeException
Description copied from interface: Adaptor
sends a llrp message to all the readers.

Specified by:
sendLLRPMessageToAllReaders in interface Adaptor
Parameters:
message - the llrp message.
Throws:
java.rmi.RemoteException - when there was an rmi exception.
LLRPRuntimeException - whever a runtime error occurs.

registerForAsynchronous

public void registerForAsynchronous(AsynchronousNotifiable receiver)
                             throws java.rmi.RemoteException
Description copied from interface: Adaptor
register for asynchronous messages from the reader.

Specified by:
registerForAsynchronous in interface Adaptor
Parameters:
receiver - the receiver that shall be notified with the message.
Throws:
java.rmi.RemoteException - when there was an rmi exception.

messageReceivedCallback

public void messageReceivedCallback(byte[] message,
                                    java.lang.String readerName)
                             throws java.rmi.RemoteException
Description copied from interface: Adaptor
when a asynchronous message arrives from the reader this method will be invoked. the message then gets dispatched to the registered receivers.

Specified by:
messageReceivedCallback in interface Adaptor
Parameters:
message - the llrp message.
readerName - the name of the reader that triggered the event.
Throws:
java.rmi.RemoteException - when there was an rmi exception.

deregisterFromAsynchronous

public void deregisterFromAsynchronous(AsynchronousNotifiable receiver)
                                throws java.rmi.RemoteException
Description copied from interface: Adaptor
deregister from the asynchronous messages. the receiver will no more receive asynchronous llrp messages.

Specified by:
deregisterFromAsynchronous in interface Adaptor
Parameters:
receiver - the receiver to deregister.
Throws:
java.rmi.RemoteException - when there was an rmi exception.

errorCallback

public void errorCallback(LLRPRuntimeException e,
                          java.lang.String readerName)
                   throws java.rmi.RemoteException
Description copied from interface: Adaptor
callback interface for asynchronous error messages from the reader.

Specified by:
errorCallback in interface Adaptor
Parameters:
e - the exception that has been reported.
readerName - the name of the reader where the error occured.
Throws:
java.rmi.RemoteException - whenver there is an error on transport level (rmi).

getReader

public Reader getReader(java.lang.String readerName)
                 throws java.rmi.RemoteException
Description copied from interface: Adaptor
returns a requested reader.

Specified by:
getReader in interface Adaptor
Parameters:
readerName - the name of the requested reader.
Returns:
the reader.
Throws:
java.rmi.RemoteException - when there was an rmi exception.

setAdaptorName

public void setAdaptorName(java.lang.String adaptorName)
                    throws java.rmi.RemoteException
Description copied from interface: Adaptor
sets the name of the adaptor.

Specified by:
setAdaptorName in interface Adaptor
Parameters:
adaptorName - the name of the adaptor to set.
Throws:
java.rmi.RemoteException

setAdaptorManagement

public void setAdaptorManagement(AdaptorManagement management)


Copyright © 2009. All Rights Reserved.