static { xs = new XStream(new DomDriver()); xs.alias("pipe", FilterPipeInfo.class); xs.alias("svr", String.class); // xs.alias("dfas", (new String[0]).getClass()); // xs.alias("name", null); }
@Override protected XStream createXStream() { XStream ret = super.createXStream(); ret.alias("errors", Errors.class); ret.alias("error", Error.class); ret.addImplicitCollection(Error.Parameters.class, "parameters", "parameter", String.class); return ret; }
/** * reads the configuration file and returns a <code>FilterPipeInfo</code> object. * * @throws Exception if anything goes wrong while reading the configuration file. */ public static FilterPipeInfo read(String fName, Map servers) throws Exception { Reader r = new FileReader(fName); FilterPipeInfo pipe = (FilterPipeInfo) (xs.fromXML(r)); pipe.name = getName(fName); int l = pipe.dfas.size(); pipe.request = new PipelineRequest[l]; for (int i = 0; i < l; i++) { // System.out.println("looking up `"+ pipe.dfas.get(i)+"'"); FilterSvrInfo svr = (FilterSvrInfo) servers.get(pipe.dfas.get(i)); if (svr == null) { pipe.e = new IOException("no information for server `" + pipe.dfas.get(i) + "' available"); return pipe; } if (svr.e != null) { Exception e = new IOException( "referenced server configuration for server `" + svr.name + "' is broken"); e.initCause(svr.e); pipe.e = e; return pipe; } pipe.request[i] = svr.getRequest(); } return pipe; }
/** ******************************************************************* */ void write(Writer out) { xs.toXML(this, out); }