/** {@inheritDoc} */ public void stop(BundleContext context) { ServiceTracker t = getServiceTracker(); if (t != null) { t.close(); } RCTracker rct = getRCTracker(); if (rct != null) { rct.close(); } ImageCacheTracker ict = getImageCacheTracker(); if (ict != null) { ict.close(); } }
/** {@inheritDoc} */ public void start(BundleContext bc) { setBundleContext(bc); VideoScreen s = new VideoScreen(); // Check for a properties file for video categories... File conf = new File("conf"); if ((conf.exists()) && (conf.isDirectory())) { File props = new File(conf, "videoscreen.properties"); if ((props.exists()) && (props.isFile())) { Properties p = Util.findProperties(props); if (p != null) { int count = Util.str2int(p.getProperty("categoryCount"), 0); if (count > 0) { ArrayList<String> l = new ArrayList<String>(); for (int i = 0; i < count; i++) { String tmp = p.getProperty("category" + i); if (tmp != null) { l.add(tmp); } } if (l.size() > 0) { String[] array = l.toArray(new String[l.size()]); s.setParameters(array); } } } } } // Now we listen for command events. String[] topics = new String[] {"org/jflicks/rc/COMMAND"}; Hashtable<String, String[]> h = new Hashtable<String, String[]>(); h.put(EventConstants.EVENT_TOPIC, topics); bc.registerService(EventHandler.class.getName(), s, h); RCTracker rct = new RCTracker(bc, s); setRCTracker(rct); rct.open(); ImageCacheTracker ict = new ImageCacheTracker(bc, s); setImageCacheTracker(ict); ict.open(); try { Filter filter = bc.createFilter("(Player-Handle=" + Player.PLAYER_VIDEO + ")"); ServiceTracker st = new ServiceTracker(bc, filter, null); setServiceTracker(st); st.open(); s.setPlayerServiceTracker(st); } catch (InvalidSyntaxException ex) { } Hashtable<String, String> dict = new Hashtable<String, String>(); dict.put(Screen.TITLE_PROPERTY, s.getTitle()); bc.registerService(Screen.class.getName(), s, dict); }