org.apache.ode.store
Class ProcessStoreImpl

java.lang.Object
  extended by org.apache.ode.store.ProcessStoreImpl
All Implemented Interfaces:
ProcessStore

public class ProcessStoreImpl
extends java.lang.Object
implements ProcessStore

JDBC-based implementation of a process store. Also provides an "in-memory" store by way of HSQL database.

The philsophy here is to keep things simple. Process store operations are relatively infrequent. Performance of the public methods is not a concern. However, note that the ProcessConf objects returned by the class are going to be used from within the engine runtime, and hence their performance needs to be very good. Similarly, these objects should be immutable so as not to confuse the engine. Note the way that the database is used in this class, it is more akin to a recovery log, this is intentional: we want to start up, load stuff from the database and then pretty much forget about it when it comes to reads.


Field Summary
protected  java.io.File _configDir
           
protected  java.io.File _deployDir
           
 
Constructor Summary
ProcessStoreImpl()
           
ProcessStoreImpl(EndpointReferenceContext eprContext, javax.sql.DataSource inMemDs)
          Constructor that hardwires OpenJPA on a new in-memory database.
ProcessStoreImpl(EndpointReferenceContext eprContext, javax.sql.DataSource ds, java.lang.String persistenceType, OdeConfigProperties props, boolean createDatamodel)
           
 
Method Summary
static java.util.Map<javax.xml.namespace.QName,org.w3c.dom.Node> calcInitialProperties(TDeployment.Process dd)
          Create a property mapping based on the initial values in the deployment descriptor.
protected  long calculateVersion(java.io.File deploymentUnitDirectory)
           
static javax.sql.DataSource createInternalDS(java.lang.String guid)
           
 java.util.Collection<javax.xml.namespace.QName> deploy(java.io.File deploymentUnitDirectory)
          Deploys a process.
 java.util.Collection<javax.xml.namespace.QName> deploy(java.io.File deploymentUnitDirectory, boolean activate, java.lang.String duName)
          Deploys a process.
protected  void finalize()
           
protected  java.io.File findDeployDir(DeploymentUnitDAO dudao)
           
protected  void fireEvent(ProcessStoreEvent pse)
           
 java.io.File getConfigDir()
           
 long getCurrentVersion()
          Gets the version used by the store for the last deployment.
 java.io.File getDeployDir()
           
 java.util.Collection<java.lang.String> getPackages()
          Lists the names of all the packages that have been deployed (corresponds to a directory name on the file system).
 ProcessConf getProcessConfiguration(javax.xml.namespace.QName processId)
          Gets all the details of a process configuration (properties, deploy dates, ...)
 java.util.List<javax.xml.namespace.QName> getProcesses()
          Get the list of processes known to the store.
 java.util.List<javax.xml.namespace.QName> listProcesses(java.lang.String packageName)
          Lists all processe ids in a given package.
protected  java.util.List<ProcessConfImpl> load(DeploymentUnitDAO dudao)
          Load a deployment unit record stored in the db into memory.
protected  boolean load(java.lang.String duName)
          Make sure that the deployment unit is loaded.
 void loadAll()
          Load all the deployment units out of the store.
 void refreshSchedules(java.lang.String packageName)
           
 void registerListener(ProcessStoreListener psl)
          Register a configuration store listener.
 void setConfigDir(java.io.File configDir)
           
 void setDeployDir(java.io.File depDir)
           
 void setProperty(javax.xml.namespace.QName pid, javax.xml.namespace.QName propName, org.w3c.dom.Node value)
           
 void setProperty(javax.xml.namespace.QName pid, javax.xml.namespace.QName propName, java.lang.String value)
          Set a process property.
 void setRetiredPackage(java.lang.String packageName, boolean retired)
          Retires all processes in a given package.
 void setState(javax.xml.namespace.QName pid, ProcessState state)
          Marks a process as active / retired or disabled
 void shutdown()
           
static void shutdownInternalDB(javax.sql.DataSource ds)
           
 java.util.Collection<javax.xml.namespace.QName> undeploy(java.io.File dir)
          Undeploys a package.
 java.util.Collection<javax.xml.namespace.QName> undeploy(java.lang.String duName)
           
 void unregisterListener(ProcessStoreListener psl)
          Unregister a configuration store listener.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_deployDir

protected java.io.File _deployDir

_configDir

protected java.io.File _configDir
Constructor Detail

ProcessStoreImpl

public ProcessStoreImpl()

ProcessStoreImpl

public ProcessStoreImpl(EndpointReferenceContext eprContext,
                        javax.sql.DataSource ds,
                        java.lang.String persistenceType,
                        OdeConfigProperties props,
                        boolean createDatamodel)

ProcessStoreImpl

public ProcessStoreImpl(EndpointReferenceContext eprContext,
                        javax.sql.DataSource inMemDs)
Constructor that hardwires OpenJPA on a new in-memory database. Suitable for tests.

Method Detail

shutdown

public void shutdown()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

deploy

