CRecordAddAppFactory

Register an application factory.

This message belongs to the application factory collector API.

{
  "id": "ee3af3ad-16e4-45c7-af8b-8c11e93f18c7",
  "name": "ADD_APP_FACTORY",
  "isService": "false",
  "namespaces": "",
  "description": "Add an application factory.",
  "slots": [
    {
      "key": "app",
      "name": "APPLICATION",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "RECORD",
      "description": "The application as record APPLICATION."
    },
    {
      "key": "factoryAddress",
      "name": "FACTORY_ADDRESS",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "TARGET_ADDRESS",
      "description": "The address of the application factory."
    }
  ]
}

Example of use (after generating of the class CRecordAddAppFactory):

// create an application description
@NotNull
private CRecord createApplicationRecord() throws CException
{
    final CRecord record = CRecordApplication.create();
    CRecordApplication.setId(record,
                             UUID.fromString("186687b0-e99b-4479-be94-d69051c9542f"));
    CRecordApplication.setName(record,
                               "Monitor");
    CRecordApplication.setShortDescription(record,
                                           "A monitor to hold monitoring panels");
    CRecordApplication.setLongDescription(record,
                                          "An application for monitoring states of the nyssr.net");
    CRecordApplication.setIcon(record,
                               "apps/Monitor/monitor.png");
    CRecordApplication.setPermissions(record,
                                      new String[]{});

    return record;
}

// register your app
private void registerApplicationFactory() throws CException
{
    final IId microserviceId = CIdFactory.fromObject("NY_ApplicationFactoryCollector");
    final CEnvelope env = CEnvelope.forMicroService(microserviceId);

    final CRecord record = CRecordAddAppFactory.create();
    CRecordAddAppFactory.setApplication(record,
                                        createApplicationRecord());
    CRecordAddAppFactory.setFactoryAddress(record,
                                           getAddress());

    sendRequest(env,
                record);
}

You can check the result of the registration in a separate message handler for the response:

// in the constructor of your target:
addMessageHandler(CRecordAddAppFactory.ID,
                  this::asyncAddAppFactory);
// handle the answer
private boolean asyncAddAppFactory(@NotNull final CEnvelope aEnvelope,
                                   @NotNull final CRecord aRecord)
{
    if (aEnvelope.isAnswer())
    {
        if (aEnvelope.getResultCode() != CResultCode.SUCCESS)
        {
            // ...
        }
        return true;
    }
    else
    {
        return false;
    }
}

nyssr.net - Innovative Distributed System