org.oddjob.sql
Class SQLPersisterService

java.lang.Object
  extended by org.oddjob.sql.SQLPersisterService

public class SQLPersisterService
extends Object

Description

Persists job state to a database. The database must have a table which can be created with the following sql.

 CREATE TABLE oddjob(
   path VARCHAR(128), 
   id VARCHAR(32), 
   job BLOB, 
  CONSTRAINT oddjob_pk PRIMARY KEY (path, id))
 

Example

Using a SQL Persister.
<oddjob id="this">
    <job>
        <sequential>
            <jobs>
                <sql-persister-service id="sql-persister">
                    <connection>
                        <connection driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:mem:test" username="sa"/>
                    </connection>
                </sql-persister-service>
                <oddjob id="oj" file="${this.dir}/SQLPersisterInner.xml">
                    <persister>
                        <value value="${sql-persister.persister(test)}"/>
                    </persister>
                </oddjob>
                <stop job="${sql-persister}"/>
            </jobs>
        </sequential>
    </job>
</oddjob>
Note that because this is a service, it must be stopped once the inner Oddjob has completed it's work. In an Oddjob that was running continually this would not be necessary.
Author:
Rob Gordon.

Constructor Summary
SQLPersisterService()
           
 
Method Summary
 String getName()
           
 OddjobPersister getPersister(String path)
           
 SQLSerializationFactory getSerializationFactory()
           
 void setConnection(Connection connection)
          Set the connection.
 void setName(String name)
           
 void setSerializationFactory(SQLSerializationFactory serializationFactory)
           
 void start()
           
 void stop()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SQLPersisterService

public SQLPersisterService()
Method Detail

start

public void start()
           throws SQLException
Throws:
SQLException

stop

public void stop()
          throws SQLException
Throws:
SQLException

setConnection

public void setConnection(Connection connection)
                   throws SQLException
Set the connection.

Parameters:
connection - The connection.
Throws:
SQLException

getName

public String getName()

setName

public void setName(String name)

getSerializationFactory

public SQLSerializationFactory getSerializationFactory()

setSerializationFactory

public void setSerializationFactory(SQLSerializationFactory serializationFactory)

getPersister

public OddjobPersister getPersister(String path)

Property: persister

Description: The persister.

Required: R/O.


toString

public String toString()
Overrides:
toString in class Object