org.openadaptor.adaptor
Class LocalAsyncSource
java.lang.Object
org.openadaptor.adaptor.SimpleComponent
org.openadaptor.adaptor.AbstractReader
org.openadaptor.adaptor.AbstractSimpleSource
org.openadaptor.adaptor.AbstractSimpleSourceSink
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
Field Summary |
protected java.util.Vector |
_data
a queue of DataObjects to process |
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 |
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.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 |
_data
protected java.util.Vector _data
- a queue of DataObjects to process
LocalAsyncSource
public LocalAsyncSource()
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 componentprops
- Properties objectprefix
- Prefix string to search for propertiescontroller
- 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)