|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.fosstrak.llrp.adaptor.AdaptorManagement
public class AdaptorManagement
The AdaptorManagement handles your adaptors, enqueues LLRPMessages, handles
errors from the reader site and notifies you about incoming LLRPMessages.
There are some common pitfalls when using the AdaptorManagement:
// create a message handler
MessageHandler msgHandler = new MessageHandler();
// create an exception handler
ExceptionHandler handler = new ExceptionHandler();
// run the initializer method
String readConfig = Utility.findWithFullPath("/readerDefaultConfig.properties");
String writeConfig = readConfig;
boolean commitChanges = true;
AdaptorManagement.getInstance().initialize(
readConfig, storeConfig, commitChanges, handler, msgHandler);
// now the management should be initialized and ready to be used
// create an adaptor
String adaptorName = "myAdaptor";
AdaptorManagement.getInstance().define(adaptorName, "localhost");
// create a reader
String readerName = "myReader";
Adaptor adaptor = AdaptorManagement.getAdaptor(adaptorName);
adaptor.define(readerName, "192.168.1.23", 5084, true, true);
//Enqueue some LLRPMessage on the adaptor
AdaptorManagement.enqueueLLRPMessage(adaptorName, readerName, message);
// when you shutdown your application call the shutdown method
AdaptorManagement.getInstance().shutdown();
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_ADAPTOR_NAME
the name for the default local adaptor. |
Method Summary | |
---|---|
void |
checkStatus()
check whether the AdaptorManagement is ok or not. |
void |
commit()
commits the configuration to the properties file. |
boolean |
containsAdaptor(java.lang.String adaptorName)
tells whether an adaptorName already exists. |
java.lang.String |
define(java.lang.String adaptorName,
java.lang.String address)
adds a new adaptor to the adaptor list. |
void |
deregisterFullHandler(MessageHandler handler)
remove a handler from the full handler list. |
void |
deregisterPartialHandler(MessageHandler handler,
java.lang.Class clzz)
remove a handler from the handlers list. |
void |
disconnectReaders()
disconnectReaders shuts down all local readers. |
void |
dispatchHandlers(java.lang.String adaptorName,
java.lang.String readerName,
org.llrp.ltk.types.LLRPMessage message)
dispatches an LLRP message to all the registered full handlers. |
void |
enqueueLLRPMessage(java.lang.String adaptorName,
java.lang.String readerName,
org.llrp.ltk.types.LLRPMessage message)
enqueue an LLRPMessage to be sent to a llrp reader. the adaptor will process the message when ready. |
Adaptor |
getAdaptor(java.lang.String adaptorName)
returns an adaptor to a given adaptorName. |
java.util.List<java.lang.String> |
getAdaptorNames()
returns a list of all the available adaptor names. |
AdaptorImpl |
getDefaultAdaptor()
helper to access the default local adaptor more convenient. |
LLRPExceptionHandler |
getExceptionHandler()
returns the exception handler. |
static AdaptorManagement |
getInstance()
returns the singleton of the AdaptorManagement. |
java.lang.String |
getReadConfig()
returns the configuration file where to read the settings. |
java.lang.String |
getStoreConfig()
returns the configuration file where to store changes. |
boolean |
hasFullHandler(MessageHandler handler)
tests whether a given handler is already registered or not. |
boolean |
hasPartialHandler(MessageHandler handler,
java.lang.Class clzz)
checks whether a given handler is registered at a given selector class. |
boolean |
initialize(java.lang.String readConfig,
java.lang.String storeConfig,
boolean commitChanges,
LLRPExceptionHandler exceptionHandler,
MessageHandler handler)
initializes the AdaptorManagement. |
boolean |
initialize(java.lang.String readConfig,
java.lang.String storeConfig,
boolean commitChanges,
LLRPExceptionHandler exceptionHandler,
MessageHandler handler,
boolean export)
ATTENTION: initializes the AdaptorManagement.DO NOT USE THIS METHOD as long as you know what you are doing (this method instructs with export=true to export the first local adaptor as a server adaptor. |
boolean |
isCommitChanges()
flags whether all changes to the AdaptorManagement get reflected to the configuration file. |
boolean |
isInitialized()
flags whether the AdaptorManagement has already been initialized. |
boolean |
isLocalAdapter(java.lang.String adapterName)
checks, whether a given adapter is a local adapter or not. |
boolean |
isReady(java.lang.String adaptorName)
you can check whether an adaptor is ready to accept messages. |
void |
loadFromFile()
loads the adaptorManagement configuration from file (holds the adaptors and the readers for the local adaptor). |
void |
postException(LLRPRuntimeException e,
LLRPExceptionHandlerTypeMap exceptionType,
java.lang.String adapterName,
java.lang.String readerName)
posts an exception the the exception handler. |
void |
registerFullHandler(MessageHandler handler)
register a handler that will receive all the incoming messages. |
void |
registerPartialHandler(MessageHandler handler,
java.lang.Class clzz)
register a handler that will receive only a restricted set of messages. |
void |
reset()
resets the management to initial state. |
void |
setCommitChanges(boolean commitChanges)
sets whether all changes to the AdaptorManagement get reflected to the configuration file. |
void |
setExceptionHandler(LLRPExceptionHandler exceptionHandler)
sets the exception handler. |
void |
setReadConfig(java.lang.String readConfig)
sets the configuration file. |
void |
setStoreConfig(java.lang.String storeConfig)
sets the configuration file where to store changes. |
void |
shutdown()
the client leaves the adaptor management. the management makes the cleanup. |
void |
storeToFile()
stores the configuration of the adaptor management to file. the remote adaptors get stored and for the local adaptor all readers get stored as well. |
void |
undefine(java.lang.String adaptorName)
removes an adaptor from the adaptor list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_ADAPTOR_NAME
Method Detail |
---|
public boolean initialize(java.lang.String readConfig, java.lang.String storeConfig, boolean commitChanges, LLRPExceptionHandler exceptionHandler, MessageHandler handler) throws LLRPRuntimeException
readConfig
- where the configuration shall be read from.storeConfig
- where the configuration shall be written to (if changes happen).commitChanges
- if storeConfig is set and commitChanges is true then all
the changes to the AdaptorManagement are committed to storeConfig.exceptionHandler
- the exception handler from the GUI.handler
- a handler to dispatch the LLRP messages (can be set to null).
LLRPRuntimeException
- whenever the AdaptorManagement could not be loaded.public boolean initialize(java.lang.String readConfig, java.lang.String storeConfig, boolean commitChanges, LLRPExceptionHandler exceptionHandler, MessageHandler handler, boolean export) throws LLRPRuntimeException
readConfig
- where the configuration shall be read from.storeConfig
- where the configuration shall be written to (if changes happen).commitChanges
- if storeConfig is set and commitChanges is true then all
the changes to the AdaptorManagement are committed to storeConfig.exceptionHandler
- the exception handler from the GUI.handler
- a handler to dispatch the LLRP messages (can be set to null).export
- if the first local adaptor is to be exported by RMI or not.
LLRPRuntimeException
- whenever the AdaptorManagement could not be loaded.public boolean isInitialized()
public void reset() throws LLRPRuntimeException
LLRPRuntimeException
- if an error occurs during reset.public void commit()
public void checkStatus() throws LLRPRuntimeException
LLRPRuntimeException
public void shutdown()
public void disconnectReaders()
public boolean containsAdaptor(java.lang.String adaptorName) throws LLRPRuntimeException
adaptorName
- the name of the adaptor to check.
LLRPRuntimeException
- whever something goes wrong ...public boolean isLocalAdapter(java.lang.String adapterName) throws LLRPRuntimeException
adapterName
- the name of the adapter to check.
LLRPRuntimeException
- whenever something goes wrong...public java.lang.String define(java.lang.String adaptorName, java.lang.String address) throws LLRPRuntimeException, java.rmi.RemoteException, java.rmi.NotBoundException
adaptorName
- the name of the new adaptor.address
- if you are using a client adaptor you have to provide the address of the server stub.
LLRPRuntimeException
- when either name already exists or when there occurs an error in adaptor creation.
java.rmi.RemoteException
- when there is an error during transmition.
java.rmi.NotBoundException
- when there is no registry available.public void undefine(java.lang.String adaptorName) throws LLRPRuntimeException
adaptorName
- the name of the adaptor to remove.
LLRPRuntimeException
- when either the name does not exist or when an internal runtime error occurs.public java.util.List<java.lang.String> getAdaptorNames() throws LLRPRuntimeException
LLRPRuntimeException
public Adaptor getAdaptor(java.lang.String adaptorName) throws LLRPRuntimeException
adaptorName
- the name of the requested adaptor.
LLRPRuntimeException
- when the adaptor does not exist.public AdaptorImpl getDefaultAdaptor() throws LLRPRuntimeException
LLRPRuntimeException
- this should never occur!public boolean isReady(java.lang.String adaptorName) throws LLRPRuntimeException
adaptorName
- the name of the adaptor to check.
LLRPRuntimeException
public void enqueueLLRPMessage(java.lang.String adaptorName, java.lang.String readerName, org.llrp.ltk.types.LLRPMessage message) throws LLRPRuntimeException
adaptorName
- the name of the adaptor holding the llrp reader.readerName
- the name of the llrp reader.message
- the LLRPMessage.
LLRPRuntimeException
- when the queue of the adaptor is full.public void registerFullHandler(MessageHandler handler)
handler
- the handler.public void deregisterFullHandler(MessageHandler handler)
handler
- the handler to be removed.public boolean hasFullHandler(MessageHandler handler)
handler
- the handler to check for.
public void registerPartialHandler(MessageHandler handler, java.lang.Class clzz)
handler
- the handler.clzz
- the type of messages that the handler likes to receive (example KEEPALIVE.class).public void deregisterPartialHandler(MessageHandler handler, java.lang.Class clzz)
handler
- the handler to remove.clzz
- the class where the handler is registered.public boolean hasPartialHandler(MessageHandler handler, java.lang.Class clzz)
handler
- the handler to check.clzz
- the class where to search for the handler.
public void dispatchHandlers(java.lang.String adaptorName, java.lang.String readerName, org.llrp.ltk.types.LLRPMessage message)
adaptorName
- the name of the adapter that received the message.readerName
- the reader that received the message.message
- the LLRP message itself.public void postException(LLRPRuntimeException e, LLRPExceptionHandlerTypeMap exceptionType, java.lang.String adapterName, java.lang.String readerName)
exceptionType
- the type of the exception. see LLRPExceptionHandler
for more details.adapterName
- the name of the adaptor that caused the exception.readerName
- the name of the reader that caused the exception.e
- the exception itself.public static AdaptorManagement getInstance()
public void loadFromFile() throws LLRPRuntimeException
LLRPRuntimeException
- whenever there is an exception during restoring.public void storeToFile() throws LLRPRuntimeException
LLRPRuntimeException
- whenever there occurs an error during storage.public LLRPExceptionHandler getExceptionHandler()
public void setExceptionHandler(LLRPExceptionHandler exceptionHandler)
exceptionHandler
- the exception handler.public boolean isCommitChanges()
public void setCommitChanges(boolean commitChanges)
commitChanges
- public java.lang.String getReadConfig()
public void setReadConfig(java.lang.String readConfig)
readConfig
- the configuration file.public java.lang.String getStoreConfig()
public void setStoreConfig(java.lang.String storeConfig)
storeConfig
- the configuration file where to store changes.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |