A EclipseLink SessionCustomizer allowing to integrate in an "embedded" mode
Compass with EclipseLink. 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 EclipseLink.
The embedded EclipseLink support uses Compass GPS and adds an "embedded" Compass, or adds a searchable
feature to EclipseLink by registering a
org.compass.core.Compass instance and a
org.compass.gps.device.jpa.JpaGpsDevice instance with EclipseLink. It registers mirroring listeners (after delete/store/persist) to automatically
mirror changes done through EclipseLink to the Compass index. It also registeres an event listener
(
org.compass.gps.device.hibernate.embedded.CompassEventListener to syncronize with transactions.
Use
EclipseLinkHelper 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 EclipseLink has at naming Sessions. Note, if you change the
name of the Session using EclipseLink 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
org.compass.core.transaction.JTASyncTransactionFactory and if RESOURCE LOCAL is used it will automatically use
org.compass.core.transaction.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.EclipseLink.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.EclipseLink.config: A classpath that points to Compass configuration.
- compass.EclipseLink.session.customizer: If there is another EclipseLink
SessionCustomizer that needs
to be applied, its class FQN should be specified with this setting.
author: kimchy |