org.ogf.graap.wsag.server.engine
Class WsagEngine

java.lang.Object
  extended by org.ogf.graap.wsag.server.engine.WsagEngine
All Implemented Interfaces:
IAgreementFactoryHome

public class WsagEngine
extends Object
implements IAgreementFactoryHome

The WSAGEngine provides access to all agreement factories configured for this engine. The available factories can be retrieved via the agreement factory home interface. The agreement factory home is retrieved by the #getAgreementFactoryHome() method. Before the engine can be used it must be initialized. Engine initialization is triggered by the #initializeEngine(String) method.

Author:
Oliver Waeldrich

Field Summary
protected  List<PersistentAgreementFactory> factoriesOL
          An ordered list with the available agreement factories.
protected  Map<String,PersistentAgreementFactory> persistentFactories
          A map that contains the available persistent agreement factory which are identified by their factory id.
 
Method Summary
 PersistentAgreementFactory find(String factoryId)
          looks up a factory with the given id.
 IAgreementFactory getAgreementFactoryPrototype()
          Instantiates a new agreement factory instance based on the engine configuration.
 WSAG4JEngineConfigurationType getConfiguration()
          Returns the configuration for this engine instance.
 String getDefaultResourceId()
          Returns the resource id configured for this engine instance or the a generated UUID if not set.
static WsagEngine getInstance(InputStream configuration)
          Returns a new WSAG engine instance.
static WsagEngine getInstance(String configFile)
          Returns a new WSAG engine instance.
static WsagEngine getInstance(WSAG4JEngineConfigurationType engineConfiguration)
          Returns a new WSAG engine instance.
 IAgreementFactoryHome getPersistenceLayer()
          Returns the persistence layer for this engine.
 PersistentAgreementFactory[] list()
          Lists all agreement factories.
 void remove(String factoryId)
          Removes the factory with the given ID.
 void save()
          Saves all factories.
 void saveAgreementFactories(PersistentAgreementFactory[] factories)
           
 void shutdown()
          Shutdown of the WSAG4J engine instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

persistentFactories

protected Map<String,PersistentAgreementFactory> persistentFactories
A map that contains the available persistent agreement factory which are identified by their factory id.


factoriesOL

protected List<PersistentAgreementFactory> factoriesOL
An ordered list with the available agreement factories. The factories are stored in the order they were retrieved from the persistence layer.

Method Detail

getInstance

public static WsagEngine getInstance(InputStream configuration)
                              throws EngineInstantiationException
Returns a new WSAG engine instance.

Parameters:
configuration - engine configuration as input stream
Returns:
the new created engine instance
Throws:
EngineInstantiationException - failed to instantiate the engine

getInstance

public static WsagEngine getInstance(String configFile)
                              throws EngineInstantiationException
Returns a new WSAG engine instance.

Parameters:
configFile - engine configuration as file name (must be available in the class path)
Returns:
the new created engine instance
Throws:
EngineInstantiationException - failed to instantiate the engine

getInstance

public static WsagEngine getInstance(WSAG4JEngineConfigurationType engineConfiguration)
                              throws EngineInstantiationException
Returns a new WSAG engine instance.

Parameters:
engineConfiguration - engine configuration
Returns:
the new created engine instance
Throws:
EngineInstantiationException - failed to instantiate the engine

find

public PersistentAgreementFactory find(String factoryId)
                                throws Exception
looks up a factory with the given id.

Specified by:
find in interface IAgreementFactoryHome
Parameters:
factoryId - the id of the factory to find
Returns:
the factory
Throws:
Exception - an error occurred while looking up the factory.
See Also:
IAgreementFactoryHome.find(String)

getAgreementFactoryPrototype

public IAgreementFactory getAgreementFactoryPrototype()
                                               throws Exception
Instantiates a new agreement factory instance based on the engine configuration.

Parameters:
configuration - Configuration of the wsag4j engine.
Returns:
Agreement factory prototype based on the wsag4j configuration.
Throws:
Exception - failed to initialize the configured factory

getConfiguration

public WSAG4JEngineConfigurationType getConfiguration()
Returns the configuration for this engine instance.

Returns:
the wsag4jConfiguration

getDefaultResourceId

public String getDefaultResourceId()
Returns the resource id configured for this engine instance or the a generated UUID if not set.

Returns:
the default resource id

getPersistenceLayer

public IAgreementFactoryHome getPersistenceLayer()
Returns the persistence layer for this engine.

Returns:
the persistence layer for this engine

list

public PersistentAgreementFactory[] list()
                                  throws Exception
Description copied from interface: IAgreementFactoryHome
Lists all agreement factories.

Specified by:
list in interface IAgreementFactoryHome
Returns:
all available persistent factories
Throws:
Exception - indicates an error while generating the factory list
See Also:
IAgreementFactoryHome.list()

remove

public void remove(String factoryId)
            throws Exception
Description copied from interface: IAgreementFactoryHome
Removes the factory with the given ID.

Specified by:
remove in interface IAgreementFactoryHome
Parameters:
factoryId - removes the factory with the given id from the persistence layer
Throws:
Exception - an error occurred while removing the factory
See Also:
IAgreementFactoryHome.remove(java.lang.String)

save

public void save()
          throws Exception
Saves all factories.

Throws:
Exception - indicates an error while saving the factories

saveAgreementFactories

public void saveAgreementFactories(PersistentAgreementFactory[] factories)
                            throws Exception
Specified by:
saveAgreementFactories in interface IAgreementFactoryHome
Parameters:
factories - the factories to save
Throws:
Exception - indicates an error while saving the factories
See Also:
IAgreementFactoryHome.saveAgreementFactories(org.ogf.graap.wsag.server.persistence.PersistentAgreementFactory[])

shutdown

public void shutdown()
              throws Exception
Shutdown of the WSAG4J engine instance.

Throws:
Exception - indicates an error during engine shutdown


Copyright © 2008-2012. All Rights Reserved.