org.tigris.scarab.services
Class TorqueService

java.lang.Object
  extended byorg.apache.fulcrum.BaseService
      extended byorg.tigris.scarab.services.TorqueService
All Implemented Interfaces:
org.apache.fulcrum.Service

public class TorqueService
extends org.apache.fulcrum.BaseService

Turbine does not yet have a way to initialize components directly, and use of fulcrum's DatabaseService causes fulcrum to try to treat all the Managers as services. So this service is used to initialize Torque. It also creates an instance of each scarab om object to avoid deadlock.

Version:
$Id: TorqueService.java 9891 2005-10-23 13:57:24Z jorgeuriarte $
Author:
John McNally

Field Summary
 
Fields inherited from class org.apache.fulcrum.BaseService
configuration, isInitialized, name, serviceBroker
 
Fields inherited from interface org.apache.fulcrum.Service
SERVICE_NAME
 
Constructor Summary
TorqueService()
           
 
Method Summary
 void init()
          Initializes the service by setting up Torque.
protected  void loadOM()
          This method loads all the classes in the org.tigris.scarab.om package.
 void shutdown()
          Shuts down the service.
 
Methods inherited from class org.apache.fulcrum.BaseService
getCategory, getConfiguration, getInit, getName, getRealPath, getServiceBroker, getServiceObject, getStatus, isInitialized, setInit, setName, setServiceBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TorqueService

public TorqueService()
Method Detail

init

public void init()
          throws org.apache.fulcrum.InitializationException
Initializes the service by setting up Torque.

Throws:
org.apache.fulcrum.InitializationException

loadOM

protected void loadOM()
               throws java.lang.Exception
This method loads all the classes in the org.tigris.scarab.om package. The torque classes of Foo and FooPeer contain a circular relationship so loading the class of Foo requires a FooPeer instance and creating a FooPeer instance requires the Foo class to be loaded. It is possible to deadlock if multiple threads attempt to load Foo simultaneously. A full analysis of possible deadlock scenarios has not been done, so to be as safe as possible we create one instance of each om object via the Manager.getInstance() method; this makes sure the Managers are initialized as well. It may be possible to reduce this to only calling Class.forName on each class.

Throws:
java.lang.Exception

shutdown

public void shutdown()
Shuts down the service. This method halts the IDBroker's daemon thread in all of the DatabaseMap's.



Copyright © 2000-2004 Tigris.org. All Rights Reserved.