org.backsource.xindice
Class AmsterdamXindiceBase

java.lang.Object
  extended byorg.backsource.amsterdam.service.HandlerSupport
      extended byorg.backsource.amsterdam.service.filter.ServiceFilterSupport
          extended byorg.backsource.xindice.AmsterdamXindiceBase
All Implemented Interfaces:
org.backsource.amsterdam.service.Handler, org.backsource.amsterdam.service.HandlerSupportMBean, org.backsource.amsterdam.service.Servable, org.backsource.amsterdam.service.filter.ServiceFilter, org.backsource.amsterdam.service.filter.ServiceFilterSupportMBean, org.backsource.amsterdam.metadata.XmlConfigurable
Direct Known Subclasses:
AmsterdamXindiceManagementFilter, AmsterdamXindicePublisher

public abstract class AmsterdamXindiceBase
extends org.backsource.amsterdam.service.filter.ServiceFilterSupport
implements org.backsource.amsterdam.metadata.XmlConfigurable

A base class for Xindice Amsterdam components.

This base class may be used to create filters and publishers that work agains the Xindice XML DB.It should be configured with a base xindice uri, pointing to a base collection and either a specifyed collection to work agains or an xpath to be used to get the collection names from the message.

Here is a possible configuration for filter with a preconfigured collection:

   <filter-conf>
          <url>xmldb:xindice:///db/test</url>
          <collection>senasteNytt</collection>
        </filter-conf>

And here is for publisher with an xpath selecting collections:

    
<publisher className="org.backsource.xindice.AmsterdamXindicePublisher">
      <url>xmldb:xindice:///db/test</url>
      <collection-xpath>//Subject[@Scheme="EdrumCategory"]/@FormalName</collection-xpath>
    </publisher>

Version:
$Revision: 1.1.1.1 $
Author:
Peter Antman

Field Summary
protected  java.lang.String col
           
protected  java.util.HashSet existingCollections
           
protected  XindicePool pool
           
protected  java.lang.String url
           
protected  java.lang.String xpath
           
 
Fields inherited from class org.backsource.amsterdam.service.HandlerSupport
name, objectName, service, useBean
 
Constructor Summary
AmsterdamXindiceBase()
           
 
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) connected to this configuration.
protected  org.w3c.dom.Document getDocument(org.backsource.amsterdam.service.ServiceMessage message, boolean isFilter)
          Return a DOM document from message, if isFilter is true, guarantee that message still contains a message.
 void importXml(org.w3c.dom.Element element)
           
 void start()
          Start the component, get a list of all existing child collections.
 void stop()
          Stop component.
 java.lang.String toString()
           
protected  void updateExistingCollections()
          Moved here to make it possible to update the existing collections.
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.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, handleMessage, 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.HandlerSupportMBean
getName, getObjectName, isUseBean
 
Methods inherited from interface org.backsource.amsterdam.service.Handler
getService, handleMessage, setService
 
Methods inherited from interface org.backsource.amsterdam.service.Servable
destroy, init
 

Field Detail

pool

protected XindicePool pool

existingCollections

protected java.util.HashSet existingCollections

url

protected java.lang.String url

col

protected java.lang.String col

xpath

protected java.lang.String xpath
Constructor Detail

AmsterdamXindiceBase

public AmsterdamXindiceBase()
Method Detail

start

public void start()
           throws java.lang.Exception
Start the component, get a list of all existing child collections.

Specified by:
start in interface org.backsource.amsterdam.service.Servable
Throws:
java.lang.Exception

updateExistingCollections

protected void updateExistingCollections()
                                  throws XindiceException
Moved here to make it possible to update the existing collections.

Throws:
XindiceException

stop

public void stop()
          throws java.lang.Exception
Stop component.

Specified by:
stop in interface org.backsource.amsterdam.service.Servable
Throws:
java.lang.Exception

toString

public java.lang.String toString()

getDocument

protected org.w3c.dom.Document getDocument(org.backsource.amsterdam.service.ServiceMessage message,
                                           boolean isFilter)
                                    throws org.backsource.amsterdam.service.ServiceException
Return a DOM document from message, if isFilter is true, guarantee that message still contains a message.

Throws:
org.backsource.amsterdam.service.ServiceException

getCollections

protected java.lang.String[] getCollections(org.w3c.dom.Document doc,
                                            boolean create)
                                     throws XindiceException,
                                            org.backsource.utils.xml.XmlException
Get the collection(s) connected to this configuration.

if col is set, that will be used, if xpath i set, the names of the collections will fetched from the document. getCollectionName(java.lang.String) will be used to get any mapped name for the collection and validateCollection(java.lang.String, boolean) will be used to validate the colection. Both these are typically overridden in subclasses to provide needed behaviuor.

Parameters:
doc - document to save.
Throws:
XindiceException - if collection is not correct
org.backsource.utils.xml.XmlException - if getting of collection with xpath failes.

getCollectionName

protected java.lang.String getCollectionName(java.lang.String colName)
                                      throws XindiceException
Template method to use in sublclasses that wants to map incomming collection name to another, this version just returns the name.

Returns:
a collections name, wich may be a mapped name, or null if the collection is not a valid/allowed collection.
Throws:
XindiceException

validateCollection

protected boolean validateCollection(java.lang.String colName,
                                     boolean create)
                              throws XindiceException
Validate that the collection exists, if create is true try create one.

The dafult impl just checks if the collections exist,and returns true if is does and false otherwise.

Parameters:
colName - the collection to check.
create - create collection if it does not exists if set to true.
Throws:
XindiceException - if collection did not exist and create was false or if creation did not work.

importXml

public void importXml(org.w3c.dom.Element element)
               throws org.backsource.amsterdam.deployment.DeploymentException
Specified by:
importXml in interface org.backsource.amsterdam.metadata.XmlConfigurable
Throws:
org.backsource.amsterdam.deployment.DeploymentException


Copyright © 2003-2004 Backsource. All Rights Reserved.