Java Doc for JpaGpsDevice.java in  » Search-Engine » compass-2.0 » org » compass » gps » device » jpa » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » compass 2.0 » org.compass.gps.device.jpa 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
   org.compass.gps.device.jpa.JpaGpsDevice

JpaGpsDevice
public class JpaGpsDevice extends AbstractParallelGpsDevice implements PassiveMirrorGpsDevice(Code)

A Java Persistence API Gps Device (EJB3 Persistence).

The jpa device provides support for using jpa to index a database. The path can be viewed as: Database <-> EntityManager(JPA) <-> Objects <-> Compass::Gps <-> Compass::Core (Search Engine). What it means is that for every object that has both jpa and compass mappings, you will be able to index it's data, as well as real time mirroring of data changes.

When creating the object, an EntityManagerFactory must be provided to the Device.

Indexing uses JpaEntitiesLocator to locate all the entities that can be indexed (i.e. entities that have both Compass and JPA mappings). Most of the time the org.compass.gps.device.jpa.entities.DefaultJpaEntitiesLocator is enough, but special JPA implementation one can be provided. If none is provided, the device will use the JpaEntitiesLocatorDetector to auto detect the correct locator (which defaults to the ( org.compass.gps.device.jpa.entities.DefaultJpaEntitiesLocator ).

The indexing process itself is done through an implementation of org.compass.gps.device.jpa.indexer.JpaIndexEntitiesIndexer . There are several implemenations for it including a default one that uses plain JPA APIs. Specific implementations (such as Hibernate and OpenJPA) are used for better performance.

Mirroring can be done in two ways. The first one is using JPA official API, implemeting an Entity Lifecycle listener and specifing it for each entity class via annotations. Compass comes with helper base clases for it, AbstractCompassJpaEntityListener and AbstractDeviceJpaEntityListener . As far as integrating Compass with JPA for mirroring, this is the less preferable way. The second option for mirroring is to use the JpaEntityLifecycleInjector , which will use the internal JPA implementation to inject global lifecycle event listerens (sadly, there is no option to do that with the EntityManagerFactory API). If the JpaGpsDevice.setInjectEntityLifecycleListener(boolean) is set to true (defaults to false), the device will try to use the injector to inject global event listeners. If no JpaEntityLifecycleInjector is defined, the device will try to autodetect the injector based on the current support for specific JPA implementations using the JpaEntityLifecycleInjectorDetector . See its javadoc for a list of the current JPA implementations supported.

Mirroring can be turned off using the JpaGpsDevice.setMirrorDataChanges(boolean) to false. It defaults to true.

The device allows for NativeJpaExtractor to be set, for applications that use a framework or by themself wrap the actual EntityManagerFactory implementation.

For advance usage, the device allows for EntityManagerWrapper to be set, allowing to control the creation of EntityManagers, and transactions. The DefaultEntityManagerWrapper should suffice for most cases.

The device extends the parallel device provinding supprot for parallel indexing.
author:
   kimchy




Constructor Summary
public  JpaGpsDevice()
     Creates a new JpaGpsDevice.
public  JpaGpsDevice(String name, EntityManagerFactory entityManagerFactory)
     Creates a new device with a specific name and an entity manager factory.

Method Summary
protected  IndexEntity[]doGetIndexEntities()
    
protected  IndexEntitiesIndexerdoGetIndexEntitiesIndexer()
    
protected  voiddoStart()
    
protected  voiddoStop()
    
public  EntityManagerFactorygetEntityManagerFactory()
    
public  EntityManagerWrappergetEntityManagerWrapper()
     Returns the Entity Manager factory wrapper to control the entity manager operations.
public  intgetFetchCount()
     Returns the fetch count for the indexing process.
public  EntityManagerFactorygetNativeEntityManagerFactory()
    
public  NativeJpaExtractorgetNativeJpaExtractor()
     Returns the native extractor.
public  booleanisMirrorDataChanges()
    
public  voidsetEntitiesIndexer(JpaIndexEntitiesIndexer entitiesIndexer)
     Sets a custom entities indexer that will be used to index the data.
public  voidsetEntitiesLocator(JpaEntitiesLocator entitiesLocator)
     Sets a specific enteties locator, which is responsible for locating enteties that need to be indexed.
public  voidsetEntityManagerFactory(EntityManagerFactory entityManagerFactory)
     Sets the Jpa EntityManagerFactory.
public  voidsetEntityManagerWrapper(EntityManagerWrapper entityManagerWrapper)
     Sets the Entity Manager factory wrapper to control the entity manager operations.
public  voidsetFetchCount(int fetchCount)
     Sets the fetch count for the indexing process.
public  voidsetIndexQueryProvider(Class entityClass, JpaQueryProvider queryProvider)
    

Sets a specific query provider for the index process of the given entity class.

public  voidsetIndexQueryProvider(String entityName, JpaQueryProvider queryProvider)
    

Sets a specific query provider for the index process of the given entity name.

public  voidsetIndexSelectQuery(Class entityClass, String selectQuery)
    

Sets a specific select statement for the index process of the given entity class.

public  voidsetIndexSelectQuery(String entityName, String selectQuery)
     Sets a specific select statement for the index process of the given entity name.
public  voidsetInjectEntityLifecycleListener(boolean injectEntityLifecycleListener)
     Sets if the device should try and automatically inject global entity lifecycle listeners using either the provided JpaEntityLifecycleInjector , or if not set, using the JpaEntityLifecycleInjectorDetector .
public  voidsetLifecycleInjector(JpaEntityLifecycleInjector lifecycleInjector)
     If the JpaGpsDevice.setLifecycleInjector(org.compass.gps.device.jpa.lifecycle.JpaEntityLifecycleInjector) is set to true, the global lifecycle injector that will be used to inject global lifecycle event listerens to the underlying implementation of the EntityManagerFactory.
public  voidsetMirrorDataChanges(boolean mirrorDataChanges)
    
public  voidsetNativeExtractor(NativeJpaExtractor nativeJpaExtractor)
    

Sets a specialized native entity manager factory extractor.



Constructor Detail
JpaGpsDevice
public JpaGpsDevice()(Code)
Creates a new JpaGpsDevice. Note that its name ( JpaGpsDevice.setName(String) and entity manager factory ( JpaGpsDevice.setEntityManagerFactory(javax.persistence.EntityManagerFactory) must be set.



JpaGpsDevice
public JpaGpsDevice(String name, EntityManagerFactory entityManagerFactory)(Code)
Creates a new device with a specific name and an entity manager factory.




Method Detail
doGetIndexEntities
protected IndexEntity[] doGetIndexEntities() throws CompassGpsException(Code)



doGetIndexEntitiesIndexer
protected IndexEntitiesIndexer doGetIndexEntitiesIndexer()(Code)



doStart
protected void doStart() throws CompassGpsException(Code)



doStop
protected void doStop() throws CompassGpsException(Code)



getEntityManagerFactory
public EntityManagerFactory getEntityManagerFactory()(Code)



getEntityManagerWrapper
public EntityManagerWrapper getEntityManagerWrapper()(Code)
Returns the Entity Manager factory wrapper to control the entity manager operations.



getFetchCount
public int getFetchCount()(Code)
Returns the fetch count for the indexing process. A large number will perform the indexing faster, but will consume more memory. Default to 200.



getNativeEntityManagerFactory
public EntityManagerFactory getNativeEntityManagerFactory()(Code)



getNativeJpaExtractor
public NativeJpaExtractor getNativeJpaExtractor()(Code)
Returns the native extractor.



isMirrorDataChanges
public boolean isMirrorDataChanges()(Code)

See Also:   org.compass.gps.MirrorDataChangesGpsDevice.isMirrorDataChanges



setEntitiesIndexer
public void setEntitiesIndexer(JpaIndexEntitiesIndexer entitiesIndexer)(Code)
Sets a custom entities indexer that will be used to index the data. By default will be detected automatically based on the actual implemenation of JPA used and will try to use it.



setEntitiesLocator
public void setEntitiesLocator(JpaEntitiesLocator entitiesLocator)(Code)
Sets a specific enteties locator, which is responsible for locating enteties that need to be indexed. Not a required parameter, since will use the JpaEntitiesLocatorDetector to auto detect that correct one.



setEntityManagerFactory
public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory)(Code)
Sets the Jpa EntityManagerFactory. This is manadatory for the Jpa device.
Parameters:
  entityManagerFactory - The entity manager factory the device will use.



setEntityManagerWrapper
public void setEntityManagerWrapper(EntityManagerWrapper entityManagerWrapper)(Code)
Sets the Entity Manager factory wrapper to control the entity manager operations. This is optional since the device has sensible defaults for it.
Parameters:
  entityManagerWrapper - The entity manager wrapper to control the manager operations.



setFetchCount
public void setFetchCount(int fetchCount)(Code)
Sets the fetch count for the indexing process. A large number will perform the indexing faster, but will consume more memory. Defaults to 200.



setIndexQueryProvider
public void setIndexQueryProvider(Class entityClass, JpaQueryProvider queryProvider)(Code)

Sets a specific query provider for the index process of the given entity class.

Note, this information is used when the device starts.
Parameters:
  entityClass - The Entity class to associate the query provider with
Parameters:
  queryProvider - The query provider to execute when indexing the given entity




setIndexQueryProvider
public void setIndexQueryProvider(String entityName, JpaQueryProvider queryProvider)(Code)

Sets a specific query provider for the index process of the given entity name.

Note, this information is used when the device starts.
Parameters:
  entityName - The Entity name to associate the query provider with
Parameters:
  queryProvider - The query provider to execute when indexing the given entity




setIndexSelectQuery
public void setIndexSelectQuery(Class entityClass, String selectQuery)(Code)

Sets a specific select statement for the index process of the given entity class. The same as JpaGpsDevice.setIndexQueryProvider(Class,JpaQueryProvider) using org.compass.gps.device.jpa.queryprovider.DefaultJpaQueryProvider .

Certain JPA implementations have specific query providers with possible enhanced functionality in regards to indexing. When using this method instead of providing their specific implementation might mean less functionality from the indexer.

Note, this information is used when the device starts.
Parameters:
  entityClass - The Entity class to associate the select query with
Parameters:
  selectQuery - The select query to execute when indexing the given entity




setIndexSelectQuery
public void setIndexSelectQuery(String entityName, String selectQuery)(Code)
Sets a specific select statement for the index process of the given entity name. The same as JpaGpsDevice.setIndexQueryProvider(String,JpaQueryProvider) using org.compass.gps.device.jpa.queryprovider.DefaultJpaQueryProvider .

Certain JPA implementations have specific query providers with possible enhanced functionality in regards to indexing. When using this method instead of providing their specific implementation might mean less functionality from the indexer.

Note, this information is used when the device starts.
Parameters:
  entityName - The entity name to associate the select query with
Parameters:
  selectQuery - The select query to execute when indexing the given entity




setInjectEntityLifecycleListener
public void setInjectEntityLifecycleListener(boolean injectEntityLifecycleListener)(Code)
Sets if the device should try and automatically inject global entity lifecycle listeners using either the provided JpaEntityLifecycleInjector , or if not set, using the JpaEntityLifecycleInjectorDetector . Defaults to false.



setLifecycleInjector
public void setLifecycleInjector(JpaEntityLifecycleInjector lifecycleInjector)(Code)
If the JpaGpsDevice.setLifecycleInjector(org.compass.gps.device.jpa.lifecycle.JpaEntityLifecycleInjector) is set to true, the global lifecycle injector that will be used to inject global lifecycle event listerens to the underlying implementation of the EntityManagerFactory. If not set, the JpaEntitiesLocatorDetector will be used to auto-detect it.



setMirrorDataChanges
public void setMirrorDataChanges(boolean mirrorDataChanges)(Code)

See Also:   org.compass.gps.MirrorDataChangesGpsDevice.setMirrorDataChanges(boolean)



setNativeExtractor
public void setNativeExtractor(NativeJpaExtractor nativeJpaExtractor)(Code)

Sets a specialized native entity manager factory extractor. For applications that use a framework or by themself wrap the actual EntityManagerFactory implementation. The native extractor is mainly used for specialized JpaEntityLifecycleInjector and JpaEntitiesLocator .




Methods inherited from org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
abstract protected IndexEntity[] doGetIndexEntities() throws CompassGpsException(Code)(Java Doc)
abstract protected IndexEntitiesIndexer doGetIndexEntitiesIndexer()(Code)(Java Doc)
final protected void doIndex(CompassSession session) throws CompassGpsException(Code)(Java Doc)
public synchronized void index() throws CompassGpsException(Code)(Java Doc)
public void setIndexEntitiesPartitioner(IndexEntitiesPartitioner indexEntitiesPartitioner)(Code)(Java Doc)
public void setParallelIndexExecutor(ParallelIndexExecutor parallelIndexExecutor)(Code)(Java Doc)
public synchronized void start() throws CompassGpsException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.