Search in sources :

Example 1 with EdgeDeviceAutoProvisioner

use of org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner in project hono by eclipse.

the class AmqpServerFactory method registrationService.

/**
 * Creates a Device Registration service instance.
 * <p>
 * This factory method makes sure that each set of event senders
 * is used by a single dedicated service instance only. This is necessary because during start up,
 * the service will implicitly invoke {@link MessagingClientProvider#start()} in order
 * to establish the senders' connection to the messaging infrastructure. For the AMQP 1.0 based senders,
 * this connection needs to be established on the verticle's event loop thread in order to work properly.
 *
 * @return The MongoDB registration service.
 */
private RegistrationService registrationService() {
    final EdgeDeviceAutoProvisioner edgeDeviceAutoProvisioner = new EdgeDeviceAutoProvisioner(vertx, deviceManagementService, eventSenderProvider(), autoProvisionerConfigProperties, tracer);
    final var service = new MongoDbBasedRegistrationService(deviceDao);
    service.setEdgeDeviceAutoProvisioner(edgeDeviceAutoProvisioner);
    service.setTenantInformationService(tenantInformationService);
    return service;
}
Also used : EdgeDeviceAutoProvisioner(org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner) MongoDbBasedRegistrationService(org.eclipse.hono.deviceregistry.mongodb.service.MongoDbBasedRegistrationService)

Example 2 with EdgeDeviceAutoProvisioner

use of org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner in project hono by eclipse.

the class AmqpServerFactory method registrationService.

/**
 * Creates a Device Registration service instance.
 * <p>
 * This factory method makes sure that each set of event senders
 * is used by a single dedicated service instance only. This is necessary because during start up,
 * the service will implicitly invoke {@link MessagingClientProvider#start()} in order
 * to establish the senders' connection to the messaging infrastructure. For the AMQP 1.0 based senders,
 * this connection needs to be established on the verticle's event loop thread in order to work properly.
 *
 * @return The MongoDB registration service.
 */
private RegistrationService registrationService() {
    final EdgeDeviceAutoProvisioner edgeDeviceAutoProvisioner = new EdgeDeviceAutoProvisioner(vertx, deviceManagementService, eventSenderProvider(), autoProvisionerConfigProperties, tracer);
    final var service = new RegistrationServiceImpl(devicesAdapterStore, schemaCreator);
    service.setEdgeDeviceAutoProvisioner(edgeDeviceAutoProvisioner);
    service.setTenantInformationService(tenantInformationService);
    return service;
}
Also used : RegistrationServiceImpl(org.eclipse.hono.deviceregistry.jdbc.impl.RegistrationServiceImpl) EdgeDeviceAutoProvisioner(org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner)

Example 3 with EdgeDeviceAutoProvisioner

use of org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner in project hono by eclipse.

the class MongoDbBasedRegistrationServiceTest method startService.

/**
 * Starts up the service.
 *
 * @param testContext The test context to use for running asynchronous tests.
 */
@BeforeAll
public void startService(final VertxTestContext testContext) {
    vertx = Vertx.vertx();
    deviceDao = MongoDbTestUtils.getDeviceDao(vertx, DB_NAME);
    credentialsDao = MongoDbTestUtils.getCredentialsDao(vertx, DB_NAME);
    deviceManagementService = new MongoDbBasedDeviceManagementService(vertx, deviceDao, credentialsDao, config);
    final EdgeDeviceAutoProvisioner edgeDeviceAutoProvisioner = new EdgeDeviceAutoProvisioner(vertx, deviceManagementService, mockEventSenders(), new AutoProvisionerConfigProperties(), NoopTracerFactory.create());
    registrationService = new MongoDbBasedRegistrationService(deviceDao);
    registrationService.setEdgeDeviceAutoProvisioner(edgeDeviceAutoProvisioner);
    CompositeFuture.all(deviceDao.createIndices(), credentialsDao.createIndices()).onComplete(testContext.succeedingThenComplete());
}
Also used : EdgeDeviceAutoProvisioner(org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner) AutoProvisionerConfigProperties(org.eclipse.hono.deviceregistry.service.device.AutoProvisionerConfigProperties) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with EdgeDeviceAutoProvisioner

use of org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner in project hono by eclipse.

the class ApplicationConfig method amqpServer.

/**
 * Creates a new server for exposing the device registry's AMQP 1.0 based
 * endpoints.
 *
 * @param tenantService The tenant service instance.
 * @param registrationService The device registration service instance.
 * @param credentialsService The credentials service instance.
 * @param tenantManagementService The tenant management service instance.
 * @param deviceManagementService The device management service instance.
 * @param credentialsManagementService The credentials management service instance.
 * @return The server.
 */
