net.sf.xaj.web
Class XmlDbWebRemoteService

java.lang.Object
  extended by net.sf.xaj.core.AbstractDiscoverableXmlDb
      extended by net.sf.xaj.web.XmlDbWebRemoteService
All Implemented Interfaces:
DiscoverableXmlDb, XmlDb

public class XmlDbWebRemoteService
extends AbstractDiscoverableXmlDb

An XmlDb faŤade that delegates tasks to a remote XmlDb web service.

The configurable properties of this class are:

xmlDbServiceName
The XmlDb service name to delegate to.
xmlDbBatchUrl
The XmlDb XQuery web service to delegate batch requests to.
xmlDbQueryUrl
The XmlDb XQuery web service to delegate XQuery requests to.
httpClient
The HttpClient instance to use for remote calls to the remote XmlDb batch service.
documentBuilderFactory
The JAXP DocumentBuilderFactory to use for creating Document objects.
saveDir
The directory which to pass to SerializableTempFile's constructor for saving during serialization. In this way serialized results, i.e. cached results, can be persisted after the JVM terminates. Defaults to nothing, meaning the SerializeableTempFile will serialize the file contents directly tot he serialized output stream.
transformerFactory
The JAXP TransformerFactory to use for creating Transformer objects.
includeMachineNameInTempFiles
If set to true then the local machine name will be appended to the temp file name prefix used for storing temporary files. If working in a clustered environment and SerializableTempFiles are copied across machines in the cluster, this should be set to true so that temp file names to not collide across different machines. Defaults to true.

Version:
$Revision: 53 $ $Date: 2007-10-18 19:36:52 +1300 (Thu, 18 Oct 2007) $
Author:
matt

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sf.xaj.XmlDb
XmlDb.BatchTaskResult, XmlDb.SearchResultsMetadata, XmlDb.State, XmlDb.XQuerySearchCriteria, XmlDb.XQuerySearchResults
 
Field Summary
static java.lang.String TEMP_FILE_PREFIX
          The prefix used for temp files created by this service.
static java.lang.String TEMP_FILE_SUFFIX
          The suffix used for temp files created by this service.
 
Fields inherited from class net.sf.xaj.core.AbstractDiscoverableXmlDb
DEFAULT_SHUTDOWN_EXECUTOR_WAIT_SECS
 
Constructor Summary
XmlDbWebRemoteService()
           
 
Method Summary
 boolean delete(java.io.Serializable id)
          Delete an XML resource based on its ID.
 java.lang.Integer deleteByXQuery(XmlDb.XQuerySearchCriteria criteria)
          Delete a set of XML resources that match the results of an XQuery.
 XmlDb.XQuerySearchResults executeXQuery(XmlDb.XQuerySearchCriteria criteria)
          Execute an XQuery program and return the results.
 XmlResource get(java.io.Serializable id)
          Get an XML resource based on its ID.
 javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
           
 org.apache.commons.httpclient.HttpClient getHttpClient()
           
 java.lang.String getListVariableDelimiter()
           
 java.lang.String getListVariableSplitDelimiter()
           
 java.io.File getSaveDir()
           
protected  BasicBatchTransactionHolder getTransactionHolder()
          Get a BasicBatchTransactionHolder implementation inside of a transaction.
protected  java.lang.Object getTransactionHolderKey()
          Get the object the transaction holder is bound to for a given thread.
 javax.xml.transform.TransformerFactory getTransformerFactory()
           
 XmlDb getXmlDb()
          Get the XmlDb instance represented by this service key.
 java.lang.String getXmlDbBatchUrl()
           
 java.lang.String getXmlDbQueryUrl()
           
 java.lang.String getXmlDbServiceName()
           
 java.lang.String getXmlDbStoreUrl()
           
 boolean isIncludeMachineNameInTempFiles()
           
 void setDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
           
 void setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
           
 void setIncludeMachineNameInTempFiles(boolean includeMachineNameInTempFiles)
           
 void setListVariableDelimiter(java.lang.String listVariableDelimiter)
           
 void setListVariableSplitDelimiter(java.lang.String listVariableSplitDelimiter)
           
 void setSaveDir(java.io.File saveDir)
           
 void setTransformerFactory(javax.xml.transform.TransformerFactory transformerFactory)
           
 void setXmlDbBatchUrl(java.lang.String xmlDbBatchUrl)
           
 void setXmlDbQueryUrl(java.lang.String xmlDbQueryUrl)
           
 void setXmlDbServiceName(java.lang.String xmlDbServiceName)
           
 void setXmlDbStoreUrl(java.lang.String xmlDbStoreUrl)
           
 java.io.Serializable storeXml(XmlResource resource)
          Store an XML resource in the DB.
 
Methods inherited from class net.sf.xaj.core.AbstractDiscoverableXmlDb
close, doClose, doInit, getExecutor, getServiceKey, getShutdownExecutorWaitSecs, getState, getTransactionTemplate, init, isShutdownExecutorServiceOnClose, processBatch, setExecutor, setServiceKey, setShutdownExecutorServiceOnClose, setShutdownExecutorWaitSecs, setTransactionTemplate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEMP_FILE_PREFIX

public static final java.lang.String TEMP_FILE_PREFIX
The prefix used for temp files created by this service.

See Also:
Constant Field Values

TEMP_FILE_SUFFIX

public static final java.lang.String TEMP_FILE_SUFFIX
The suffix used for temp files created by this service.

See Also:
Constant Field Values
Constructor Detail

XmlDbWebRemoteService

public XmlDbWebRemoteService()
Method Detail

getXmlDb

