1 package org.sapia.regis.local; 2 3 import java.io.ByteArrayInputStream ; 4 import java.io.File ; 5 import java.io.FileInputStream ; 6 import java.io.InputStream ; 7 import java.rmi.RemoteException ; 8 import java.util.Properties ; 9 10 import org.sapia.regis.Configurable; 11 import org.sapia.regis.Node; 12 import org.sapia.regis.Path; 13 import org.sapia.regis.RWNode; 14 import org.sapia.regis.RegisSession; 15 import org.sapia.regis.Registry; 16 import org.sapia.regis.impl.NodeImpl; 17 import org.sapia.regis.loader.RegistryConfigLoader; 18 19 33 public class LocalRegistry implements Registry, Configurable { 34 35 private RWNode _root; 36 37 public LocalRegistry(){ 38 this(new NodeImpl(null, Node.ROOT_NAME)); 39 } 40 41 public LocalRegistry(RWNode root){ 42 _root = root; 43 } 44 45 public RegisSession open() { 46 return new LocalRegisSession(); 47 } 48 49 public Node getRoot() { 50 return _root; 51 } 52 53 public void load(File config) throws Exception { 54 load(new FileInputStream (config)); 55 } 56 57 public void load(InputStream is) throws Exception { 58 if(_root == null){ 59 _root = new NodeImpl(null, Node.ROOT_NAME); 60 } 61 RegistryConfigLoader loader = new RegistryConfigLoader(_root); 62 loader.load(is); 63 } 64 65 public void load(Path nodePath, String username, String password, String xmlConf, Properties props) throws RemoteException , Exception { 66 Node child = _root.getChild(nodePath); 67 if(child == null){ 68 throw new IllegalStateException ("No such node: " + nodePath.toString()); 69 } 70 RegistryConfigLoader loader = new RegistryConfigLoader((RWNode)child); 71 loader.load(new ByteArrayInputStream (xmlConf.getBytes())); 72 } 73 74 public void syncLoad(Path nodePath, String username, String password, String xmlConf, Properties props) throws RemoteException , Exception { 75 } 76 77 public void close() { 78 } 79 80 } 81 | Popular Tags |