CRecordAddAppFactory
The message
This message belongs to the application factory collector API.
The Application Collector Service is located in the plugin NY_ApplicationFactoryCollectorPlugIn.
{ "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." } ] }
Arguments
APPLICATION : The description of the application. See CRecordApplication.FACTORY_ADDRESS : The target address of the factory.
Usage
Sending the message
Example of use (after generating of the class
// create an application description @NotNull private CRecord createApplicationRecord() throws CException { final CRecord record = CRecordApplication.create();// every application has an UUID as ID 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 thenyssr .net ");// an image in the file store CRecordApplication.setIcon(record, "apps/Monitor/monitor.png");// no special permission required CRecordApplication.setPermissions(record, new String[]{}); return record; }// register your app private void registerApplicationFactory() throws CException {// The message is sent to the AppCollector microservice. 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 booleanasyncAddAppFactory (@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { if (aEnvelope.getResultCode() != CResultCode.SUCCESS) {// ... } return true; } else { return false; } }