|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.compass.gps.device.hibernate.embedded.CompassEventListener
public class CompassEventListener
An Hibernate event listener allowing to run Compass embedded within Hibernate. The embedded mode will allow to automatically (with minimal configuration) get Compass configured to mirror changes done through Hibernate to the search engine, as well as simply indexing the whole database content.
Configuration of this listener is simple:
<hibernate-configuration> <session-factory> <event type="post-update"> <listener class="org.compass.gps.device.hibernate.embedded.CompassEventListener"/> </event> <event type="post-insert"> <listener class="org.compass.gps.device.hibernate.embedded.CompassEventListener"/> </event> <event type="post-delete"> <listener class="org.compass.gps.device.hibernate.embedded.CompassEventListener"/> </event> <event type="post-collection-recreate"> <listener class="org.compass.gps.device.hibernate.embedded.CompassEventListener"/> </event> <event type="post-collection-remove"> <listener class="org.compass.gps.device.hibernate.embedded.CompassEventListener"/> </event> <event type="post-collection-update"> <listener class="org.compass.gps.device.hibernate.embedded.CompassEventListener"/> </event> </session-factory> </hibernate-configuration>
When using Hiberante annotations or entity manager Compass also contains Hibernate search event class so it will be automatically detected. In such a case, there is no need for the event listener configuration.
Once the above configuration is set, then Compass is "installed" within Hibernate. In order to enable
Compass, the search engine connection url must be set using Hibernate properties configuration. For example:
<property name="compass.engine.connection">testindex</property>
.
Compass will automatically go over the mapped classes in Hibernate and will check if they have Compass mappings. If they do, they will be added to the searchable entities. If no such searchable classes are found, this listener will perform no operations.
Compass additional configuration can be set using typical Hiberante properties configuration using the
compass.
prefix. If using an external Compass configuration file is preferred, then the
compass.hibernate.config
can be configured and point to the location of a Compass configuration
file.
Embedded Compass also allows to use CompassGps.index()
in order to complely reindex
the database. See HibernateHelper
for more information. In
order to configure the Compass instance that will be used to index the database, the gps.index.
can be used.
Transaction management is automatically bounded to Hibernate by using Compass local transaction. If other transaction strategies are used (such as JTA Sync or XA) then the Compass transaction will be bounded to them and not the Hibernate transaction.
A user defined HibernateMirrorFilter
can be used to
filter out mirror operations. In order to configure one, the compass.hibernate.mirrorFilter
can be used with the implementation class FQN.
In order to get the Compass
instnace bounded to this Hibernate configuration, the
HibernateHelper
can be used. This is mainly used in order to perform search operations on the
index and get a Compass Gps in order to reindex the database.
Field Summary | |
---|---|
static String |
COMPASS_CONFIG_LOCATION
|
static String |
COMPASS_MIRROR_FILTER
|
Constructor Summary | |
---|---|
CompassEventListener()
|
Method Summary | |
---|---|
Compass |
getCompass()
|
Properties |
getIndexSettings()
|
void |
initialize(Configuration cfg)
|
void |
onPostDelete(PostDeleteEvent event)
|
void |
onPostInsert(PostInsertEvent event)
|
void |
onPostRecreateCollection(PostCollectionRecreateEvent postCollectionRecreateEvent)
|
void |
onPostRemoveCollection(PostCollectionRemoveEvent postCollectionRemoveEvent)
|
void |
onPostUpdate(PostUpdateEvent event)
|
void |
onPostUpdateCollection(PostCollectionUpdateEvent postCollectionUpdateEvent)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String COMPASS_CONFIG_LOCATION
public static final String COMPASS_MIRROR_FILTER
Constructor Detail |
---|
public CompassEventListener()
Method Detail |
---|
public void initialize(Configuration cfg)
initialize
in interface Initializable
public Compass getCompass()
public Properties getIndexSettings()
public void onPostDelete(PostDeleteEvent event)
onPostDelete
in interface PostDeleteEventListener
public void onPostInsert(PostInsertEvent event)
onPostInsert
in interface PostInsertEventListener
public void onPostUpdate(PostUpdateEvent event)
onPostUpdate
in interface PostUpdateEventListener
public void onPostRecreateCollection(PostCollectionRecreateEvent postCollectionRecreateEvent)
onPostRecreateCollection
in interface PostCollectionRecreateEventListener
public void onPostRemoveCollection(PostCollectionRemoveEvent postCollectionRemoveEvent)
onPostRemoveCollection
in interface PostCollectionRemoveEventListener
public void onPostUpdateCollection(PostCollectionUpdateEvent postCollectionUpdateEvent)
onPostUpdateCollection
in interface PostCollectionUpdateEventListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |