Visit Platform at http://www.platform.com

Main Page   Class Hierarchy   Compound List   Compound Members  

ServiceContext Class Reference

The interface class of service context used by service instance. More...

List of all members.


Public Types

enum  InterruptEvent {
  IE_NONE, IE_SESSION_KILLED, IE_SESSION_SUSPENDED, IE_SERVICE_DEALLOCATED,
  InterruptNone = IE_NONE, InterruptTaskKilled = IE_SESSION_KILLED, InterruptTaskSuspended = IE_SESSION_SUSPENDED
}

Public Methods

const char * getServiceName () const throw (SoamException)
 Gets the service name.

InterruptEvent getLastInterruptEvent (SoamULong &gracePeriod) const throw (SoamException)
 Gets the current interrupt event.
  • InterruptNone
  • InterruptTaskKilled
  • InterruptTaskSuspended
After detecting an interrupt event, it is up the developer to decide what the best course of action is.


void setControlCode (SoamInt code) throw (SoamException)
 Sets a service control code for service instance manager.

const char * getApplicationName () const throw (SoamException)
 Gets the name of the application.

const char * getConsumerId () const throw (SoamException)
 Gets the consumer ID.

const char * getDeployDirectory () const throw (SoamException)
 Gets the deployment directory.

const char * getLogDirectory () const throw (SoamException)
 Gets the log directory.

ServiceToSlotRatio getServiceToSlotRatio () const throw (SoamException)
 Gets the service to slot ratio for this service instance, which indicates how many slots this service is consuming.

void publish (const ResourceAttribute &attribute, bool throwOnFailure=false) throw (SoamException)
 Publishes the attribute to the system.

void unpublish (const ResourceAttribute &attribute, bool throwOnFailure=false) throw (SoamException)
 "Un-Publishes" the attribute from the system.

void setExcelRunnerServiceFlag (bool excelRunnerServiceFlag) throw (SoamException)
 Sets excelRunnerServiceFlag = true when service is excelRunner.


Friends

class ServiceContainer

Detailed Description

The interface class of service context used by service instance.

It provides functionality that the service will require throughout its lifetime. This object will be passed to a service instance when it is created. The service instance may choose to cache a reference to this object and call on it when it requires any of the features it provides. The ServiceContext is first accessible in the ServiceContainer::onCreateService() method, and is considered invalid after the ServiceContainer::onDestroyService() method returns.

NOTE: It is always best to access a pointer to this type of object through the appropriate smart pointer type instead of using a raw pointer.

See also:
ServiceContextPtr , ServiceContainer::onCreateService


Member Enumeration Documentation

enum InterruptEvent
 

ServiceContext::InterruptEvent Enumeration to indicate the various interrupts that can occur within a service instance. All interrupts will be accompanied by a grace period that will indicate the amount of time that will be given for the service instance to complete it current operation. If the timeout expires before the interrupted operation completes the service instance will be terminated by the middleware.

The service handlers that can be intterrupted are ;

  • onInvoke(...)
See also:
ServiceContainer::onServiceInterrupt , ServiceContainer::onInvoke
Enumeration values:
IE_NONE  This indicates that no interrupt has occured.
Deprecated:
As of Symphony 4.0, replaced by InterruptNone
IE_SESSION_KILLED  This indicates the task is being killed.
Deprecated:
As of Symphony 4.0, replaced by InterruptTaskKilled
IE_SESSION_SUSPENDED  This indicates the task is being suspended.
Deprecated:
As of Symphony 4.0, replaced by InterruptTaskSuspended
IE_SERVICE_DEALLOCATED  This interrupt is sent to the service instance when the service is being deallocated. Any data returned from the interrupted operation will be discarded by the middleware.
InterruptNone  This indicates that no interrupt has occured.
InterruptTaskKilled  This interrupt is sent to the service instance when the task is being killed. Any data returned from the interrupted operation will be discarded by the middleware.
InterruptTaskSuspended  This interrupt is sent to the service instance when the task is being suspended. Any data or exception returned from the interrupted operation will be handled in the normal manner by the middleware.

Member Function Documentation

const char* getServiceName   const throw (SoamException)
 

