Search in sources :

Example 1 with Endpoint

use of de.fraunhofer.iosb.ilt.faaast.service.endpoint.Endpoint in project FAAAST-Service by FraunhoferIOSB.

the class Service method init.

private void init() throws ConfigurationException {
    if (config.getPersistence() == null) {
        throw new InvalidConfigurationException("config.persistence must be non-null");
    }
    persistence = (Persistence) config.getPersistence().newInstance(config.getCore(), this);
    if (config.getMessageBus() == null) {
        throw new InvalidConfigurationException("config.messagebus must be non-null");
    }
    messageBus = (MessageBus) config.getMessageBus().newInstance(config.getCore(), this);
    if (config.getAssetConnections() != null) {
        List<AssetConnection> assetConnections = new ArrayList<>();
        for (AssetConnectionConfig assetConnectionConfig : config.getAssetConnections()) {
            assetConnections.add((AssetConnection) assetConnectionConfig.newInstance(config.getCore(), this));
        }
        assetConnectionManager = new AssetConnectionManager(config.getCore(), assetConnections, this);
    }
    if (config.getEndpoints() == null || config.getEndpoints().isEmpty()) {
        // TODO maybe be less restrictive and only print warning
        // throw new InvalidConfigurationException("at least endpoint must be defined in the configuration");
        logger.warn("no endpoint configuration found, starting service without endpoint which means the service will not be accessible via any kind of API");
    } else {
        endpoints = new ArrayList<>();
        for (EndpointConfig endpointConfig : config.getEndpoints()) {
            Endpoint endpoint = (Endpoint) endpointConfig.newInstance(config.getCore(), this);
            endpoints.add(endpoint);
        }
    }
    this.requestHandler = new RequestHandlerManager(this.config.getCore(), this.persistence, this.messageBus, this.assetConnectionManager);
}
Also used : AssetConnectionManager(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionManager) Endpoint(de.fraunhofer.iosb.ilt.faaast.service.endpoint.Endpoint) RequestHandlerManager(de.fraunhofer.iosb.ilt.faaast.service.request.RequestHandlerManager) ArrayList(java.util.ArrayList) AssetConnectionConfig(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionConfig) EndpointConfig(de.fraunhofer.iosb.ilt.faaast.service.endpoint.EndpointConfig) InvalidConfigurationException(de.fraunhofer.iosb.ilt.faaast.service.exception.InvalidConfigurationException) AssetConnection(de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnection)

Example 2 with Endpoint

use of de.fraunhofer.iosb.ilt.faaast.service.endpoint.Endpoint in project FAAAST-Service by FraunhoferIOSB.

the class Service method start.

/**
 * Starts the service. This includes starting the message bus and endpoints.
 *
 * @throws IllegalArgumentException if AAS environment is null/has not been
 *             properly initialized
 * @throws Exception when starting failed
 */
public void start() throws Exception {
    logger.info("Get command for starting FA³ST Service");
    if (this.aasEnvironment == null) {
        logger.error("AssetAdministrationEnvironment must be non-null");
        throw new IllegalArgumentException("AssetAdministrationEnvironment must be non-null");
    }
    persistence.setEnvironment(this.aasEnvironment);
    messageBus.start();
    for (Endpoint endpoint : endpoints) {
        logger.info("Starting endpoint {}", endpoint.getClass().getSimpleName());
        endpoint.start();
    }
    logger.info("FA³ST Service is running!");
}
Also used : Endpoint(de.fraunhofer.iosb.ilt.faaast.service.endpoint.Endpoint)

Aggregations

Endpoint (de.fraunhofer.iosb.ilt.faaast.service.endpoint.Endpoint)2 AssetConnection (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnection)1 AssetConnectionConfig (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionConfig)1 AssetConnectionManager (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionManager)1 EndpointConfig (de.fraunhofer.iosb.ilt.faaast.service.endpoint.EndpointConfig)1 InvalidConfigurationException (de.fraunhofer.iosb.ilt.faaast.service.exception.InvalidConfigurationException)1 RequestHandlerManager (de.fraunhofer.iosb.ilt.faaast.service.request.RequestHandlerManager)1 ArrayList (java.util.ArrayList)1