@Test public void testFiltering() throws InvalidSyntaxException { Filter filter = FrameworkUtil.createFilter("(&(device.id=zwave31)(|(temp >= 30)(power <= 100)))"); assertTrue(filter.matches(new HashMap<String, Object>() { { put("device.id", "zwave31"); put("service.id", "banan"); put("temp", 31); } })); assertTrue(filter.matches(new HashMap<String, Object>() { { put("device.id", "zwave31"); put("service.id", "apple"); put("power", 99); } })); assertFalse(filter.matches(new HashMap<String, Object>() { { put("device.id", "zwave31"); put("service.id", "apple"); put("temp", 29); put("power", 101); } })); filter = FrameworkUtil.createFilter("(&(device.id=32))"); assertTrue(filter.matches(new HashMap<String, Object>() { { put("device.id", 32); put("service.id", "banan"); put("p2", "NONE"); } })); filter = FrameworkUtil.createFilter("(&(device.id=32)(p1 >= 20))"); assertTrue(filter.matches(new HashMap<String, Object>() { { put("device.id", 32); put("p1", 22); put("p2", "NONE"); } })); filter = FrameworkUtil.createFilter("(&(device.online=true)(|(CurrentPower=*)(CurrentTemperature=*)))"); assertTrue(filter.matches(new HashMap<String, Object>() { { put("device.online", true); put("CurrentPower", 22); } })); assertFalse(filter.matches(new HashMap<String, Object>() { { put("device.online", false); put("CurrentPower", 22); } })); eventManager.start(); context.assertIsSatisfied(); }
public void start() { synchronized (running) { if (!running.compareAndSet(false, true)) { throw new IllegalStateException("There is thread already running"); } thread = new Thread(this); try { thread.start(); } catch (Throwable e) { logger.warn("Failed to start Event Manager: " + e); running.set(false); thread = null; } } }
EventManager implements ServiceListener, Runnable,
        ServiceTrackerCustomizer<GenericDevice, Object> { public void start() { synchronized (running) { if (!running.compareAndSet(false, true)) { throw new IllegalStateException("There is thread already running"); } thread = new Thread(this); try { thread.start(); } catch (Throwable e) { logger.warn("Failed to start Event Manager: " + e); running.set(false); thread = null; } } } }
EventManager implements ServiceListener, Runnable,
        ServiceTrackerCustomizer<GenericDevice, Object> { public void start() { synchronized (running) { if (!running.compareAndSet(false, true)) { throw new IllegalStateException("There is thread already running"); } thread = new Thread(this); try { thread.start(); } catch (Throwable e) { logger.warn("Failed to start Event Manager: " + e); running.set(false); thread = null; } } } EventManager(); }
EventManager implements ServiceListener, Runnable,
        ServiceTrackerCustomizer<GenericDevice, Object> { public void start() { synchronized (running) { if (!running.compareAndSet(false, true)) { throw new IllegalStateException("There is thread already running"); } thread = new Thread(this); try { thread.start(); } catch (Throwable e) { logger.warn("Failed to start Event Manager: " + e); running.set(false); thread = null; } } } EventManager(); void setContext(BundleContext context); @Override void run(); @Override void serviceChanged(ServiceEvent event); void start(); void shutdown(); void addPropertyEvent(String deviceId, String serviceId, Map<String, Object> properties); void addStateEvent(String deviceId, String serviceId, String propertyId, Type type); @Override Object addingService(ServiceReference<GenericDevice> reference); @Override void modifiedService(ServiceReference<GenericDevice> reference, Object service); @Override void removedService(ServiceReference<GenericDevice> reference, Object service); }
EventManager implements ServiceListener, Runnable,
        ServiceTrackerCustomizer<GenericDevice, Object> { public void start() { synchronized (running) { if (!running.compareAndSet(false, true)) { throw new IllegalStateException("There is thread already running"); } thread = new Thread(this); try { thread.start(); } catch (Throwable e) { logger.warn("Failed to start Event Manager: " + e); running.set(false); thread = null; } } } EventManager(); void setContext(BundleContext context); @Override void run(); @Override void serviceChanged(ServiceEvent event); void start(); void shutdown(); void addPropertyEvent(String deviceId, String serviceId, Map<String, Object> properties); void addStateEvent(String deviceId, String serviceId, String propertyId, Type type); @Override Object addingService(ServiceReference<GenericDevice> reference); @Override void modifiedService(ServiceReference<GenericDevice> reference, Object service); @Override void removedService(ServiceReference<GenericDevice> reference, Object service);  }