org.openadaptor.adaptor
Class LocalAsyncSource

java.lang.Object
  extended by org.openadaptor.adaptor.SimpleComponent
      extended by org.openadaptor.adaptor.AbstractReader
          extended by org.openadaptor.adaptor.AbstractSimpleSource
              extended by org.openadaptor.adaptor.AbstractSimpleSourceSink
                  extended by org.openadaptor.adaptor.LocalAsyncSource
All Implemented Interfaces:
java.lang.Runnable, CallbackProvider, Component, Configurable, IbafTransactionalResource, Sink, Source, DOMessageReaderDelegate

public class LocalAsyncSource
extends AbstractSimpleSourceSink

 This adaptor component is designed to let you run an adaptor "inVM" and
 send it data to process directly from your code. The source will process
 requests asynchronously
 
 You can use one of the following methods...
    void process(DataObject[] dobs)
 or
    void process(String text)
 in the latter case, the Source will assume you are sending DOXML unless you
 attach a DOStringReader to the Source. If it is unable to convert the text to
 a DataObject array then an IbafException will be thrown BUT note that if
 adaptor transaction fails you wont get any notification so will have to
 implement some asynchronous ack/nack.
 
 You can get access to components using RunAdaptor.getComponentByName(String)
 

Author:
fred

Nested Class Summary
 
Nested classes/interfaces inherited from class org.openadaptor.adaptor.AbstractSimpleSource
AbstractSimpleSource.SourceListenThread
 
Nested classes/interfaces inherited from class org.openadaptor.adaptor.SimpleComponent
SimpleComponent.StateHolder
 
Field Summary
protected  java.util.Vector _data
          a queue of DataObjects to process
 
Fields inherited from class org.openadaptor.adaptor.AbstractSimpleSourceSink
responses
 
Fields inherited from class org.openadaptor.adaptor.AbstractSimpleSource
_last_processed_time, _max_calls_per_poll, _num_polls, _num_processed, _source_type, CALLBACK_SOURCE, LISTEN_SOURCE, log, POLL_SOURCE
 
Fields inherited from class org.openadaptor.adaptor.AbstractReader
_batch_size, _comment_regexps, _end_data, _file_name, _file_name_att, _header_lines, _re_compiler, _re_matcher, _reader, _rec_num, _rec_num_att, _record_regexps, _start_data, _stream_reader, _string_reader, _useAlternateDOXMLReader
 
Fields inherited from class org.openadaptor.adaptor.SimpleComponent
_callbackManager, _controller, _formatter, _name, _propsPrefix, _readerDelegate, _textEncoding, MESSAGE_WRITER_PREFIX, MESSAGEID_ATTR, TEXT_ENCODING_ATTR
 
Constructor Summary
LocalAsyncSource()
           
 
Method Summary
 void init(java.lang.String name, java.util.Properties props, java.lang.String prefix, Controller controller)
          This is a callback source.
 void process(DataObject[] dobs)
          process these dataobjects asynchronously
 void process(java.lang.String text)
          process this string record asynchronously, throws and exception if record cannot be converted to DataObject array
 DataObject[] sourcePoll()
          this method is repeatedly called by the adaptor source thread
 void txnCommit()
          called when adaptor commits a transaction
 
Methods inherited from class org.openadaptor.adaptor.AbstractSimpleSourceSink
processHospitalException, processMessage, sourceProcess
 
Methods inherited from class org.openadaptor.adaptor.AbstractSimpleSource
getPollPeriod, getSourceType, getStatus, processMessage, processMessage, processMessageWithTxn, run, runCallback, runListen, runPoll, setMaxCallsPerPoll, setPollPeriod, setSourceType, sourceCleanUp, sourceHasTransactionRecovery, sourceListen, sourcePause, sourceProcess, sourceProcess, sourceResume, sourceStartUp, sourceStop, sourceTransactionBegin, sourceTransactionProcess
 
Methods inherited from class org.openadaptor.adaptor.AbstractReader
getDOStreamReader, getDOStringReader, getLineNumberReader, getReader, getXMLString, isReaderEOF, isWhitespace, nextDataObjectArray, readDOStreamReader, readDOStringReader, readDOXML, readDOXMLAlternate, readerCleanUp, readerEOF, readerException, readerStartUp, setDOStringReader, setHeaderLines, setReader
 
Methods inherited from class org.openadaptor.adaptor.SimpleComponent
addCallback, canUpdateWhileRunning, cleanUp, customControl, didReceiveMessage, getAsProperties, getCallbackManager, getCurrentState, getCustomControlProperties, getLastUID, getName, getProperty, getProperty, getPropsPrefix, getRequestedState, getSecurityManager, getTextEncoding, getXMLFormatter, notifyEvent, pause, removeCallback, resume, setCallbackManager, setCallbackManager, setCurrentState, setFromProperties, setFromProperties, setFromResource, setName, setPropsPrefix, setRequestedState, terminate, txnBegin, txnCommitWithExceptions, txnRollback, txnRollback, waitForRequestedStateChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openadaptor.adaptor.Component
cleanUp, customControl, getName, getPropsPrefix, getRequestedState, getStatus, pause, resume, setName, setPropsPrefix, terminate
 
Methods inherited from interface org.openadaptor.adaptor.IbafTransactionalResource
txnBegin, txnCommitWithExceptions, txnRollback, txnRollback
 
Methods inherited from interface org.openadaptor.adaptor.Configurable
canUpdateWhileRunning, getAsProperties, setFromProperties, setFromProperties
 
Methods inherited from interface org.openadaptor.adaptor.CallbackProvider
addCallback, getCallbackManager, notifyEvent, removeCallback, setCallbackManager, setCallbackManager
 

Field Detail

_data

protected java.util.Vector _data
a queue of DataObjects to process

Constructor Detail

LocalAsyncSource

public LocalAsyncSource()
Method Detail

init

public void init(java.lang.String name,
                 java.util.Properties props,
                 java.lang.String prefix,
                 Controller controller)
          throws IbafException
This is a callback source. Messages will be received by your program code that will call process() on this source directly.

Specified by:
init in interface Component
Overrides:
init in class AbstractSimpleSource
Parameters:
name - The name to be given to the component
props - Properties object
prefix - Prefix string to search for properties
controller - The component's controller object
Throws:
IbafException - Thrown if initialisation fails, mandatory properties are missing or properties cannot be parsed.
See Also:
Controller, SimpleController

sourcePoll

public DataObject[] sourcePoll()
                        throws IbafException
this method is repeatedly called by the adaptor source thread

Overrides:
sourcePoll in class AbstractSimpleSource
Throws:
IbafException

process

public void process(DataObject[] dobs)
process these dataobjects asynchronously


process

public void process(java.lang.String text)
             throws IbafException
process this string record asynchronously, throws and exception if record cannot be converted to DataObject array

Throws:
IbafException

txnCommit

public void txnCommit()
               throws IbafException
called when adaptor commits a transaction

Specified by:
txnCommit in interface IbafTransactionalResource
Overrides:
txnCommit in class SimpleComponent
Throws:
IbafException - If fails to commit the transaction
See Also:
Controller.txnCommit(Source)