1 package org.sapia.regis.prevayler; 2 3 import java.io.ByteArrayInputStream ; 4 import java.util.Date ; 5 import java.util.Properties ; 6 7 import org.prevayler.Transaction; 8 import org.sapia.regis.Node; 9 import org.sapia.regis.Path; 10 import org.sapia.regis.RWNode; 11 import org.sapia.regis.loader.RegistryConfigLoader; 12 13 public class TxLoad implements Transaction{ 14 15 static final long serialVersionUID = 1L; 16 private Path path; 17 private String xmlConf; 18 private Properties props; 19 20 public TxLoad(Path path, String xmlConf, Properties props){ 21 if(path == null){ 22 this.path = Path.parse(Node.ROOT_NAME); 23 } 24 else{ 25 this.path = path; 26 } 27 this.xmlConf = xmlConf; 28 this.props = props; 29 } 30 31 public void executeOn(Object arg0, Date arg1){ 32 Node root = (Node)arg0; 33 RegistryConfigLoader loader = new RegistryConfigLoader((RWNode)root.getChild(path)); 34 try{ 35 if(props == null) 36 loader.load(new ByteArrayInputStream (this.xmlConf.getBytes())); 37 else 38 loader.load(new ByteArrayInputStream (this.xmlConf.getBytes()), props); 39 }catch(Exception e){ 40 throw new RuntimeException ("Could not load configuration", e); 41 } 42 } 43 44 } 45 | Popular Tags |