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(Agreement 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.
 Agreement getAgreementInstance()
          
 AgreementContextType getContext()
           
 String getCronExpression()
           
 Map<String,org.apache.xmlbeans.XmlObject> getExecutionContext()
          Returns the persisted execution context for this agreement.
 GuaranteeTermStateType[] getGuaranteeTermStates()
           
 Class getImplementationClass()
          Returns the class of the agreement implementation.
 IAgreementContext getMonitoringContext()
          Deprecated.  
 IServiceTermMonitoringHandler[] getMonitoringHandler()
          Returns the list of registered monitoring handler.
 String getName()
          Returns the agreement name.
 ServiceTermStateType[] getServiceTermStates()
           
 AgreementStateType getState()
           
 TermTreeType getTerms()
           
 Map<String,Object> getTransientExecutionContext()
          Returns the transient execution context for this agreement.
 AgreementPropertiesType getXMLObject()
          Returns the agreement properties as XmlObject.
 boolean isMonitoring()
           
 void notifyReload()
          This method notifies a concrete agreement instance that the monitored agreement instance was reloaded.
 void notifyReload(Map<String,org.apache.xmlbeans.XmlObject> executionCtx)
          This method allows an agreement instance to get notified after reload.
 void setAccountingSystem(IAccountingSystem accountingSystem)
           
 void setAgreementId(String agreementId)
          Sets the ID of the agreement.
 void setContext(AgreementContextType context)
          Sets the context of the agreement.
 void setCronExpression(String cronExpression)
           
 void setExecutionContext(IAgreementContext executionContext)
           
 void setGuaranteeTermStates(GuaranteeTermStateType[] guaranteeTermStateList)
          Sets the guarantee term states of the agreement.
 void setName(String name)
          Sets the name of the agreement.
 void setServiceTermStates(ServiceTermStateType[] serviceTermStateList)
          Sets the service term states of the agreement.
 void setState(AgreementStateType agreementState)
          Sets the state of the agreement.
 void setTerms(TermTreeType terms)
          Sets the terms of the agreement.
 void setXmlObject(AgreementPropertiesType properties)
          Sets the properties for this agreement explicitly.
 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 Agreement.notifyObservers()) all observer registered to this monitorable agreement will be notified of the state change ass well.
 boolean validate()
          Validates the resource properties document of this instance.
 
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
 
Methods inherited from interface org.ogf.graap.wsag.api.Agreement
addObserver, hasChanged, notifyObservers, notifyObservers
 

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(), Agreement.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(), Agreement.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(), Agreement.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(), Agreement.getExecutionContext(), Constant Field Values
Constructor Detail

MonitorableAgreement

public MonitorableAgreement(Agreement 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

getMonitoringContext

@Deprecated
public IAgreementContext getMonitoringContext()
Deprecated. 

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 Agreement.notifyReload(java.util.Map) method is invoked. Implementations of the Agreement can override the Agreement#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 Agreement getAgreementInstance()


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 Agreement.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)

validate

public boolean validate()
Description copied from interface: Agreement
Validates the resource properties document of this instance.

Specified by:
validate in interface Agreement
Returns:
true if the resource properties document is valid, otherwise false.
See Also:
Agreement.validate()

notifyReload

public void notifyReload(Map<String,org.apache.xmlbeans.XmlObject> executionCtx)
Description copied from interface: Agreement
This method allows an agreement instance to get notified after reload. An invocation of the Agreement.notifyReload(Map) method sets the execution context (see Agreement.getExecutionContext()) of the agreement and invokes the #notifyReinitialized(Map) method of this agreement instance.

Specified by:
notifyReload in interface Agreement
Parameters:
executionCtx - the current execution context
See Also:
Agreement.notifyReload(java.util.Map)

setAgreementId

public void setAgreementId(String agreementId)
Description copied from interface: Agreement
Sets the ID of the agreement.

Specified by:
setAgreementId in interface Agreement
Parameters:
agreementId - the agreement id to set
See Also:
Agreement.setAgreementId(java.lang.String)

setContext

public void setContext(AgreementContextType context)
Description copied from interface: Agreement
Sets the context of the agreement.

Specified by:
setContext in interface Agreement
Parameters:
context - the agreement context to set
See Also:
Agreement.setContext(org.ogf.schemas.graap.wsAgreement.AgreementContextType)

setName

public void setName(String name)
Description copied from interface: Agreement
Sets the name of the agreement.

Specified by:
setName in interface Agreement
Parameters:
name - the agreement name to set
See Also:
Agreement.setName(java.lang.String)

setTerms

public void setTerms(TermTreeType terms)
Description copied from interface: Agreement
Sets the terms of the agreement.

Specified by:
setTerms in interface Agreement
Parameters:
terms - the agreement terms to set
See Also:
Agreement.setTerms(org.ogf.schemas.graap.wsAgreement.TermTreeType)

setState

public void setState(AgreementStateType agreementState)
Description copied from interface: Agreement
Sets the state of the agreement.

Specified by:
setState in interface Agreement
Parameters:
agreementState - the agreement state to set
See Also:
Agreement.setState(org.ogf.schemas.graap.wsAgreement.AgreementStateType)

setGuaranteeTermStates

public void setGuaranteeTermStates(GuaranteeTermStateType[] guaranteeTermStateList)
Description copied from interface: Agreement
Sets the guarantee term states of the agreement.

Specified by:
setGuaranteeTermStates in interface Agreement
Parameters:
guaranteeTermStateList - the guarantee term states to set
See Also:
Agreement.setGuaranteeTermStates(org.ogf.schemas.graap.wsAgreement.GuaranteeTermStateType[])

setServiceTermStates

public void setServiceTermStates(ServiceTermStateType[] serviceTermStateList)
Description copied from interface: Agreement
Sets the service term states of the agreement.

Specified by:
setServiceTermStates in interface Agreement
Parameters:
serviceTermStateList - the service term states to set
See Also:
Agreement.setServiceTermStates(org.ogf.schemas.graap.wsAgreement.ServiceTermStateType[])

getXMLObject

public AgreementPropertiesType getXMLObject()
Description copied from interface: Agreement
Returns the agreement properties as XmlObject.

Specified by:
getXMLObject in interface Agreement
Returns:
an XML representation of the agreement properties document
See Also:
Agreement.getXMLObject()

setXmlObject

public void setXmlObject(AgreementPropertiesType properties)
Description copied from interface: Agreement
Sets the properties for this agreement explicitly.

Specified by:
setXmlObject in interface Agreement
Parameters:
properties - the agreement properties to set
See Also:
Agreement.setXmlObject(org.ogf.schemas.graap.wsAgreement.AgreementPropertiesType)

getTransientExecutionContext

public Map<String,Object> getTransientExecutionContext()
Description copied from interface: Agreement
Returns the transient execution context for this agreement.

Specified by:
getTransientExecutionContext in interface Agreement
Returns:
the agreement transient execution context
See Also:
Agreement.getTransientExecutionContext()

getImplementationClass

public Class getImplementationClass()
Description copied from interface: Agreement
Returns the class of the agreement implementation.

Specified by:
getImplementationClass in interface Agreement
Returns:
the implementation class
See Also:
Agreement.getImplementationClass()

getExecutionContext

public Map<String,org.apache.xmlbeans.XmlObject> getExecutionContext()
Description copied from interface: Agreement
Returns the persisted execution context for this agreement.

Specified by:
getExecutionContext in interface Agreement
Returns:
the agreement persisted execution context


Copyright © 2008-2012. All Rights Reserved.