wt.index
Class IndexAccessorConnection

java.lang.Object
  extended bywt.index.IndexAccessorConnection
Direct Known Subclasses:
IndexAccessorHttpConnection

public abstract class IndexAccessorConnection
extends Object

This class is the abstraction layer for our various
connection schemes between the method server's Indexer
and the index/search engine. The connection
factory, in this package, returns the proper derived
class of this parentage.

The usage of this class should look the same for almost all
purposes

Example:
try { IndexAccessorConnection iaccConn = null;
IndexAccessor iacc = null;

iaccConn = IndexAccessorConnectionFactory.createAccessor( getIndex( ) );
iaccConn.setIndexKey( createIndexKey( ) );
iaccConn.setCollectionPath( getIndex( ).getCollectionPath( ) );
iaccConn.setOperation( IndexAccessorConnection.INSERT );
iaccConn.setIndexEnabled( getIndex( ).isIndexEnabled( ) );
iaccConn.setVerboseExecution( VERBOSE_EXECUTION );
iaccConn.setSaveFiles( getIndex( ).isSaveFiles( ) );

iaccConn.openConnection();
iacc = iaccConn.getIndexAccessor();
iacc.writeHeader( );
iacc.beginIndex();
iacc.writeType( "MyCrObject" ); // this maps to a type defined in formats.cfg
MyChangeRequest cr = (MyChangeRequest)getIndexable( );
iacc.writeItem( "identity", cr.getIdentity( ) );

iacc.endIndex();

// Wait for the status to come back indicating that indexing is complete.
String accStatus = iaccConn.getStatus();
if (!( accStatus.equals(IndexConstants.SUCCESS_STATUS))) {
Object args[] = { identity };
throw new IndexingException( RESOURCE, indexResource.INDEX_FAILURE, args );
}
}
finally {
iaccConn.closeConnection( );
}



Supported API: true

Extendable: false

See Also:
IndexDelegate, wt.index.IndexAccessorFactory, IndexAccessor

Nested Class Summary
(package private)  class IndexAccessorConnection.IndexAccessorInner
           
 
Field Summary
static int DELETE
           
protected  String encoding
           
(package private)  IndexAccessor indexAccessor
           
protected  String indexKey
           
protected  String indexObjectClass
           
static int INSERT
           
protected  int operation
           
private static String RESOURCE
           
private static File tempFile
           
private  long tempTimer
           
static int VALIDATE
           
 
Constructor Summary
IndexAccessorConnection()
           
 
Method Summary
abstract  void closeConnection()
           
 IndexAccessor getIndexAccessor()
           
 OutputStream getOutputStream()
           
abstract  String getStatus()
           
abstract  void openConnection()
           
 void setOperation(int an_operation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSERT

public static final int INSERT
See Also:
Constant Field Values

DELETE

public static final int DELETE
See Also:
Constant Field Values

VALIDATE

public static final int VALIDATE
See Also:
Constant Field Values

operation

protected int operation

indexKey

protected String indexKey

indexObjectClass

protected String indexObjectClass

encoding

protected String encoding

tempFile

private static File tempFile

tempTimer

private long tempTimer

indexAccessor

IndexAccessor indexAccessor

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values
Constructor Detail

IndexAccessorConnection

public IndexAccessorConnection()
Method Detail

openConnection

public abstract void openConnection()
                             throws IOException
Throws:
IOException

closeConnection

public abstract void closeConnection()

getStatus

public abstract String getStatus()
                          throws WTException
Throws:
WTException

setOperation

public void setOperation(int an_operation)

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Throws:
IOException

getIndexAccessor

public IndexAccessor getIndexAccessor()
                               throws IOException,
                                      UnsupportedEncodingException
Throws:
IOException
UnsupportedEncodingException