CRecordApplication
This is a data record for the description of an application.
This message belongs to the application factory collector API.
{ "id": "5a8d5a3f-37c0-47f5-bb88-25f5f5e6a20c", "name": "APPLICATION", "isService": "false", "namespaces": "", "description": "The application data.", "slots": [ { "key": "appId", "name": "ID", "direction": "REQUEST", "mandatory": "false", "type": "UUID", "description": "The ID of an application." }, { "key": "appName", "name": "NAME", "direction": "REQUEST", "mandatory": "false", "type": "STRING", "description": "The name of the application." }, { "key": "shortAppDesc", "name": "SHORT_DESCRIPTION", "direction": "REQUEST", "mandatory": "false", "type": "STRING", "description": "A short description." }, { "key": "longAppDesc", "name": "LONG_DESCRIPTION", "direction": "REQUEST", "mandatory": "false", "type": "STRING", "description": "A long description." }, { "key": "iconPath", "name": "ICON", "direction": "REQUEST", "mandatory": "false", "type": "STRING", "description": "The relative path of the icon file in the file store." }, { "key": "properties", "name": "PROPERTIES", "direction": "REQUEST", "mandatory": "false", "type": "STRING_PROPERTIES", "description": "Properties for running the application." }, { "key": "permissions", "name": "PERMISSIONS", "direction": "REQUEST", "mandatory": "false", "type": "STRING_ARRAY", "description": "Permissions required to start the application." } ] }
This record is used, for example, when registering application factories.
Example of use (after generating of the class CRecordApplication
):
// 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; } }