com.wideplay.warp.persist
Class PersistenceService

java.lang.Object
  extended by com.wideplay.warp.persist.PersistenceService

public abstract class PersistenceService
extends Object

This is the core warp-persist artifact. It providers factories for generating guice modules for your persistence configuration. It also must be injected into your code later as a service abstraction for starting the underlying persistence engine (Hibernate or JPA).

Implementations of this type should make sure start() and shutdown() are thread safe.

Since:
1.0

Constructor Summary
PersistenceService()
           
 
Method Summary
static boolean isDynamicFinder(Method method)
          A utility for testing if a given method is a dynamic finder.
abstract  void shutdown()
          Stops the underlying persistence engine.
abstract  void start()
          Starts the underlying persistence engine and makes warp-persist ready for use.
static SessionStrategyBuilder using(PersistenceStrategy ps)
          Configure a given PersistenceStrategy, either because it is not part of Warp Persist, or because you need support for multiple persistence modules (bound to an annotation).
static SessionStrategyBuilder usingDb4o()
          A factory for warp-persist using Db4o in your Guice module.
static SessionStrategyBuilder usingHibernate()
          A factory for warp-persist using Hibernate in your Guice module.
static SessionStrategyBuilder usingJpa()
          A factory for warp-persist using JPA in your Guice module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceService

public PersistenceService()
Method Detail

start

public abstract void start()
Starts the underlying persistence engine and makes warp-persist ready for use. For instance, with hibernate, it creates a SessionFactory and may open connection pools. This method *must* be called by your code prior to using any warp-persist or hibernate artifacts. If already started, calling this method does nothing, if already stopped, it also does nothing.


shutdown

public abstract void shutdown()
Stops the underlying persistence engine. For instance, with Hibernate, it closes the SessionFactory. If already stopped, calling this method does nothing. If not yet started, it also does nothing.


usingHibernate

public static SessionStrategyBuilder usingHibernate()
A factory for warp-persist using Hibernate in your Guice module. See http://www.wideplay.com for proper documentation on the EDSL.

Returns:
Returns the next step in the configuration chain.

usingJpa

public static SessionStrategyBuilder usingJpa()
A factory for warp-persist using JPA in your Guice module. See http://www.wideplay.com for proper documentation on the EDSL. Any compliant implementation of JPA is supported (in theory). Currently, TopLink, Hibernate and OpenJPA have shown positive results.

Returns:
Returns the next step in the configuration chain.

usingDb4o

public static SessionStrategyBuilder usingDb4o()
A factory for warp-persist using Db4o in your Guice module. See http://www.wideplay.com for proper documentation on the EDSL. Note that Db4o has slightly different semantics than ORM frameworks like Hibernate and JPA. Consult the documentation carefully.

Returns:
Returns the next step in the configuration chain.

using

public static SessionStrategyBuilder using(PersistenceStrategy ps)
Configure a given PersistenceStrategy, either because it is not part of Warp Persist, or because you need support for multiple persistence modules (bound to an annotation).

Parameters:
ps - the PersistenceService to configure
Returns:
the next step in the configuration chain

isDynamicFinder

public static boolean isDynamicFinder(Method method)
A utility for testing if a given method is a dynamic finder.

Parameters:
method - A method you suspect is a Dynamic Finder.
Returns:
Returns true if the method is annotated @Finder