Gets the service name.

Returns:
a service name.
Exceptions:
SoamException  - if failed

InterruptEvent getLastInterruptEvent SoamULong &    gracePeriod const throw (SoamException)
 

Gets the current interrupt event.

  • InterruptNone
  • InterruptTaskKilled
  • InterruptTaskSuspended
After detecting an interrupt event, it is up the developer to decide what the best course of action is.

Parameters:
gracePeriod  [OUT] - the grace period of interruption
Returns:
event of interruption.
See also:
InterruptEvent
Exceptions:
SoamException 

void setControlCode SoamInt    code throw (SoamException)
 

Sets a service control code for service instance manager.

Parameters:
code  [IN] - the control code defined in the application profile
Exceptions:
SoamException 

const char* getApplicationName   const throw (SoamException)
 

Gets the name of the application.

Returns:
the application name associated with this service instance.
Exceptions:
SoamException 

const char* getConsumerId   const throw (SoamException)
 

Gets the consumer ID.

Returns:
the consumer ID associated with the application.
Exceptions:
SoamException 

const char* getDeployDirectory   const throw (SoamException)
 

Gets the deployment directory.

Returns:
the deployment directory associated with this service.
Exceptions:
SoamException 

const char* getLogDirectory   const throw (SoamException)
 

Gets the log directory.

Note: If no log directory was configured in the application profile, this method will return "${SOAM_HOME}/work".

Returns:
the log directory configured for this application.
Exceptions:
SoamException 

ServiceToSlotRatio getServiceToSlotRatio   const throw (SoamException)
 

Gets the service to slot ratio for this service instance, which indicates how many slots this service is consuming.

The ratio will be either 1:N or N:1, where N is a positive integer. A 1:N ratio means that this service instance is consuming multiple slots. An N:1 ratio means that this service instance is consuming a fraction of a slot.

Returns:
The service to slot ratio for this service instance.
Exceptions:
SoamException 

void publish const ResourceAttribute   attribute,
bool    throwOnFailure = false
throw (SoamException)
 

Publishes the attribute to the system.

The service may publish details about an attribute at any time during its lifetime. To reduce coding complexity, this method will not throw an exception (by default) if the publish cannot be completed successfully. If your service wishes to get an exception on failure to publish then set throwOnFailure to true.

NOTE: If more than one service instance publishes the same attribute with host-level scope, un-publishing the attribute will simply remove one of the publishing references. This means the system will continue to use the last value published for the attribute until all service instances have un-published the same attribute.

Parameters:
attribute  [IN] - The attribute being un-published.
throwOnFailure  [IN] - Indicates if we want the method to throw an exception in the event it fails to publish the attribute. Default value is [false];
See also:
ResourceAttribute
Exceptions:
SoamException 

void unpublish const ResourceAttribute   attribute,
bool    throwOnFailure = false
throw (SoamException)
 

"Un-Publishes" the attribute from the system.

The service may un-publish details about an attribute at any time during its lifetime. To reduce coding complexity, this method will not throw an exception if the un-publishing cannot be completed successfully. If your service wishes to get an exception on failure to "un-publish" then set throwOnFailure to true.

NOTE: If more than one service instance publishes the same attribute with host-level scope, un-publishing the attribute will simply remove one of the publishing references. This means the system will continue to use the last value published for the attribute until all service instances have un-published the same attribute.

Parameters:
attribute  [IN] - The attribute being un-published.
throwOnFailure  [IN] - Indicates if we want the method to throw an exception in the event it fails to un-publish the attribute. Default value is [false];
See also:
ResourceAttribute
Exceptions:
SoamException 

void setExcelRunnerServiceFlag bool    excelRunnerServiceFlag throw (SoamException)
 

Sets excelRunnerServiceFlag = true when service is excelRunner.

Parameters:
code  [IN] - excel runner service flag (Only call in excel service runner service)
Exceptions:
SoamException 


     
Date Modified: 11 Nov 2009
Platform Support: support@platform.com
Platform Information Development: doc@platform.com

Platform Computing. Accelerating Intelligence(TM).
Copyright © 2001-2009 Platform Computing Corporation. All rights reserved.