org.compass.gps.device.jpa.entities
Class DefaultJpaEntitiesLocator

java.lang.Object
  extended by org.compass.gps.device.jpa.entities.DefaultJpaEntitiesLocator
All Implemented Interfaces:
JpaEntitiesLocator

public class DefaultJpaEntitiesLocator
extends Object
implements JpaEntitiesLocator

The default JpaEntitiesLocator implementations. Should work with all different JPA implementations, with the only caveat that it is based on Annotations only. So, any applications that uses a combination of both annotations and xml definitions (or any other type), will probably loose some information during the index process (providing that the xml definitions are ones that collide with Compass definitions). Please check if a JPA actual implementation is provided with compass in such cases, and if not, writing one should be simple (and should probably use the actual JPA implementation APIs).

Author:
kimchy

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
DefaultJpaEntitiesLocator()
           
 
Method Summary
protected  EntityInformation createEntityInformation(Class<?> clazz, ResourceMapping resourceMapping)
          Creates the EntityInformation for a given class.
 EntityInformation[] locate(javax.persistence.EntityManagerFactory entityManagerFactory, JpaGpsDevice device)
          Locates the entities used for the index operation.
protected  boolean shouldFilter(EntityInformation entityInformation, JpaGpsDevice device)
          Return true if the entity should be filtered out from the index operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log
Constructor Detail

DefaultJpaEntitiesLocator

public DefaultJpaEntitiesLocator()
Method Detail

locate

public EntityInformation[] locate(javax.persistence.EntityManagerFactory entityManagerFactory,
                                  JpaGpsDevice device)
                           throws JpaGpsDeviceException
Description copied from interface: JpaEntitiesLocator
Locates the entities used for the index operation.

Specified by:
locate in interface JpaEntitiesLocator
Parameters:
entityManagerFactory - The EntityManagerFactory to be optionally used for locating the entities.
device - The Jpa device that called this locator.
Returns:
An array of the enteties that need to be indexed during the index operation.
Throws:
JpaGpsDeviceException

createEntityInformation

protected EntityInformation createEntityInformation(Class<?> clazz,
                                                    ResourceMapping resourceMapping)
                                             throws JpaGpsDeviceException
Creates the EntityInformation for a given class. If return null the class will be filtered out.

Implementation filters out classes that do not have the Entity annotation (i.e. return null for such a case).

Parameters:
clazz - The class to create the EntityInformation for
resourceMapping - The Compass resource mapping (used for sub indexes extraction)
Returns:
The entity information, or null to filter it out
Throws:
JpaGpsDeviceException

shouldFilter

protected boolean shouldFilter(EntityInformation entityInformation,
                               JpaGpsDevice device)
Return true if the entity should be filtered out from the index operation.

Implementation filters out classes that one of the super classes has the Inheritance annotation and the super class has compass mappings.

Parameters:
entityInformation - The entity information to check if it should be filtered
device - The Jpa gps device
Returns:
true if the entity should be filtered from the index process


Copyright (c) 2004-2009 The Compass Project.