Exemplo n.º 1
0
  public void write(OutputStream out) throws IOException {
    Properties props = new Properties();

    Configurer c = new Configurer(this, props);
    c.addInline(Tunnel.class);
    c.deconfigure();

    props.store(out, null);
  }
Exemplo n.º 2
0
  public void read(InputStream in) throws IOException {
    Properties props = new Properties();
    props.load(in);
    Configurer c = new Configurer(this, props);
    TypeCoercer.addCoercion(
        String.class,
        Tunnel.class,
        new TypeCoercer.TypeCoercion<String, Tunnel>() {

          public Tunnel coerce(String k) {
            Tunnel t = new Tunnel();

            String[] s = k.split(":");
            t.setLocalPort(Integer.parseInt(s[0]));
            t.setHostName(s[1]);
            t.setRemotePort(Integer.parseInt(s[2]));

            return t;
          }
        });
    c.configure();
  }