org.ogf.graap.wsag.server.persistence.impl
Class AbstractWSAG4JPersistence

java.lang.Object
  extended by org.ogf.graap.wsag.server.api.EngineComponent
      extended by org.ogf.graap.wsag.server.persistence.impl.AbstractWSAG4JPersistence
All Implemented Interfaces:
IEngineComponent, IAgreementFactoryHome
Direct Known Subclasses:
DatabaseWSAG4JPersistence, SimpleWSAG4JPersistence

public abstract class AbstractWSAG4JPersistence
extends EngineComponent
implements IAgreementFactoryHome

Abstract implementation of an agreement factory home. This implementation provides global configuration-related functions as well as it is responsible to find and load the agreement factory prototype (based on the configuration).

All implementations of the IAgreementFactoryHome interface should extend this abstract implementation.

Author:
Oliver Waeldrich

Constructor Summary
AbstractWSAG4JPersistence()
           
 
Method Summary
protected  void doInitialize()
          
protected abstract  PersistentAgreementFactory[] doLoad()
          Loads the agreement factories for this persistence layer.
protected abstract  boolean doRemove(PersistentAgreementFactory factory)
          Removes a persistent factory from the persistence layer.
 PersistentAgreementFactory find(String agreementFactoryId)
          Lists the agreement for the factory with the given id.
 boolean hasChanged()
          Indicates that the persistence layer has changed and needs to be re-initialized (see #initialize()).
 PersistentAgreementFactory[] list()
          Lists all agreement factories.
 void remove(String factoryId)
          Removes the factory with the given ID.
 void setChanged(boolean changed)
          Sets the flag to indicate that the persistence layer has changed and needs to be re-initialized (see #initialize()).
 
Methods inherited from class org.ogf.graap.wsag.server.api.EngineComponent
getEngine, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ogf.graap.wsag.server.persistence.IAgreementFactoryHome
saveAgreementFactories
 

Constructor Detail

AbstractWSAG4JPersistence

public AbstractWSAG4JPersistence()
Method Detail

doLoad

protected abstract PersistentAgreementFactory[] doLoad()
                                                throws PersistedResourceException
Loads the agreement factories for this persistence layer. The load method is invoked during the initialization process of the persistence layer (see #initialize()) or during a find(String), list() or remove(String) operation

Returns:
the loaded factories
Throws:
PersistedResourceException - indicates an error while loading the persistent factories

doRemove

protected abstract boolean doRemove(PersistentAgreementFactory factory)
                             throws PersistedResourceException
Removes a persistent factory from the persistence layer.

Parameters:
factory - the factory to remove
Returns:
true if the factory was removed, otherwise false
Throws:
PersistedResourceException - indicates an error while removing the factory

hasChanged

public boolean hasChanged()
Indicates that the persistence layer has changed and needs to be re-initialized (see #initialize()).

Returns:
true if the persistence layer needs to be reloaded, otherwise false.

setChanged

public void setChanged(boolean changed)
Sets the flag to indicate that the persistence layer has changed and needs to be re-initialized (see #initialize()).

Parameters:
changed - true if the persistence layer needs to be reloaded, otherwise false

doInitialize

protected void doInitialize()
                     throws Exception

Specified by:
doInitialize in class EngineComponent
Throws:
Exception

find

public PersistentAgreementFactory find(String agreementFactoryId)
                                throws Exception
Lists the agreement for the factory with the given id.

Specified by:
find in interface IAgreementFactoryHome
Parameters:
agreementFactoryId - the id of the factory for which the agreements are listed
Returns:
the factory with the given id
Throws:
Exception - indicates an error while looking up the factory at the persistence layer

list

public PersistentAgreementFactory[] list()
                                  throws Exception
Lists all agreement factories.

Specified by:
list in interface IAgreementFactoryHome
Returns:
List of all agreement factories.
Throws:
Exception - indicates an exception while loading the factories from the database

remove

public void remove(String factoryId)
            throws Exception
Removes the factory with the given ID.

Specified by:
remove in interface IAgreementFactoryHome
Parameters:
factoryId - ID of the factory to remove.
Throws:
Exception - indicates an exception while removing the factory from the database


Copyright © 2008-2012. All Rights Reserved.