org.compass.core
Interface CompassCallback<T>

All Known Implementing Classes:
CompassCallbackWithoutResult

public interface CompassCallback<T>

Callback interface for Compass code. To be used with CompassTemplate's execute methods, assumably often as anonymous classes within a method implementation. The typical implementation will call CompassSession.load/find/save to perform some operations on searchable objects.

Author:
kimchy

Method Summary
 T doInCompass(CompassSession session)
          Gets called by CompassTemplate.execute with an active Compass Session.
 

Method Detail

doInCompass

T doInCompass(CompassSession session)
              throws CompassException
Gets called by CompassTemplate.execute with an active Compass Session. Does not need to care about activating or closing the Session, or handling transactions.

If called within a thread-bound Compass transaction (initiated by an outer compass transaction abstraction), the code will simply get executed on the outer compass transaction with its transactional semantics.

Allows for returning a result object created within the callback, i.e. a domain object or a hits of domain objects. Note that there's special support for single step actions: see CompassTemplate.find etc. A thrown RuntimeException is treated as application exception, it gets propagated to the caller of the template.

Throws:
CompassException


Copyright (c) 2004-2009 The Compass Project.