Search in sources :

Example 1 with ParserService

use of org.openmuc.framework.parser.spi.ParserService in project OpenMUC by isc-konstanz.

the class AmqpDriver method getNewParserImplementationFromServiceRegistry.

private void getNewParserImplementationFromServiceRegistry(ServiceEvent event) {
    ServiceReference<?> serviceReference = event.getServiceReference();
    ParserService parser = (ParserService) context.getService(serviceReference);
    String parserId = (String) serviceReference.getProperty("parserID");
    if (event.getType() == ServiceEvent.UNREGISTERING) {
        logger.info("{} unregistering, removing Parser from AmqpDriver", parser.getClass().getName());
        connection.setParser(parserId, null);
    } else {
        logger.info("{} changed, updating Parser in AmqpDriver", parser.getClass().getName());
        connection.setParser(parserId, parser);
    }
}
Also used : ParserService(org.openmuc.framework.parser.spi.ParserService)

Example 2 with ParserService

use of org.openmuc.framework.parser.spi.ParserService in project OpenMUC by isc-konstanz.

the class AmqpDriver method checkForExistingParserService.

private void checkForExistingParserService() {
    List<ServiceReference<?>> serviceReferences = getServiceReferences();
    for (ServiceReference<?> serviceReference : serviceReferences) {
        String parserIdInit = (String) serviceReference.getProperty("parserID");
        ParserService parserInit = (ParserService) context.getService(serviceReference);
        if (parserInit != null) {
            logger.info("{} registered, updating Parser in AmqpDriver", parserInit.getClass().getName());
            connection.setParser(parserIdInit, parserInit);
        }
    }
}
Also used : ServiceReference(org.osgi.framework.ServiceReference) ParserService(org.openmuc.framework.parser.spi.ParserService)

Example 3 with ParserService

use of org.openmuc.framework.parser.spi.ParserService in project OpenMUC by isc-konstanz.

the class AmqpComponent method handleServiceRegistrationEvent.

private void handleServiceRegistrationEvent(Object event, BundleContext context) {
    ServiceReference<?> serviceReference = ((ServiceEvent) event).getServiceReference();
    String parserId = (String) serviceReference.getProperty("parserID");
    ParserService parserService = (ParserService) context.getService(serviceReference);
    String parserServiceName = parserService.getClass().getName();
    if (((ServiceEvent) event).getType() == ServiceEvent.UNREGISTERING) {
        logger.info("{} unregistering, removing Parser", parserServiceName);
        amqpLogger.removeParser(parserId);
    } else {
        logger.info("{} changed, updating Parser", parserServiceName);
        amqpLogger.addParser(parserId, parserService);
    }
}
Also used : ServiceEvent(org.osgi.framework.ServiceEvent) ParserService(org.openmuc.framework.parser.spi.ParserService)

Example 4 with ParserService

use of org.openmuc.framework.parser.spi.ParserService in project OpenMUC by isc-konstanz.

the class MqttLoggerComponent method handleServiceRegistrationEvent.

private void handleServiceRegistrationEvent(Object event, BundleContext context) {
    ServiceReference<?> serviceReference = ((ServiceEvent) event).getServiceReference();
    String parserId = (String) serviceReference.getProperty("parserID");
    ParserService parserService = (ParserService) context.getService(serviceReference);
    String parserServiceName = parserService.getClass().getName();
    if (((ServiceEvent) event).getType() == ServiceEvent.UNREGISTERING) {
        logger.info("{} unregistering, removing Parser", parserServiceName);
        mqttLogger.removeParser(parserId);
    } else {
        logger.info("{} changed, updating Parser", parserServiceName);
        mqttLogger.addParser(parserId, parserService);
    }
}
Also used : ServiceEvent(org.osgi.framework.ServiceEvent) ParserService(org.openmuc.framework.parser.spi.ParserService)

Example 5 with ParserService

use of org.openmuc.framework.parser.spi.ParserService in project OpenMUC by isc-konstanz.

the class MqttDriver method checkForExistingParserService.

private void checkForExistingParserService() {
    List<ServiceReference<?>> serviceReferences = getServiceReferences();
    for (ServiceReference<?> serviceReference : serviceReferences) {
        String parserIdInit = (String) serviceReference.getProperty("parserID");
        ParserService parserInit = (ParserService) context.getService(serviceReference);
        if (parserInit != null) {
            logger.info("{} registered, updating Parser in MqttDriver", parserInit.getClass().getName());
            connection.setParser(parserIdInit, parserInit);
        }
    }
}
Also used : ServiceReference(org.osgi.framework.ServiceReference) ParserService(org.openmuc.framework.parser.spi.ParserService)

Aggregations

ParserService (org.openmuc.framework.parser.spi.ParserService)6 ServiceEvent (org.osgi.framework.ServiceEvent)2 ServiceReference (org.osgi.framework.ServiceReference)2