org.ogf.graap.wsag.server.monitoring
Class MonitorableAgreement

java.lang.Object
  extended by java.util.Observable
      extended by org.ogf.graap.wsag.server.monitoring.MonitorableAgreement
All Implemented Interfaces:
Observer, Agreement

public class MonitorableAgreement
extends Observable
implements Agreement, Observer

MonitorableAgreement Supports monitoring of service terms, agreement state and automatic evaluation of guarantee terms.

Author:
Oliver Waeldrich

Field Summary
static String MONITORING_ACTIVE
          Key to resolve if monitoring was started for a particular agreement implementation from the agreement execution context.
static String MONITORING_CRON
          Key to resolve the monitoring interval for a particular agreement implementation from the agreement execution context.
static String MONITORING_HANDLER
          Key to resolve the class names of the monitoring handler for a particular agreement implementation from the agreement execution context.
static String MONITORING_HANDLER_COUNT
          Key to resolve the number of the monitoring handler for a particular agreement implementation from the agreement execution context.
 
Constructor Summary
MonitorableAgreement(AbstractAgreementType agreement)
          Creates a new instance of a monitorable agreement.
MonitorableAgreement(PersistentAgreementContainer persistentAgreementContainer)
          Recreates an instance of a monitorable agreement.
 
Method Summary
 void addMonitoringHandler(IServiceTermMonitoringHandler handler)
           
 IAccountingSystem getAccountingSystem()
           
 String getAgreementId()
          Returns the agreement id.
 AbstractAgreementType getAgreementInstance()
          Returns a domain-specific agreement implementation.
 AgreementContextType getContext()
           
 String getCronExpression()
           
 IAgreementContext getExecutionContext()
           
 GuaranteeTermStateType[] getGuaranteeTermStates()
           
 IServiceTermMonitoringHandler[] getMonitoringHandler()
          Returns the list of registered monitoring handler.
 String getName()
          Returns the agreement name.
 ServiceTermStateType[] getServiceTermStates()
           
 AgreementStateType getState()
           
 TermTreeType getTerms()
           
 boolean isMonitoring()
           
 void notifyReload()
          This method notifies a concrete agreement instance that the monitored agreement instance was reloaded.
 void setAccountingSystem(IAccountingSystem accountingSystem)
           
 void setCronExpression(String cronExpression)
           
 void setExecutionContext(IAgreementContext executionContext)
           
 void startMonitoring()
          Starts the agreement monitoring process.
 void stopMonitoring()
          Stops the agreement monitoring.
 void terminate(TerminateInputType reason)
          Terminates an agreement.
 void update(Observable o, Object arg)
          If the monitored agreement receives a state change notification of the concrete agreement implementation (@link Observable.notifyObservers()) all observer registered to this monitorable agreement will be notified of the state change ass well.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MONITORING_ACTIVE

public static final String MONITORING_ACTIVE
Key to resolve if monitoring was started for a particular agreement implementation from the agreement execution context. It refers a XmlBoolean. If the boolean value is true monitoring was started using the MonitorableAgreement, if false or not present monitoring was not used. Used for loading persisted agreements.

See Also:
getAgreementInstance(), AbstractAgreementType.getExecutionContext(), Constant Field Values

MONITORING_CRON

public static final String MONITORING_CRON
Key to resolve the monitoring interval for a particular agreement implementation from the agreement execution context. It refers a XmlString value. Used for loading persisted agreements.

See Also:
getAgreementInstance(), AbstractAgreementType.getExecutionContext(), Constant Field Values

MONITORING_HANDLER

public static final String MONITORING_HANDLER
Key to resolve the class names of the monitoring handler for a particular agreement implementation from the agreement execution context. It refers a XmlString. The monitoring handler class names are stored in the agreement execution context with the following strategy: MONITORING_HANDLER + "." + handler[i].getClass().getName() Used for loading persisted agreements.

See Also:
getAgreementInstance(), AbstractAgreementType.getExecutionContext(), Constant Field Values

MONITORING_HANDLER_COUNT

public static final String MONITORING_HANDLER_COUNT
Key to resolve the number of the monitoring handler for a particular agreement implementation from the agreement execution context. It refers a XmlInt. Used for loading persisted agreements.

See Also:
getAgreementInstance(), AbstractAgreementType.getExecutionContext(), Constant Field Values
Constructor Detail

MonitorableAgreement

public MonitorableAgreement(AbstractAgreementType agreement)
Creates a new instance of a monitorable agreement. The agreement object, for which this MonitorableAgreement is created, implements the methods to store the terms and the state of the agreement, and to terminate the agreement.

