A TopLink SessionCustomizer allowing to integrate in an "embedded" mode
Compass with TopLink. The single required setting (for example, within the persistence.xml
file) is the Compass connection property (
org.compass.core.config.CompassEnvironment.CONNECTION and at least one Searchable class mapped out of the classes mapped in TopLink.
The embedded TopLink support uses Compass GPS and adds an "embedded" Compass, or adds a searchable
feature to TopLink by registering a
org.compass.core.Compass instance and a
org.compass.gps.device.jpa.JpaGpsDevice instance with TopLink. It registers mirroring listeners (after delete/store/persist) to automatically
mirror changes done through TopLink to the Compass index. It also registeres an event listener
(
org.compass.gps.device.hibernate.embedded.CompassEventListener to syncronize with transactions.
Use
TopLinkHelper in order to access the Compass instance or the
JpaGpsDevice instance attached to a given entity manager.
The Compass instnace used for mirroring can be configured by adding compass prefixed settings.
Additional settings that only control the Compass instnace created for indexing should be set using
gps.index.compass. . For more information on indexing and mirroring Compass please check
org.compass.gps.impl.SingleCompassGps .
This customizer tries to find the persistence info in order to read the properties out of it. In order
for it to find it, it uses the naming convention TopLink has at naming Sessions. Note, if you change the
name of the Session using TopLink setting, this customizer will not be able to operate.
This session customizer will also identify if the persistence info is configured to work with JTA or
with RESOURCE LOCAL transaction and adjust itsefl accordingly. If JTA is used, it will automatically
use Compass
JTASyncTransactionFactory and if RESOURCE LOCAL is used it will automatically use
LocalTransactionFactory . Note, this is only set if the transaction factory is not explicitly set
using Compass settings.
Specific properties that this plugin can use:
- compass.toplink.indexQuery.[entity name/class]: Specific select query that will be used to perform the indexing
for the mentioned specific entity name / class. Note, before calling
org.compass.gps.CompassGps.index there
is an option the programmatically control this.
- compass.toplink.config: A classpath that points to Compass configuration.
- compass.toplink.session.customizer: If there is another TopLink
SessionCustomizer that needs
to be applied, its class FQN should be specified with this setting.
author: kimchy |