Skip to content

Service Implementations

The OpenJAUS SDK provides a number of service implementations that can be used to quickly build a JAUS Component. The Core (AS5710A) service implementations (Transport, Events, AccessContol, Management, Liveness, Discovery) are built into the base Components and are included automatically depending on which base Component is used. Additional service implementations must be manually added to the Component.

There are two styles of service implementations provided:

  1. Inheritance based implementations
  2. Delegate based implementations

Inheritance based implementations (Older)

The older and more common service implementation style is the inheritance based implementation. It is anticipated that all service implementations will eventually be migrated to the delegate based implementation style (see below).

This style of service implementation requires the derived Component class to inherit from the service implementation class to implement the service behavior. In addition, the derived class should call the configure, start, and stop methods of the service implementation to ensure that it is correctly configured, started, and/or stopped. Some service implementations may also require the derived Component class to override and implement some additional methods to handle service specific behavior.

Inheritance based service implementations end with Impl in the class name. For example, the HealthReporter inheritance based service implementation is named HealthReporterImpl.

Example:

// .h file

class MyHealthReporterComponent :
    public openjaus::iop_v3::HealthReporterImpl, // Inherit from the Service Implementation class
    public openjaus::core::Base
{
public:
    MyHealthReporterComponent();
    ~MyHealthReporterComponent() override;

    // ...

protected:
    void startService() override;
    void stopService() override;

    // ...
};
// .cpp file

void MyHealthReporterComponent::startService()
{
    Base::startService();
    HealthReporterImpl::startService();
}

void MyHealthReporterComponent::stopService()
{
    HealthReporterImpl::stopService();
    Base::stopService();
}

Delegate based implementations (Newer)

The newer and preferred service implementation style is the delegate based implementation. Not all service implementations are supported using this style (especially older implementations), however, it is anticipated that all future service implementations will follow this style.

This style of service implementation requires the derived Component class to create an instance of the service implementation and implement all the service interface methods by calling into the service implementation delegate. In addition, the derived Component class may need to call the configure, start, and/or stop methods of the service implementation to ensure that it is correctly configured, started, and/or stopped. Some service implementations may also require the Component class to register functions / callbacks to handle service specific behavior.

Delegate based service implementations end with Delegate in the class name. For example, the DigitalResourceDiscovery delegate based service implementation is named DigitalResourceDiscoveryDelegate.

Example:

// MyDigitalResourceDiscoveryComponent.h

class MyDigitalResourceDiscoveryComponent :
    public openjaus::iop_v3::DigitalResourceDiscovery, // Inherit from the base Service class
    public openjaus::core::EventsBase
{
public:
    MyDigitalResourceDiscoveryComponent();
    ~MyDigitalResourceDiscoveryComponent() override;

    // Override the service interface methods
    bool addDigitalResourceEndpoint(openjaus::iop_v3::digitalresourcediscovery::RegisterDigitalResourceEndpoint* incoming) override;
    bool removeDigitalResourceEndpoint(openjaus::iop_v3::digitalresourcediscovery::RemoveDigitalResourceEndpoint* incoming) override;


    // ...

private:
    void configureService() override;

    openjaus::iop_v3::DigitalResourceDiscoveryDelegate delegate; // Create an instance of the service implementation
};
// MyDigitalResourceDiscoveryComponent.cpp

MyDigitalResourceDiscoveryComponent::MyDigitalResourceDiscoveryComponent() :
    delegate(this) // Pass a pointer to the Transport service interface to the service implementation
{
}

bool MyDigitalResourceDiscoveryComponent::addDigitalResourceEndpoint(openjaus::iop_v3::digitalresourcediscovery::RegisterDigitalResourceEndpoint* incoming)
{
    return delegate.addDigitalResourceEndpoint(incoming);
}

bool MyDigitalResourceDiscoveryComponent::removeDigitalResourceEndpoint(openjaus::iop_v3::digitalresourcediscovery::RemoveDigitalResourceEndpoint* incoming)
{
    return delegate.removeDigitalResourceEndpoint(incoming);
}

void MyDigitalResourceDiscoveryComponent::configureService()
{
    EventsBase::configureService();

    // Add static resources to the DigitalResourceDiscovery service if necessary
    // delegate.addStaticResource();
}