public XmlDb getXmlDb()
Description copied from interface: DiscoverableXmlDb
Get the XmlDb instance represented by this service key.

Specified by:
getXmlDb in interface DiscoverableXmlDb
Overrides:
getXmlDb in class AbstractDiscoverableXmlDb
Returns:
the XmlDb instance

getTransactionHolder

protected BasicBatchTransactionHolder getTransactionHolder()
Description copied from class: AbstractDiscoverableXmlDb
Get a BasicBatchTransactionHolder implementation inside of a transaction.

Specified by:
getTransactionHolder in class AbstractDiscoverableXmlDb
Returns:
the holder

getTransactionHolderKey

protected java.lang.Object getTransactionHolderKey()
Description copied from class: AbstractDiscoverableXmlDb
Get the object the transaction holder is bound to for a given thread.

Specified by:
getTransactionHolderKey in class AbstractDiscoverableXmlDb
Returns:
the transaction key object

delete

public boolean delete(java.io.Serializable id)
Description copied from interface: XmlDb
Delete an XML resource based on its ID.

Parameters:
id - the ID of the resource to delete
Returns:
true if the document was deleted

deleteByXQuery

public java.lang.Integer deleteByXQuery(XmlDb.XQuerySearchCriteria criteria)
Description copied from interface: XmlDb
Delete a set of XML resources that match the results of an XQuery.

Parameters:
criteria - the XQuery criteria
Returns:
the number of documents deleted

executeXQuery

public XmlDb.XQuerySearchResults executeXQuery(XmlDb.XQuerySearchCriteria criteria)
Description copied from interface: XmlDb
Execute an XQuery program and return the results.

Note that some implementations might have requirements as to how this list is garbage collected or treated once finished. Users of this API should call List.clear() when finished using the returned List instance so that the implementation can free any required resources.

Parameters:
criteria - the XQuery search criteria to execute
Returns:
the results

get

public XmlResource get(java.io.Serializable id)
Description copied from interface: XmlDb
Get an XML resource based on its ID.

Parameters:
id - the ID of the resource to get
Returns:
the XmlResource, or null if not found

storeXml

public java.io.Serializable storeXml(XmlResource resource)
Description copied from interface: XmlDb
Store an XML resource in the DB.

Parameters:
resource - the resource to store
Returns:
the stored ID of the resource

getDocumentBuilderFactory

public javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
Returns:
the documentBuilderFactory

setDocumentBuilderFactory

public void setDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory)
Parameters:
documentBuilderFactory - the documentBuilderFactory to set

getHttpClient

public org.apache.commons.httpclient.HttpClient getHttpClient()
Returns:
the httpClient

setHttpClient

public void setHttpClient(org.apache.commons.httpclient.HttpClient httpClient)
Parameters:
httpClient - the httpClient to set

getTransformerFactory

public javax.xml.transform.TransformerFactory getTransformerFactory()
Returns:
the transformerFactory

setTransformerFactory

public void setTransformerFactory(javax.xml.transform.TransformerFactory transformerFactory)
Parameters:
transformerFactory - the transformerFactory to set

getXmlDbQueryUrl

public java.lang.String getXmlDbQueryUrl()
Returns:
the xmlDbQueryUrl

setXmlDbQueryUrl

public void setXmlDbQueryUrl(java.lang.String xmlDbQueryUrl)
Parameters:
xmlDbQueryUrl - the xmlDbQueryUrl to set

getXmlDbServiceName

public java.lang.String getXmlDbServiceName()
Returns:
the xmlDbServiceName

setXmlDbServiceName

public void setXmlDbServiceName(java.lang.String xmlDbServiceName)
Parameters:
xmlDbServiceName - the xmlDbServiceName to set

getXmlDbBatchUrl

public java.lang.String getXmlDbBatchUrl()
Returns:
the xmlDbBatchUrl

setXmlDbBatchUrl

public void setXmlDbBatchUrl(java.lang.String xmlDbBatchUrl)
Parameters:
xmlDbBatchUrl - the xmlDbBatchUrl to set

getListVariableDelimiter

public java.lang.String getListVariableDelimiter()
Returns:
the listVariableDelimiter

getXmlDbStoreUrl

public java.lang.String getXmlDbStoreUrl()
Returns:
the xmlDbStoreUrl

setXmlDbStoreUrl

public void setXmlDbStoreUrl(java.lang.String xmlDbStoreUrl)
Parameters:
xmlDbStoreUrl - the xmlDbStoreUrl to set

setListVariableDelimiter

public void setListVariableDelimiter(java.lang.String listVariableDelimiter)
Parameters:
listVariableDelimiter - the listVariableDelimiter to set

getListVariableSplitDelimiter

public java.lang.String getListVariableSplitDelimiter()
Returns:
the listVariableSplitDelimiter

setListVariableSplitDelimiter

public void setListVariableSplitDelimiter(java.lang.String listVariableSplitDelimiter)
Parameters:
listVariableSplitDelimiter - the listVariableSplitDelimiter to set

getSaveDir

public java.io.File getSaveDir()
Returns:
the saveDir

setSaveDir

public void setSaveDir(java.io.File saveDir)
Parameters:
saveDir - the saveDir to set

isIncludeMachineNameInTempFiles

public boolean isIncludeMachineNameInTempFiles()
Returns:
the includeMachineNameInTempFiles

setIncludeMachineNameInTempFiles

public void setIncludeMachineNameInTempFiles(boolean includeMachineNameInTempFiles)
Parameters:
includeMachineNameInTempFiles - the includeMachineNameInTempFiles to set