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

java.lang.Object
  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 Object
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

Field Summary
protected  WSAG4JEngineConfigurationType wsag4jConfiguration
          the wsag4j engine configuration
 
Constructor Summary
AbstractWSAG4JPersistence()
           
 
Method Summary
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.
protected  IAgreementFactory getAgreementFactoryPrototype(WSAG4JEngineConfigurationType configuration)
           
 WSAG4JEngineConfigurationType getEngineConfiguration()
          returns the configuration of the wsag4j engine
 boolean hasChanged()
          Indicates that the persistence layer has changed and needs to be re-initialized (see initialize()).
 void 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()).
 void setEngineConfiguration(WSAG4JEngineConfigurationType configuration)
          sets the configuration of the wsag4j engine
 
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
 

Field Detail

wsag4jConfiguration

protected WSAG4JEngineConfigurationType wsag4jConfiguration
the wsag4j engine configuration

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

getEngineConfiguration

public WSAG4JEngineConfigurationType getEngineConfiguration()
Description copied from interface: IEngineComponent
returns the configuration of the wsag4j engine

Specified by:
getEngineConfiguration in interface IEngineComponent
Returns:
Configuration for this agreement factory home instance.

setEngineConfiguration

public void setEngineConfiguration(WSAG4JEngineConfigurationType configuration)
Description copied from interface: IEngineComponent
sets the configuration of the wsag4j engine

Specified by:
setEngineConfiguration in interface IEngineComponent
Parameters:
configuration - The configuration used to initialize this agreement factory home instance.

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

getAgreementFactoryPrototype

protected IAgreementFactory getAgreementFactoryPrototype(WSAG4JEngineConfigurationType configuration)
                                                  throws Exception
Parameters:
configuration - Configuration of the wsag4j engine.
Returns:
Agreement factory prototype based on the wsag4j configuration.
Throws:
Exception - failed to initialize the configured factory

initialize

public void initialize()
                throws Exception

Specified by:
initialize in interface IEngineComponent
Throws:
Exception - Indicates an error while initializing the engine component.

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 Fraunhofer Institute SCAI. All Rights Reserved.