/** * Adds SqueezeBoxServerHandlers to the discovery service to find SqueezeBox Players * * @param squeezeBoxServerHandler */ private synchronized void registerSqueezeBoxPlayerDiscoveryService( SqueezeBoxServerHandler squeezeBoxServerHandler) { SqueezeBoxPlayerDiscoveryParticipant discoveryService = new SqueezeBoxPlayerDiscoveryParticipant(squeezeBoxServerHandler); squeezeBoxServerHandler.registerSqueezeBoxPlayerListener(discoveryService); this.discoveryServiceRegs.put( squeezeBoxServerHandler.getThing().getUID(), bundleContext.registerService( DiscoveryService.class.getName(), discoveryService, new Hashtable<String, Object>())); }
@Override protected synchronized void removeHandler(ThingHandler thingHandler) { if (thingHandler instanceof SqueezeBoxServerHandler) { ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(thingHandler.getThing().getUID()); if (serviceReg != null) { serviceReg.unregister(); discoveryServiceRegs.remove(thingHandler.getThing().getUID()); } } if (thingHandler instanceof SqueezeBoxPlayerHandler) { SqueezeBoxServerHandler bridge = ((SqueezeBoxPlayerHandler) thingHandler).getSqueezeBoxServerHandler(); if (bridge != null) { bridge.removePlayerCache(((SqueezeBoxPlayerHandler) thingHandler).getMac()); } } }