Search in sources :

Example 6 with TimerService

use of org.openremote.container.timer.TimerService in project openremote by openremote.

the class MqttBrokerService method init.

@Override
public void init(Container container) throws Exception {
    host = getString(container.getConfig(), MQTT_SERVER_LISTEN_HOST, BrokerConstants.HOST);
    port = getInteger(container.getConfig(), MQTT_SERVER_LISTEN_PORT, BrokerConstants.PORT);
    clientEventService = container.getService(ClientEventService.class);
    ManagerIdentityService identityService = container.getService(ManagerIdentityService.class);
    messageBrokerService = container.getService(MessageBrokerService.class);
    executorService = container.getExecutorService();
    timerService = container.getService(TimerService.class);
    if (!identityService.isKeycloakEnabled()) {
        LOG.warning("MQTT connections are not supported when not using Keycloak identity provider");
        active = false;
    } else {
        active = true;
        identityProvider = (ManagerKeycloakIdentityProvider) identityService.getIdentityProvider();
        container.getService(MessageBrokerService.class).getContext().addRoutes(this);
    }
}
Also used : ManagerIdentityService(org.openremote.manager.security.ManagerIdentityService) ClientEventService(org.openremote.manager.event.ClientEventService) MessageBrokerService(org.openremote.container.message.MessageBrokerService) TimerService(org.openremote.container.timer.TimerService)

Example 7 with TimerService

use of org.openremote.container.timer.TimerService in project openremote by openremote.

the class ProvisioningService method init.

@Override
public void init(Container container) throws Exception {
    persistenceService = container.getService(PersistenceService.class);
    identityService = container.getService(ManagerIdentityService.class);
    TimerService timerService = container.getService(TimerService.class);
    container.getService(ManagerWebService.class).addApiSingleton(new ProvisioningResourceImpl(this, timerService, identityService));
}
Also used : PersistenceService(org.openremote.container.persistence.PersistenceService) ManagerIdentityService(org.openremote.manager.security.ManagerIdentityService) ManagerWebService(org.openremote.manager.web.ManagerWebService) TimerService(org.openremote.container.timer.TimerService)

Example 8 with TimerService

use of org.openremote.container.timer.TimerService in project openremote by openremote.

the class UserAssetProvisioningMQTTHandler method start.

@Override
public void start(Container container) throws Exception {
    super.start(container);
    provisioningService = container.getService(ProvisioningService.class);
    timerService = container.getService(TimerService.class);
    brokerService = container.getService(MqttBrokerService.class);
    assetStorageService = container.getService(AssetStorageService.class);
    ManagerIdentityService identityService = container.getService(ManagerIdentityService.class);
    if (!identityService.isKeycloakEnabled()) {
        LOG.warning("MQTT connections are not supported when not using Keycloak identity provider");
        isKeycloak = false;
    } else {
        isKeycloak = true;
        identityProvider = (ManagerKeycloakIdentityProvider) identityService.getIdentityProvider();
        container.getService(MessageBrokerService.class).getContext().addRoutes(new ProvisioningPersistenceRouteBuilder(this));
    }
}
Also used : ManagerIdentityService(org.openremote.manager.security.ManagerIdentityService) AssetStorageService(org.openremote.manager.asset.AssetStorageService) TimerService(org.openremote.container.timer.TimerService) MqttBrokerService(org.openremote.manager.mqtt.MqttBrokerService)

Example 9 with TimerService

use of org.openremote.container.timer.TimerService 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;
}
Also used : AssetStorageService(org.openremote.manager.asset.AssetStorageService) AssetPredictedDatapointService(org.openremote.manager.datapoint.AssetPredictedDatapointService) AssetProcessingService(org.openremote.manager.asset.AssetProcessingService) GeofenceAssetAdapter(org.openremote.manager.rules.geofence.GeofenceAssetAdapter) NotificationService(org.openremote.manager.notification.NotificationService) TimerService(org.openremote.container.timer.TimerService) GatewayService(org.openremote.manager.gateway.GatewayService) PersistenceService(org.openremote.container.persistence.PersistenceService) ManagerIdentityService(org.openremote.manager.security.ManagerIdentityService) AssetDatapointService(org.openremote.manager.datapoint.AssetDatapointService) ManagerWebService(org.openremote.manager.web.ManagerWebService) ClientEventService(org.openremote.manager.event.ClientEventService) FlowResourceImpl(org.openremote.manager.rules.flow.FlowResourceImpl)

Aggregations

TimerService (org.openremote.container.timer.TimerService)9 ManagerIdentityService (org.openremote.manager.security.ManagerIdentityService)8 MessageBrokerService (org.openremote.container.message.MessageBrokerService)5 ClientEventService (org.openremote.manager.event.ClientEventService)5 ManagerWebService (org.openremote.manager.web.ManagerWebService)5 PersistenceService (org.openremote.container.persistence.PersistenceService)4 AssetStorageService (org.openremote.manager.asset.AssetStorageService)3 AssetDatapointService (org.openremote.manager.datapoint.AssetDatapointService)3 GatewayService (org.openremote.manager.gateway.GatewayService)3 Logger (java.util.logging.Logger)2 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 AgentService (org.openremote.manager.agent.AgentService)2 MqttBrokerService (org.openremote.manager.mqtt.MqttBrokerService)2 RulesService (org.openremote.manager.rules.RulesService)2 Container (org.openremote.model.Container)2 AttributeEvent (org.openremote.model.attribute.AttributeEvent)2 java.util (java.util)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1