IRecordRegistryHelper
The Record Registry Helper is a service for registering nano services and record names.
In the record definition it is possible to specify
{ "id": "f2be95a8-50a5-4a42-a1f3-53eb3a02145d","name": "NOTIFY_APP_INSTANCE_STARTED" ,"isService": "true" ,"namespaces": "SYSTEM" , "description": "Whenever an application instance has been started,\nthis notification service will be triggered.\nDirection: App Instance Registry --> Public.", "slots": [ { "key": "1", "name": "INSTANCE", "direction": "REQUEST", "mandatory": "true", "type": "RECORD", "description": "The application instance record (see APP_INSTANCE)." } ] }
Additionally,
Getting the service
The service is available through the local service registry.
final IRecordRegistryHelper helper = CServiceRegistry.getInstance() .getService(IRecordRegistryHelper.class);
As always, make sure that the service starter of your package has a dependency on the helper service to ensure that the service already exists.
Register records
This method is used to register a record. The specified class is a class generated from the record definition using the RecordGenerator.
void registerRecord(@NotNull Class<? extends IGeneratedRecord> aClass) throws CException;
Deregister records
This method is used to deregister a record. The specified class is a class generated from the record definition using the RecordGenerator.
void deregisterRecord(@NotNull Class<? extends IGeneratedRecord> aClass) throws CException;
Usage
The service is mostly used in ServiceStarters to register multiple records.
public class CPackageFileCacheRecords implements IServiceStarter { @Override public void getDependencies(@NotNull final IServiceDependencyList aDependencyList) { aDependencyList.add(IRecordRegistryHelper.class); } @Override public void start(@NotNull final IServiceRegistry aServiceRegistry) throws Exception { final IRecordRegistryHelper helper = aServiceRegistry.getService(IRecordRegistryHelper.class); if (helper != null) { helper.registerRecord(CRecordFileCacheClear.class); helper.registerRecord(CRecordFileCacheGetFile.class); helper.registerRecord(CRecordFileCacheRemoveFile.class); helper.registerRecord(CRecordFileCacheStoreFile.class); helper.registerRecord(CRecordFileCacheStorePartOfFile.class); } } @Override public void stop(@NotNull final IServiceRegistry aServiceRegistry) throws Exception { final IRecordRegistryHelper helper = aServiceRegistry.getService(IRecordRegistryHelper.class); if (helper != null) { helper.deregisterRecord(CRecordFileCacheClear.class); helper.deregisterRecord(CRecordFileCacheGetFile.class); helper.deregisterRecord(CRecordFileCacheRemoveFile.class); helper.deregisterRecord(CRecordFileCacheStoreFile.class); helper.deregisterRecord(CRecordFileCacheStorePartOfFile.class); } } }