Access to application attributes in a service

The service API gives developers access to information exposed to the Service Instance.

Scope


Applicability

Details

Operating system

  • Windows

  • Linux

  • Solaris

Limitations

None


About application attributes for services

The service API enables developers to access the following application attributes from the ServiceContext object:
  • Application name

  • Service name

  • Consumer ID

  • Deployment directory

  • Configured log directory

Example: Get application attributes with service API

To retrieve and print all the additional information your service code would look like this:
C++
const char* applicationName = serviceContext.getApplicationName();
const char* consumerId = serviceContext.getConsumerId();
const char* deploymentDir = serviceContext.getDeployDirectory();
const char* logDir = serviceContext.getLogDirectory();
const char* serviceName = serviceContext.getServiceName();
...
C# (.NET)
string applicationName = serviceContext.ApplicationName;
string consumerId = serviceContext.ConsumerId;
string deploymentDir = serviceContext.DeployDirectory;
string logDir = serviceContext.LogDirectory;
string serviceName = serviceContext.ServiceName;
...
Java
String applicationName = serviceContext.getApplicationName();
String consumerId = serviceContext.getConsumerId();
String deploymentDir = serviceContext.getDeployDirectory();
String logDir = serviceContext.getLogDirectory();
String serviceName = serviceContext.getServiceName();
...