|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.backsource.amsterdam.service.HandlerSupport
org.backsource.amsterdam.service.filter.ServiceFilterSupport
org.backsource.xindice.AmsterdamXindiceBase
org.backsource.xindice.AmsterdamXindicePublisher
Amsterdam publisher for Xindice.
This class publishes the incomming document to the configured collections. It overrides the validateCollection(java.lang.String, boolean) method to create any collection that it can not find if the create-collections flag is true. It is also possible to set a key-xpath expression so that it can lookup the key to save as from the incomming document. There is currently no way to just use a subset of the collections fethched from the xpath; to make collections name or skip certain collections, sublcass this class and override the getCollectionName(java.lang.String) and/or validateCollection(java.lang.String, boolean)
Here is a configuration that goes agains a single collections.
<filter className="org.backsource.xindice.AmsterdamXindicePublisher">
<filter-conf>
<url>xmldb:xindice:///db/test</url>
<collection>senasteNytt</collection>
<create-collections>true</create-collections>
<key-xpath>/NewsML/NewsEnvelope/TransmissionId</key-xpath>
</filter-conf>
</filter>
And here is a publisher config that dynalically selects the collections to save the document to (and creates them if they do not exist).
<publisher className="org.backsource.xindice.AmsterdamXindicePublisher">
<url>xmldb:xindice:///db/test</url>
<!--<collection>test</collection>-->
<collection-xpath>//Subject[@Scheme="EdrumCategory"]/@FormalName</collection-xpath>
<create-collections>true</create-collections>
<key-xpath>/NewsML/NewsEnvelope/TransmissionId</key-xpath>
</publisher>
Possible bugs
1. Have seen situations when loading of thow parallell messages with same category and where the category did not exist prior: seems as if the second one does not allways see that the collection was created by the first thread.
| Field Summary | |
protected boolean |
createCols
|
protected java.lang.String |
keyXpath
|
| Fields inherited from class org.backsource.xindice.AmsterdamXindiceBase |
col, existingCollections, pool, url, xpath |
| Fields inherited from class org.backsource.amsterdam.service.HandlerSupport |
name, objectName, service, useBean |
| Constructor Summary | |
AmsterdamXindicePublisher()
|
|
| Method Summary | |
protected java.lang.String |
getCollectionName(java.lang.String colName)
Template method to use in sublclasses that wants to map incomming collection name to another, this version just returns the name. |
protected java.lang.String[] |
getCollections(org.w3c.dom.Document doc,
boolean create)
Get the collection(s) this message should be saved in. |
void |
handleMessage(org.backsource.amsterdam.service.ServiceMessage message)
Publish the xml message to the collections this service was configured to i use. |
void |
importXml(org.w3c.dom.Element element)
Takes argument as AmsterdamXindiceBase. |
void |
start()
Start the component, get a list of all existing child collections. |
java.lang.String |
toString()
|
protected boolean |
validateCollection(java.lang.String colName,
boolean create)
Validate that the collection exists, if create is true try create one. |
| Methods inherited from class org.backsource.xindice.AmsterdamXindiceBase |
getDocument, stop, updateExistingCollections |
| Methods inherited from class org.backsource.amsterdam.service.filter.ServiceFilterSupport |
getFilterName, getFilterObjectName, getNext, getObjectNameProperty, setFilterName, setFilterObjectName, setNext |
| Methods inherited from class org.backsource.amsterdam.service.HandlerSupport |
constructObjectName, destroy, getName, getObjectName, getService, init, isUseBean, setName, setObjectName, setService |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.backsource.amsterdam.service.Handler |
getName, getObjectName, getService, isUseBean, setService |
| Methods inherited from interface org.backsource.amsterdam.service.Servable |
destroy, init, stop |
| Methods inherited from interface org.backsource.amsterdam.service.HandlerSupportMBean |
getName, getObjectName, isUseBean |
| Field Detail |
protected boolean createCols
protected java.lang.String keyXpath
| Constructor Detail |
public AmsterdamXindicePublisher()
| Method Detail |
public void start()
throws java.lang.Exception
AmsterdamXindiceBase
start in interface org.backsource.amsterdam.service.Servablestart in class AmsterdamXindiceBasejava.lang.Exception
public void handleMessage(org.backsource.amsterdam.service.ServiceMessage message)
throws org.backsource.amsterdam.service.ServiceException
handleMessage in interface org.backsource.amsterdam.service.Handlerorg.backsource.amsterdam.service.ServiceException
public void importXml(org.w3c.dom.Element element)
throws org.backsource.amsterdam.deployment.DeploymentException
importXml in interface org.backsource.amsterdam.metadata.XmlConfigurableimportXml in class AmsterdamXindiceBaseorg.backsource.amsterdam.deployment.DeploymentExceptionpublic java.lang.String toString()
toString in class AmsterdamXindiceBase
protected java.lang.String[] getCollections(org.w3c.dom.Document doc,
boolean create)
throws XindiceException,
org.backsource.utils.xml.XmlException
if col is set, that will be used, if xpath i set, the names of the collections will fetched from the document.if create is set to true, we will try to create the collection if it does not exist, otherwise an XindiceExceptiob will be thrown if the collections does not exist.
getCollections in class AmsterdamXindiceBasedoc - document to save.
XindiceException - if collection is not correct
org.backsource.utils.xml.XmlException - if getting of collection with xpath failes.
protected java.lang.String getCollectionName(java.lang.String colName)
throws XindiceException
getCollectionName in class AmsterdamXindiceBaseXindiceException
protected boolean validateCollection(java.lang.String colName,
boolean create)
throws XindiceException
validateCollection in class AmsterdamXindiceBasecolName - the collection to check.create - create collection if it does not exists if set to true.
XindiceException - if collection did not exist and create was false or if creation did not work.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||