To write a content adapter you use a collection of Java classes
from the CADK, and ensure that your content adapter method adheres to the
Adapter
interface defined in the CADK.
A typical content adapter works as follows:
The configuration information for the content adapter is passed through in the corresponding record adapter. The content adapter uses this information to connect to a data source. For example, in the CADK reference implementation, the source data file’s name and location are passed through.
The configuration information that is passed through in the record adapter is used to construct an
AdapterConfig
object.The
AdapterConfig
object is then handed to thecom.endeca.edf.adapter.Adapter
object’sAdapter.execute
method.AdapterHandler
, meanwhile, is used to emit the records that Forge will process. A record created by the content adapter is processed by callingemit
on theAdapterHandler
parameter passed toAdapter.execute
. Records emitted in this way flow from the record adapter (that is used for harnessing the content adapter) to the next pipeline component.For example, the CADK reference implementation contains
MBoxAdapter.java
, which is a basic example of a content adapter. This content adapter connects to a data source, extracts properties from it and then constructs Endeca records with properties extracted from that source. In particular, this content adapter reads email messages from an mbox file and converts each message to an Endeca record.Each record is processed by calling the emit method on the given adapter handler. The emitted records flow from the record adapter harnessing this content adapter to the next pipeline component.
Related links