org.compass.gps.device.jpa.embedded.toplink
Class CompassSessionCustomizer
java.lang.Object
org.compass.gps.device.jpa.embedded.toplink.CompassSessionCustomizer
- All Implemented Interfaces:
- oracle.toplink.essentials.tools.sessionconfiguration.SessionCustomizer
public class CompassSessionCustomizer
- extends Object
- implements oracle.toplink.essentials.tools.sessionconfiguration.SessionCustomizer
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 (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 Compass instance and a 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
(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
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
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
|
Method Summary |
void |
customize(oracle.toplink.essentials.sessions.Session session)
|
protected javax.persistence.spi.PersistenceUnitInfo |
findPersistenceUnitInfo(oracle.toplink.essentials.sessions.Session session)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INDEX_QUERY_PREFIX
public static final String INDEX_QUERY_PREFIX
- See Also:
- Constant Field Values
COMPASS_CONFIG_LOCATION
public static final String COMPASS_CONFIG_LOCATION
- See Also:
- Constant Field Values
COMPASS_SESSION_CUSTOMIZER
public static final String COMPASS_SESSION_CUSTOMIZER
- See Also:
- Constant Field Values
CompassSessionCustomizer
public CompassSessionCustomizer()
customize
public void customize(oracle.toplink.essentials.sessions.Session session)
throws Exception
- Specified by:
customize in interface oracle.toplink.essentials.tools.sessionconfiguration.SessionCustomizer
- Throws:
Exception
findPersistenceUnitInfo
protected javax.persistence.spi.PersistenceUnitInfo findPersistenceUnitInfo(oracle.toplink.essentials.sessions.Session session)
Copyright (c) 2004-2008 The Compass Project.