Parameters:
agreement - the agreement object, which should be monitored.

MonitorableAgreement

public MonitorableAgreement(PersistentAgreementContainer persistentAgreementContainer)
Recreates an instance of a monitorable agreement. The agreement object, for which this MonitorableAgreement is created, implements the methods to store the terms and the state of the agreement, and to terminate the agreement.

Parameters:
persistentAgreementContainer - the persisted agreement object, which should be monitored.
Method Detail

isMonitoring

public boolean isMonitoring()
Returns:
the monitoring

getExecutionContext

public IAgreementContext getExecutionContext()
Returns:
the executionContext

setExecutionContext

public void setExecutionContext(IAgreementContext executionContext)
Parameters:
executionContext - the executionContext to set

addMonitoringHandler

public void addMonitoringHandler(IServiceTermMonitoringHandler handler)
Parameters:
handler - monitoring handler

getMonitoringHandler

public IServiceTermMonitoringHandler[] getMonitoringHandler()
Returns the list of registered monitoring handler.

Returns:
the monitoringHandler

getCronExpression

public String getCronExpression()
Returns:
the cronExpression

setCronExpression

public void setCronExpression(String cronExpression)
Parameters:
cronExpression - the cronExpression to set

startMonitoring

public void startMonitoring()
                     throws Exception
Starts the agreement monitoring process.

Throws:
Exception - failed to start monitoring

stopMonitoring

public void stopMonitoring()
                    throws Exception
Stops the agreement monitoring.

Throws:
Exception - error while stopping the agreement monitor scheduler

terminate

public void terminate(TerminateInputType reason)
Terminates an agreement.

Specified by:
terminate in interface Agreement
Parameters:
reason - termination reason

notifyReload

public void notifyReload()
                  throws Exception
This method notifies a concrete agreement instance that the monitored agreement instance was reloaded. This essentially implies that the AbstractAgreementType.notifyReload(java.util.Map) method is invoked. Implementations of the AbstractAgreementType can override the AbstractAgreementType.notifyReinitialized(java.util.Map) in order to implement domain specific re-initialization logic.

Throws:
Exception - indicates an error during the agreement reload process

getAgreementId

public String getAgreementId()
Description copied from interface: Agreement
Returns the agreement id.

Specified by:
getAgreementId in interface Agreement
Returns:
the agreement id
See Also:
Agreement.getAgreementId()

getContext

public AgreementContextType getContext()
Specified by:
getContext in interface Agreement
Returns:
the agreement context
See Also:
Agreement.getContext()

getGuaranteeTermStates

public GuaranteeTermStateType[] getGuaranteeTermStates()
Specified by:
getGuaranteeTermStates in interface Agreement
Returns:
the guarantee term states
See Also:
Agreement.getGuaranteeTermStates()

getName

public String getName()
Description copied from interface: Agreement
Returns the agreement name.

Specified by:
getName in interface Agreement
Returns:
the agreement name
See Also:
Agreement.getName()

getServiceTermStates

public ServiceTermStateType[] getServiceTermStates()
Specified by:
getServiceTermStates in interface Agreement
Returns:
the service term states
See Also:
Agreement.getServiceTermStates()

getState

public AgreementStateType getState()
Specified by:
getState in interface Agreement
Returns:
the agreement state
See Also:
Agreement.getState()

getTerms

public TermTreeType getTerms()
Specified by:
getTerms in interface Agreement
Returns:
the terms of the agreement
See Also:
Agreement.getTerms()

getAgreementInstance

public AbstractAgreementType getAgreementInstance()
Returns a domain-specific agreement implementation. The AbstractAgreementType implements the domain-specific termination method and stored the agreement properties. The AbstractAgreementType.getXMLObject() returns the actual properties of an agreement implementation. These properties must be valid at all time, i.e. if an agreement implementation overrides the Agreement.getState() method the implementation must make sure that the agreement properties are updated with the returned state.

Specified by:
getAgreementInstance in interface Agreement
Returns:
the agreement implementation

setAccountingSystem

public void setAccountingSystem(IAccountingSystem accountingSystem)
Parameters:
accountingSystem - the accountingSystem to set

getAccountingSystem

public IAccountingSystem getAccountingSystem()
Returns:
the accountingSystem

update

public void update(Observable o,
                   Object arg)
If the monitored agreement receives a state change notification of the concrete agreement implementation (@link Observable.notifyObservers()) all observer registered to this monitorable agreement will be notified of the state change ass well.

Specified by:
update in interface Observer
See Also:
Observer.update(java.util.Observable, java.lang.Object)


Copyright © 2008-2012 Fraunhofer Institute SCAI. All Rights Reserved.