use of org.openremote.container.persistence.PersistenceService in project openremote by openremote.
the class RulesService method init.
@Override
public void init(Container container) throws Exception {
executorService = container.getExecutorService();
timerService = container.getService(TimerService.class);
persistenceService = container.getService(PersistenceService.class);
rulesetStorageService = container.getService(RulesetStorageService.class);
identityService = container.getService(ManagerIdentityService.class);
notificationService = container.getService(NotificationService.class);
assetStorageService = container.getService(AssetStorageService.class);
assetProcessingService = container.getService(AssetProcessingService.class);
assetDatapointService = container.getService(AssetDatapointService.class);
assetPredictedDatapointService = container.getService(AssetPredictedDatapointService.class);
clientEventService = container.getService(ClientEventService.class);
gatewayService = container.getService(GatewayService.class);
if (initDone) {
return;
}
clientEventService.addSubscriptionAuthorizer((realm, auth, subscription) -> {
if (subscription.isEventType(RulesEngineStatusEvent.class) || subscription.isEventType(RulesetChangedEvent.class)) {
if (auth == null) {
return false;
}
if (auth.isSuperUser()) {
return true;
}
// Regular user must have role
if (!auth.hasResourceRole(ClientRole.READ_ASSETS.getValue(), auth.getClientId())) {
return false;
}
boolean isRestrictedUser = identityService.getIdentityProvider().isRestrictedUser(auth);
return !isRestrictedUser;
}
return false;
});
ServiceLoader.load(GeofenceAssetAdapter.class).forEach(geofenceAssetAdapter -> {
LOG.fine("Adding GeofenceAssetAdapter: " + geofenceAssetAdapter.getClass().getName());
geofenceAssetAdapters.add(geofenceAssetAdapter);
});
geofenceAssetAdapters.addAll(container.getServices(GeofenceAssetAdapter.class));
geofenceAssetAdapters.sort(Comparator.comparingInt(GeofenceAssetAdapter::getPriority));
container.getService(MessageBrokerService.class).getContext().addRoutes(this);
configEventExpires = getString(container.getConfig(), RULE_EVENT_EXPIRES, RULE_EVENT_EXPIRES_DEFAULT);
container.getService(ManagerWebService.class).addApiSingleton(new FlowResourceImpl(container.getService(TimerService.class), container.getService(ManagerIdentityService.class)));
initDone = true;
}
Aggregations