public java.util.Collection<javax.xml.namespace.QName> deploy(java.io.File deploymentUnitDirectory)
Deploys a process.

Specified by:
deploy in interface ProcessStore
Parameters:
deploymentUnitDirectory - directory containing all deployment files
Returns:
a collection of process ids (deployed processes)

deploy

public java.util.Collection<javax.xml.namespace.QName> deploy(java.io.File deploymentUnitDirectory,
                                                              boolean activate,
                                                              java.lang.String duName)
Deploys a process.


calculateVersion

protected long calculateVersion(java.io.File deploymentUnitDirectory)

undeploy

public java.util.Collection<javax.xml.namespace.QName> undeploy(java.io.File dir)
Description copied from interface: ProcessStore
Undeploys a package.

Specified by:
undeploy in interface ProcessStore
Parameters:
dir - package
Returns:
collection of successfully deployed process names

undeploy

public java.util.Collection<javax.xml.namespace.QName> undeploy(java.lang.String duName)

getPackages

public java.util.Collection<java.lang.String> getPackages()
Description copied from interface: ProcessStore
Lists the names of all the packages that have been deployed (corresponds to a directory name on the file system).

Specified by:
getPackages in interface ProcessStore
Returns:
an array of package names

listProcesses

public java.util.List<javax.xml.namespace.QName> listProcesses(java.lang.String packageName)
Description copied from interface: ProcessStore
Lists all processe ids in a given package.

Specified by:
listProcesses in interface ProcessStore
Returns:
an array of process id QNames

setState

public void setState(javax.xml.namespace.QName pid,
                     ProcessState state)
Description copied from interface: ProcessStore
Marks a process as active / retired or disabled

Specified by:
setState in interface ProcessStore
state - true for active, false for inactive

setRetiredPackage

public void setRetiredPackage(java.lang.String packageName,
                              boolean retired)
Description copied from interface: ProcessStore
Retires all processes in a given package.

Specified by:
setRetiredPackage in interface ProcessStore

getProcessConfiguration

public ProcessConf getProcessConfiguration(javax.xml.namespace.QName processId)
Description copied from interface: ProcessStore
Gets all the details of a process configuration (properties, deploy dates, ...)

Specified by:
getProcessConfiguration in interface ProcessStore
Returns:
process configuration details

setProperty

public void setProperty(javax.xml.namespace.QName pid,
                        javax.xml.namespace.QName propName,
                        org.w3c.dom.Node value)
Specified by:
setProperty in interface ProcessStore

setProperty

public void setProperty(javax.xml.namespace.QName pid,
                        javax.xml.namespace.QName propName,
                        java.lang.String value)
Description copied from interface: ProcessStore
Set a process property.

Specified by:
setProperty in interface ProcessStore

loadAll

public void loadAll()
Load all the deployment units out of the store. Called on start-up.


getProcesses

public java.util.List<javax.xml.namespace.QName> getProcesses()
Description copied from interface: ProcessStore
Get the list of processes known to the store.

Specified by:
getProcesses in interface ProcessStore
Returns:
list of processes qnames with their compiled definition

getCurrentVersion

public long getCurrentVersion()
Description copied from interface: ProcessStore
Gets the version used by the store for the last deployment.

Specified by:
getCurrentVersion in interface ProcessStore
Returns:

fireEvent

protected void fireEvent(ProcessStoreEvent pse)

registerListener

public void registerListener(ProcessStoreListener psl)
Description copied from interface: ProcessStore
Register a configuration store listener.

Specified by:
registerListener in interface ProcessStore
Parameters:
psl - ProcessStoreListener

unregisterListener

public void unregisterListener(ProcessStoreListener psl)
Description copied from interface: ProcessStore
Unregister a configuration store listener.

Specified by:
unregisterListener in interface ProcessStore
Parameters:
psl - ProcessStoreListener

calcInitialProperties

public static java.util.Map<javax.xml.namespace.QName,org.w3c.dom.Node> calcInitialProperties(TDeployment.Process dd)
Create a property mapping based on the initial values in the deployment descriptor.

Parameters:
dd -
Returns:

load

protected java.util.List<ProcessConfImpl> load(DeploymentUnitDAO dudao)
Load a deployment unit record stored in the db into memory.

Parameters:
dudao -

findDeployDir

protected java.io.File findDeployDir(DeploymentUnitDAO dudao)

load

protected boolean load(java.lang.String duName)
Make sure that the deployment unit is loaded.

Parameters:
duName - deployment unit name

setDeployDir

public void setDeployDir(java.io.File depDir)

getDeployDir

public java.io.File getDeployDir()

getConfigDir

public java.io.File getConfigDir()

setConfigDir

public void setConfigDir(java.io.File configDir)

createInternalDS

public static javax.sql.DataSource createInternalDS(java.lang.String guid)

shutdownInternalDB

public static void shutdownInternalDB(javax.sql.DataSource ds)

refreshSchedules

public void refreshSchedules(java.lang.String packageName)
Specified by:
refreshSchedules in interface ProcessStore