org.carrot2.source.xml
Class RemoteXmlSimpleSearchEngineBase

java.lang.Object
  extended by org.carrot2.core.ProcessingComponentBase
      extended by org.carrot2.source.SearchEngineBase
          extended by org.carrot2.source.SimpleSearchEngine
              extended by org.carrot2.source.xml.RemoteXmlSimpleSearchEngineBase
All Implemented Interfaces:
IDocumentSource, IProcessingComponent
Direct Known Subclasses:
EToolsDocumentSource, GoogleDesktopDocumentSource, SolrDocumentSource

public abstract class RemoteXmlSimpleSearchEngineBase
extends SimpleSearchEngine

A base class for implementing data sources based on XML/XSLT. The XSLT stylesheet will be loaded once during component initialization and cached for all further requests.


Field Summary
 
Fields inherited from class org.carrot2.source.SearchEngineBase
compressed, documents, query, results, resultsTotal, start, statistics
 
Constructor Summary
RemoteXmlSimpleSearchEngineBase()
           
 
Method Summary
 void beforeProcessing()
          Invoked after the attributes marked with Processing and Input annotations have been bound, but before a call to IProcessingComponent.process().
protected abstract  String buildServiceUrl()
          Builds the URL from which XML stream will be fetched.
protected  SearchEngineResponse fetchSearchResponse()
          Requests and returns results from the underlying search engine.
protected  String getPassword()
          Returns the password to use for HTTP Basic Authentication.
protected  String getUser()
          Returns the user name to use for HTTP Basic Authentication.
protected  Map<String,String> getXsltParameters()
          Returns parameters to be passed to the XSLT transformer.
protected abstract  IResource getXsltResource()
          Returns the XSLT stylesheet that transforms the custom XML into Carrot2 compliant XML.
 void init(IControllerContext context)
          Invoked after component's attributes marked with Init and Input annotations have been bound, but before calls to any other methods of this component.
 
Methods inherited from class org.carrot2.source.SimpleSearchEngine
process
 
Methods inherited from class org.carrot2.source.SearchEngineBase
afterFetch, clean, urlEncode
 
Methods inherited from class org.carrot2.core.ProcessingComponentBase
afterProcessing, dispose, getContext, getSharedExecutor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.carrot2.core.IProcessingComponent
afterProcessing, dispose
 

Constructor Detail

RemoteXmlSimpleSearchEngineBase

public RemoteXmlSimpleSearchEngineBase()
Method Detail

init

public void init(IControllerContext context)
Description copied from interface: IProcessingComponent
Invoked after component's attributes marked with Init and Input annotations have been bound, but before calls to any other methods of this component. After a call to this method completes without an exception, attributes marked with Init Output will be collected. In this method, components should perform initializations based on the initialization-time attributes. This method is called once in the life time of a processing component instance.

Specified by:
init in interface IProcessingComponent
Overrides:
init in class ProcessingComponentBase
Parameters:
context - An instance of IControllerContext of the controller to which this component instance will be bound.

beforeProcessing

public void beforeProcessing()
                      throws ProcessingException
Description copied from interface: IProcessingComponent
Invoked after the attributes marked with Processing and Input annotations have been bound, but before a call to IProcessingComponent.process(). In this method, the processing component should perform any initializations based on the runtime attributes. This method is called once per request.

Specified by:
beforeProcessing in interface IProcessingComponent
Overrides:
beforeProcessing in class ProcessingComponentBase
Throws:
ProcessingException - when processing cannot start, e.g. because some attributes were not bound. If thrown, the IProcessingComponent.process() method will not be called. Instead, IProcessingComponent.afterProcessing() will be called immediately to allow clean-up actions, and the component will be ready to accept further requests or to be disposed of. Finally, the exception will be rethrown from the controller method that caused the component to perform processing.

fetchSearchResponse

protected SearchEngineResponse fetchSearchResponse()
                                            throws Exception
Description copied from class: SimpleSearchEngine
Requests and returns results from the underlying search engine.

Specified by:
fetchSearchResponse in class SimpleSearchEngine
Throws:
Exception - in case of problems with the underlying search engine

getXsltResource

protected abstract IResource getXsltResource()
Returns the XSLT stylesheet that transforms the custom XML into Carrot2 compliant XML. This method will be called once during component initialization. Initialization time attributes will have been bound before the call to this method.


getXsltParameters

protected Map<String,String> getXsltParameters()
Returns parameters to be passed to the XSLT transformer. This method will be called once per processing cycle. Processing-time attributes will have been bound before this method the call to this method. The default implementation returns null.


buildServiceUrl

protected abstract String buildServiceUrl()
Builds the URL from which XML stream will be fetched. This method will be called once per request processing cycle. Processing-time attributes will have been bound before this method the call to this method.


getUser

protected String getUser()
Returns the user name to use for HTTP Basic Authentication.


getPassword

protected String getPassword()
Returns the password to use for HTTP Basic Authentication.



Copyright (c) Dawid Weiss, Stanislaw Osinski