|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openadaptor.adaptor.SimpleReaderDelegate
public class SimpleReaderDelegate
SimpleReaderDelegate is a class that can potentially be used by all Reader based Sources (e.g. FileSource, JMSSource), or independently, for example, by a J2EE message-driven-bean.
It is a meld of AbstractReader and DOXML reader code (from SimpleComponent) and includes the code to create a security manager (from SimpleController).
Some further re-factoring may be introduced in future releases.
From dealbus 2.1 onwards all Sources can have an assigned DOStringWriter DOStringWriters are use to delegate the work of converting string records to DataObjects. If a Source does not have a DOStringWriter then it is either interfacing to a specific API (eg: jdbc) or using the built in doconverter to read the internal dealbus formats.
Use the following property to assign an instance of a DOStringReader class
DOStringReader class name of a org.openadaptor.dostrings.DOStringReader
Interpretation of record formats is delegated to the DOStringReader assigned to this source.
Developers that wish to process strings with custom formats cam simply implement a new DOStringReader and assign this via the Source properties.
If SimpleReaderDelegate has no defined DOStringReader it uses the built in XMLFormatter.
The SimpleReaderDelegate supports the ability to ignore an arbitary number of headerlines and a much more powerful ability to specify regular expressions for comment lines and record lines. @see #init for properties and further explanation.
You need to refer to the assigned DOStringReader for the properties supported. The properties for this class are as follows
BatchSize Number of records (DataObjects) per DataObject array IgnoreHeaderLines Number of header lines to expected, and ignore CommentRegExpN A regular expression pattern for a comment line RecordRegExpN A regular expression for a record line UseAlternateDOXMLReader If true, uses different, but considerably slower, algorithm to read DO XML documents. This algorithm was formerly used by FileSource as a workaround to a problem reading very high volume multi-document DO XML format files. [Optional, default false]
If no Record regular expressions are defined then all lines are candiates for a record. If there are one or more Record regular expressions then a line is only a record if it matches one. If there are one or more comment regular expressions then a line is not a record if it matches one.
See also the properties supported by getXMLFormatter()
.
The openadaptor SecurityManager properties are also supported.
The MDBAdaptorListener class has been tested using
Note: With the JavaSoft J2EE reference implementation there may be permissioning restrictions which prevent proper functioning of the TestSecurityManager in its current form. You may need to adjust your J2EE security policy settings to permit dynamic add of security providers and to permit access to the filesystem location containing the openadaptor security configuration files.
For example, the TestSecurityManager assumes it can add cryptix as a provider dynamically. Default J2EE permissions may prohibit this. Even if cryptix is already added as a provider in the java.security file, the TestSecurityManager also assumes it can read security configuration properties from the filesystem. Again, default J2EE permissions may prohibit this.
DOStringReader
,
DOStringReaderWriter
,
DelimitedStringReader
,
FixedWidthStringReader
Field Summary | |
---|---|
protected int |
_batch_size
The number of records (DataObjects) to be sent in each Data Object array (0 = whole file). |
protected org.apache.oro.text.regex.Pattern[] |
_comment_regexps
array of regular expressions checkers that are used to match comments / line sto ignore in the file |
protected java.lang.String |
_end_data
|
protected XMLFormatter |
_formatter
holds the formatter that should be used by all component to to read and write adaptor framework message (XML) |
protected int |
_header_lines
The number of header lines expected in the data, these will be discarded before attempting process records or XML |
protected java.lang.String |
_prefix
|
protected java.util.Properties |
_properties
Reference to properties object and prefix. |
protected org.apache.oro.text.regex.Perl5Compiler |
_re_compiler
|
protected org.apache.oro.text.regex.Perl5Matcher |
_re_matcher
regex compiler and matcher |
protected java.io.Reader |
_reader
The input reader |
protected DOMessageReaderDelegate |
_readerDelegate
the next delegate for components that implement the DOMessageReaderDelegate interface |
protected org.apache.oro.text.regex.Pattern[] |
_record_regexps
array of regular expressions checkers that are used to match records explictily. |
protected OASecurityManager |
_secManager
security manager |
protected java.lang.String |
_start_data
Tags that signify the begining and ending of the data block. |
protected DOStringReader |
_string_reader
dataobject string reader assigned to this source |
protected boolean |
_useAlternateDOXMLReader
char buffer used to read data object XML into when reading multi-document DO XML source using readDOXMLAlternate(). |
(package private) static org.apache.log4j.Logger |
log
|
static java.lang.String |
MESSAGE_WRITER_PREFIX
component prefix for MessageWriter properties |
static java.lang.String |
MESSAGEID_ATTR
constant for unique identifier attribute name |
Constructor Summary | |
---|---|
SimpleReaderDelegate()
|
Method Summary | |
---|---|
protected void |
createSecurityManager(java.util.Properties props,
java.lang.String prefix)
Creates and initialises the OASecurityManager if "SecurityManager.Enabled" is "true" in the properties file. |
boolean |
didReceiveMessage(AbstractMessageReader sender,
DataObject[] message)
Called when unpacking an AF message. |
DOStringReader |
getDOStringReader()
Returns current instance of DOStringReader Can be null. |
java.lang.String |
getLastUID()
Access method for last unique id for message |
java.io.LineNumberReader |
getLineNumberReader()
get Input Line Number Reader |
protected java.lang.String |
getProperty(java.lang.String suffix)
Returns the value of the property suffix
associated with this component. |
java.io.Reader |
getReader()
get Input Stream Reader |
OASecurityManager |
getSecurityManager()
Returns the handle of OASecurityManager. |
protected XMLFormatter |
getXMLFormatter()
Returns an XMLFormatter instance for reading/writing DataObjects as XML. |
protected java.lang.String |
getXMLString()
Internal hacky method to read a single DealBus "XML" document into a string |
protected boolean |
isWhitespace(java.lang.String line)
|
DataObject[] |
nextDataObjectArray()
Called by Source poll, listen or callback implementation to get next DataObject array. |
protected java.lang.String |
normalisePrefix(java.lang.String prefix)
Make sure props prefix is non-null and ends with "." if not empty. |
protected DataObject[] |
readDOStreamReader()
Called by nextDataObjectArray() to read from DOStreamReader input. |
protected DataObject[] |
readDOStringReader()
Called by nextDataObjectArray() to read from DOStringReader input. |
protected DataObject[] |
readDOXML()
Called by nextDataObjectArray() to read DO XML format input. |
protected DataObject[] |
readDOXMLAlternate()
Alternative DO XML reader orginally used by FileSource to workaround a bug reading very high volume multi document DO XML format input. |
void |
readerCleanUp()
Normally called by Source sourceCleanUp() method. |
void |
readerEOF()
Called by nextDataObjectArray() to indicate end of reader input reached. |
void |
readerException(java.lang.String status,
java.lang.Exception e)
Called by nextDataObjectArray() to indicate exception condition. |
void |
readerStartUp()
Initialise and allocate resources. |
void |
setDOStringReader(java.lang.String class_name,
java.util.Properties props,
java.lang.String prefix)
Sets string reader class for this sink (see dostrings package) |
void |
setFromProperties(java.util.Properties props,
java.lang.String prefix,
java.lang.String secPrefix)
Set state from properties object. |
void |
setLineNumberReader(java.io.Reader reader)
Set Line Number Reader |
void |
setReader(java.io.Reader reader)
Set Input Stream Reader |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static org.apache.log4j.Logger log
public static final java.lang.String MESSAGEID_ATTR
public static final java.lang.String MESSAGE_WRITER_PREFIX
protected XMLFormatter _formatter
protected DOMessageReaderDelegate _readerDelegate
protected java.io.Reader _reader
protected DOStringReader _string_reader
protected int _batch_size
protected java.lang.String _start_data
protected java.lang.String _end_data
protected int _header_lines
protected boolean _useAlternateDOXMLReader
protected org.apache.oro.text.regex.Pattern[] _comment_regexps
protected org.apache.oro.text.regex.Pattern[] _record_regexps
protected org.apache.oro.text.regex.Perl5Matcher _re_matcher
protected org.apache.oro.text.regex.Perl5Compiler _re_compiler
protected OASecurityManager _secManager
protected java.util.Properties _properties
protected java.lang.String _prefix
Constructor Detail |
---|
public SimpleReaderDelegate()
Method Detail |
---|
public void setFromProperties(java.util.Properties props, java.lang.String prefix, java.lang.String secPrefix) throws IbafException
setFromProperties
in interface ReaderDelegate
props
- Properties objectprefix
- Prefix string to search for propertiessecPrefix
- Prefix string to search for security manager properties
IbafException
- Thrown if initialisation fails, mandatory
properties are missing or properties cannot be parsed.public void readerStartUp() throws IbafException
readerStartUp
in interface ReaderDelegate
IbafException
public void readerCleanUp() throws IbafException
readerCleanUp
in interface ReaderDelegate
IbafException
public DataObject[] nextDataObjectArray() throws IbafException
nextDataObjectArray
in interface ReaderDelegate
IbafException
protected DataObject[] readDOXML() throws IbafException
IbafException
protected DataObject[] readDOStreamReader() throws IbafException
IbafException
protected DataObject[] readDOStringReader() throws IbafException
IbafException
public void readerEOF()
readerEOF
in interface ReaderDelegate
public void readerException(java.lang.String status, java.lang.Exception e) throws IbafException
readerException
in interface ReaderDelegate
IbafException
public void setDOStringReader(java.lang.String class_name, java.util.Properties props, java.lang.String prefix) throws IbafException
setDOStringReader
in interface ReaderDelegate
class
- name of a DOStringReader
IbafException
public DOStringReader getDOStringReader()
getDOStringReader
in interface ReaderDelegate
public void setReader(java.io.Reader reader) throws IbafException
setReader
in interface ReaderDelegate
reader
- new input stream
IbafException
- If reader is null.public void setLineNumberReader(java.io.Reader reader) throws IbafException
setLineNumberReader
in interface ReaderDelegate
reader
- new input stream
IbafException
- If reader is null or error reading header linespublic java.io.Reader getReader()
getReader
in interface ReaderDelegate
public java.io.LineNumberReader getLineNumberReader()
getLineNumberReader
in interface ReaderDelegate
protected DataObject[] readDOXMLAlternate() throws IbafException
IbafException
protected java.lang.String getXMLString() throws java.io.IOException
java.io.IOException
protected boolean isWhitespace(java.lang.String line)
protected java.lang.String getProperty(java.lang.String suffix)
suffix
associated with this component.
The property name is formed by concatenating
_propsPrefixWithDot
with
suffix
.
suffix
- name of property (excluding component name)
public OASecurityManager getSecurityManager()
protected XMLFormatter getXMLFormatter() throws DataObjectException
Supports the following properties:
NOTE the asterisk indicates the default setting (if any)
Also supports the following (deprecated) properties:
Which are retained for backwards compatibility; it is recommended
that you do not use them in conjunction with any
of the
MessageWriter.*
properties as they may
be overridden, giving some (apparently) unexpected results.
DataObjectException
public boolean didReceiveMessage(AbstractMessageReader sender, DataObject[] message) throws DataObjectException
_unpackedMessageID
and sets flags to say it has read it. If _readerDelegate has been set,
it passes the didReceiveMessage()
along to it.
didReceiveMessage
in interface DOMessageReaderDelegate
sender
- The DataObjectMessageReader which received message
message
- message received.
_readerDelegate.didReceiveMessage()
DataObjectException
- If there was a problem readinpublic java.lang.String getLastUID()
protected void createSecurityManager(java.util.Properties props, java.lang.String prefix) throws IbafException
IbafException
protected java.lang.String normalisePrefix(java.lang.String prefix)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |