org.apache.turbine.services.castor
Class TurbineCastorService

java.lang.Object
  |
  +--org.apache.turbine.services.BaseInitable
        |
        +--org.apache.turbine.services.BaseService
              |
              +--org.apache.turbine.services.TurbineBaseService
                    |
                    +--org.apache.turbine.services.castor.TurbineCastorService
All Implemented Interfaces:
CastorService, Initable, Service

public class TurbineCastorService
extends TurbineBaseService
implements CastorService

This is a Service that offers access to the object to relational mapping from Castor. Here's an example of how you might use it:

 TurbineServices ts = TurbineServices.getInstance();
 CastorService cs = (CastorService) ts.getService (CastorService.SERVICE_NAME);
 Database db = cs.getDatabase();
 db.begin();
 ...
 db.commit();
 db.close();
 
The following properties are needed to configure this service:
 services.CastorService.classname=org.apache.turbine.services.castor.TurbineCastorService
 services.CastorService.properties.logfile=/tmp/castor.log
 services.CastorService.properties.logprefix=turbinecastor
 services.CastorService.properties.databasefile=/tmp/database.xml
 services.CastorService.properties.databasename=turbine
 
classname
the classname of this service
logfile
the path to a writable file. Castor uses its own log file
logprefix
the prefix used in the logfile to distinguish from Castor log entry and this Service. This is a recommended property
databasefile
the path to a readable file defining the mappings of the java objects an the underlying tables/columns
databasename
references a name of a database definition tag used in the mapping file

Version:
$Id: TurbineCastorService.java,v 1.1.1.1 2001/08/16 05:08:51 jvanzyl Exp $
Author:
Giacomo Pati, Christopher Elkins

Inner Class Summary
private  class TurbineCastorService.LocalResolver
          Deprecated. Internal class to resolve entities in the database mapping file.
 
Field Summary
private  java.lang.String databasefile
          Deprecated. The mapping file for the database.
private  java.lang.String databasename
          Deprecated. The name of the database to use (references the database tag in the mapping file, not the real database name).
private  org.exolab.castor.jdo.JDO jdo
          Deprecated. Castor JDO object.
private  java.io.PrintWriter logger
          Deprecated. Castor logger.
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, properties, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.turbine.services.castor.CastorService
DATABASEFILE_PROPERTY, DATABASENAME_PROPERTY, DEFAULT_LOGPREFIX, LOGFILE_PROPERTY, LOGPREFIX_PROPERTY, SERVICE_NAME
 
Constructor Summary
TurbineCastorService()
          Deprecated.  
 
Method Summary
 java.io.PrintWriter getCastorLogger()
          Deprecated. Gets you the PrintWriter object Castor is using for logging.
 org.exolab.castor.jdo.Database getDatabase()
          Deprecated. Gets a Castor Database object in the context of the defined environment.
 org.exolab.castor.jdo.JDO getJDO()
          Deprecated. Gets a JDO object initialized to the database mentioned in the property databasename.
 void init()
          Deprecated. Called the first time the Service is used.
private  void initCastor()
          Deprecated. Checks the properties and hands the mapping file to Castor.
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, init, shutdown
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, setInitableBroker, shutdown
 

Field Detail

databasename

private java.lang.String databasename
Deprecated. 
The name of the database to use (references the database tag in the mapping file, not the real database name).

databasefile

private java.lang.String databasefile
Deprecated. 
The mapping file for the database.

logger

private java.io.PrintWriter logger
Deprecated. 
Castor logger.

jdo

private org.exolab.castor.jdo.JDO jdo
Deprecated. 
Castor JDO object.
Constructor Detail

TurbineCastorService

public TurbineCastorService()
Deprecated. 
Method Detail

init

public void init()
          throws InitializationException
Deprecated. 
Called the first time the Service is used.
Specified by:
init in interface Initable
Overrides:
init in class TurbineBaseService
Following copied from interface: org.apache.turbine.services.Initable
Throws:
InitializationException, - if initialization of this class was not successful.

initCastor

private void initCastor()
                 throws java.io.IOException,
                        org.exolab.castor.mapping.MappingException,
                        java.lang.Exception
Deprecated. 
Checks the properties and hands the mapping file to Castor.
Throws:
IOException, - if there were problems to get the logfile.
MappingException, - if the mapping file is invalid.
Exception, - if no databasefile or databasename is given in the properties.

getCastorLogger

public java.io.PrintWriter getCastorLogger()
Deprecated. 
Gets you the PrintWriter object Castor is using for logging.
Specified by:
getCastorLogger in interface CastorService
Returns:
PrintWriter logger object of Castor.

getJDO

public org.exolab.castor.jdo.JDO getJDO()
Deprecated. 
Gets a JDO object initialized to the database mentioned in the property databasename.
Specified by:
getJDO in interface CastorService
Returns:
JDO object initialized to the database mentioned in the property databasename.

getDatabase

public org.exolab.castor.jdo.Database getDatabase()
                                           throws org.exolab.castor.jdo.DatabaseNotFoundException,
                                                  org.exolab.castor.jdo.PersistenceException
Deprecated. 
Gets a Castor Database object in the context of the defined environment.
Specified by:
getDatabase in interface CastorService
Returns:
Database object
Throws:
DatabaseNotFoundException, - if attempted to open a database that does not exist.
PersistenceException, - if database access failed.


Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.