com.google.enterprise.adaptor.examples
Class DbAdaptorTemplate

java.lang.Object
  extended by com.google.enterprise.adaptor.AbstractAdaptor
      extended by com.google.enterprise.adaptor.examples.DbAdaptorTemplate
All Implemented Interfaces:
Adaptor

public class DbAdaptorTemplate
extends AbstractAdaptor

Demonstrates what code is necessary for putting DB content onto a GSA.

Note: this code does not pool DB connections.

Example command line:

/java/bin/java \ -cp adaptor-withlib.jar:adaptor-examples.jar:mysql-5.1.10.jar \ com.google.enterprise.adaptor.examples.DbAdaptorTemplate \ -Dgsa.hostname=myGSA -Ddb.name=podata -Ddb.tablename=itinerary \ -Djournal.reducedMem=true


Constructor Summary
DbAdaptorTemplate()
           
 
Method Summary
 void getDocContent(Request req, Response resp)
          Gives the bytes of a document referenced with id.
 void getDocIds(DocIdPusher pusher)
          Get all doc ids from database.
 void init(AdaptorContext context)
          Initialize adaptor with the current context.
 void initConfig(Config config)
          Provides the opportunity for the Adaptor to create new configuration values or override default values.
static void main(String[] args)
           
 
Methods inherited from class com.google.enterprise.adaptor.AbstractAdaptor
destroy, main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbAdaptorTemplate

public DbAdaptorTemplate()
Method Detail

initConfig

public void initConfig(Config config)
Description copied from class: AbstractAdaptor
Provides the opportunity for the Adaptor to create new configuration values or override default values. Only Config.addKey(java.lang.String, java.lang.String) should likely be called. The user's configuration will override any values set in this way. This method is called by AbstractAdaptor.main(com.google.enterprise.adaptor.Adaptor, java.lang.String[]) before Adaptor.init(com.google.enterprise.adaptor.AdaptorContext) is called.

This implementation does nothing.

Specified by:
initConfig in interface Adaptor
Overrides:
initConfig in class AbstractAdaptor

init

public void init(AdaptorContext context)
          throws Exception
Description copied from class: AbstractAdaptor
Initialize adaptor with the current context. This is the ideal time to start any threads to do extra behind-the-scenes work. The context points to other useful objects that can be used at any time. For example, methods on DocIdPusher provided via AdaptorContext.getDocIdPusher() are allowed to be called whenever the Adaptor wishes. This allows doing event-based incremental pushes at any time.

The method is called at the end of GsaCommunicationHandler.start().

If you experience a fatal error during initialization, feel free to throw an Exception to cancel the startup process.

This implementation does nothing.

Specified by:
init in interface Adaptor
Overrides:
init in class AbstractAdaptor
Throws:
Exception

getDocIds

public void getDocIds(DocIdPusher pusher)
               throws IOException,
                      InterruptedException
Get all doc ids from database.

Throws:
IOException
InterruptedException

getDocContent

public void getDocContent(Request req,
                          Response resp)
                   throws IOException
Gives the bytes of a document referenced with id.

Throws:
IOException

main

public static void main(String[] args)