示例#1
0
  /**
   * Convenience method to get the configured value of PORT, if an OnDemand service defines one.
   *
   * @return A String object.
   */
  public int getConfiguredPort() {

    int result = 8080;

    Configuration c = getConfiguration();
    if (c != null) {

      NameValue nv = c.findNameValueByName(NMSConstants.PORT);
      if (nv != null) {

        result = Util.str2int(nv.getValue(), result);
      }
    }

    return (result);
  }
示例#2
0
  /** {@inheritDoc} */
  public int getConfiguredUpdateHour() {

    int result = 4;

    Configuration c = getConfiguration();
    if (c != null) {

      NameValue nv = c.findNameValueByName(NMSConstants.UPDATE_HOUR);
      if (nv != null) {

        result = Util.str2int(nv.getValue(), result);
      }
    }

    return (result);
  }
示例#3
0
  /** {@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);
  }