@Bean(name = BEAN_NAME_AMQP_SERVER)
@Scope("prototype")
@Profile(Profiles.PROFILE_REGISTRY_ADAPTER)
public DeviceRegistryAmqpServer amqpServer(@Autowired(required = false) final TenantService tenantService, final RegistrationServiceImpl registrationService, final CredentialsServiceImpl credentialsService, @Autowired(required = false) final TenantManagementService tenantManagementService, @Autowired(required = false) final DeviceManagementService deviceManagementService, @Autowired(required = false) final CredentialsManagementService credentialsManagementService) {
    final DeviceRegistryAmqpServer amqpServer = new DeviceRegistryAmqpServer();
    final TenantInformationService tenantInformationService = createAndApplyTenantInformationService(tenantManagementService, deviceManagementService, credentialsManagementService);
    if (deviceManagementService != null) {
        final var eventSenderProvider = eventSenderProvider();
        final EdgeDeviceAutoProvisioner edgeDeviceAutoProvisioner = new EdgeDeviceAutoProvisioner(vertx(), deviceManagementService, eventSenderProvider, autoProvisionerConfigProperties(), tracer());
        registrationService.setEdgeDeviceAutoProvisioner(edgeDeviceAutoProvisioner);
        if (credentialsManagementService != null) {
            final DeviceAndGatewayAutoProvisioner deviceAndGatewayAutoProvisioner = new DeviceAndGatewayAutoProvisioner(vertx(), deviceManagementService, credentialsManagementService, eventSenderProvider);
            credentialsService.setDeviceAndGatewayAutoProvisioner(deviceAndGatewayAutoProvisioner);
        }
    }
    registrationService.setTenantInformationService(tenantInformationService);
    credentialsService.setTenantInformationService(tenantInformationService);
    // add endpoints
    final List<AbstractAmqpEndpoint<ServiceConfigProperties>> endpoints = new ArrayList<>();
    Optional.ofNullable(tenantService).ifPresent(svc -> endpoints.add(new DelegatingTenantAmqpEndpoint<>(vertx(), svc)));
    endpoints.add(new DelegatingRegistrationAmqpEndpoint<>(vertx(), registrationService));
    endpoints.add(new DelegatingCredentialsAmqpEndpoint<>(vertx(), credentialsService));
    endpoints.forEach(ep -> {
        ep.setTracer(tracer());
        ep.setConfiguration(amqpServerProperties());
        amqpServer.addEndpoint(ep);
    });
    return amqpServer;
}
Also used : EdgeDeviceAutoProvisioner(org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner) DelegatingTenantAmqpEndpoint(org.eclipse.hono.service.tenant.DelegatingTenantAmqpEndpoint) AbstractAmqpEndpoint(org.eclipse.hono.service.amqp.AbstractAmqpEndpoint) DeviceAndGatewayAutoProvisioner(org.eclipse.hono.service.management.device.DeviceAndGatewayAutoProvisioner) ArrayList(java.util.ArrayList) DeviceRegistryAmqpServer(org.eclipse.hono.deviceregistry.server.DeviceRegistryAmqpServer) NoopTenantInformationService(org.eclipse.hono.deviceregistry.service.tenant.NoopTenantInformationService) TenantInformationService(org.eclipse.hono.deviceregistry.service.tenant.TenantInformationService) DefaultTenantInformationService(org.eclipse.hono.deviceregistry.service.tenant.DefaultTenantInformationService) Scope(org.springframework.context.annotation.Scope) Profile(org.springframework.context.annotation.Profile) ObjectFactoryCreatingFactoryBean(org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

EdgeDeviceAutoProvisioner (org.eclipse.hono.deviceregistry.service.device.EdgeDeviceAutoProvisioner)4 ArrayList (java.util.ArrayList)1 RegistrationServiceImpl (org.eclipse.hono.deviceregistry.jdbc.impl.RegistrationServiceImpl)1 MongoDbBasedRegistrationService (org.eclipse.hono.deviceregistry.mongodb.service.MongoDbBasedRegistrationService)1 DeviceRegistryAmqpServer (org.eclipse.hono.deviceregistry.server.DeviceRegistryAmqpServer)1 AutoProvisionerConfigProperties (org.eclipse.hono.deviceregistry.service.device.AutoProvisionerConfigProperties)1 DefaultTenantInformationService (org.eclipse.hono.deviceregistry.service.tenant.DefaultTenantInformationService)1 NoopTenantInformationService (org.eclipse.hono.deviceregistry.service.tenant.NoopTenantInformationService)1 TenantInformationService (org.eclipse.hono.deviceregistry.service.tenant.TenantInformationService)1 AbstractAmqpEndpoint (org.eclipse.hono.service.amqp.AbstractAmqpEndpoint)1 DeviceAndGatewayAutoProvisioner (org.eclipse.hono.service.management.device.DeviceAndGatewayAutoProvisioner)1 DelegatingTenantAmqpEndpoint (org.eclipse.hono.service.tenant.DelegatingTenantAmqpEndpoint)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 ObjectFactoryCreatingFactoryBean (org.springframework.beans.factory.config.ObjectFactoryCreatingFactoryBean)1 Bean (org.springframework.context.annotation.Bean)1 Profile (org.springframework.context.annotation.Profile)1 Scope (org.springframework.context.annotation.Scope)1