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

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

public class OpenJPAJpaEntitiesLocator
extends Object
implements JpaEntitiesLocator

A specilized version that works with OpenJPA. This class should be used instead of DefaultJpaEntitiesLocator since it works with both openjpa xml files and annotatios.

Author:
kimchy

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
OpenJPAJpaEntitiesLocator()
           
 
Method Summary
 EntityInformation[] locate(javax.persistence.EntityManagerFactory entityManagerFactory, JpaGpsDevice device)
          Locates the entities used for the index operation.
 void setClassLoader(ClassLoader classLoader)
           
protected  boolean shouldFilter(String entityname, org.apache.openjpa.meta.ClassMetaData classMetadata, JpaGpsDevice device)
          Returns true if the entity name needs to be filtered.
 
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

OpenJPAJpaEntitiesLocator

public OpenJPAJpaEntitiesLocator()
Method Detail

setClassLoader

public void setClassLoader(ClassLoader classLoader)

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

shouldFilter

protected boolean shouldFilter(String entityname,
                               org.apache.openjpa.meta.ClassMetaData classMetadata,
                               JpaGpsDevice device)
Returns true if the entity name needs to be filtered.

Implementation filteres out inherited OpenJPA mappings, since the select query for the base class will cover any inherited classes as well.

Note, that this method is called after it has been verified that the class has Compass mappings (either directly, or indirectly by an interface or a super class).

Parameters:
entityname - The name of the entity
classMetadata - The OpenJPA class meta data.
device - The Jpa Gps device
Returns:
true if the entity should be filtered out, false if not.


Copyright (c) 2004-2009 The Compass Project.