Package com.dbxml.util

Examples of com.dbxml.util.Configuration


   }

   public void load() throws IOException {
      try {
         Document doc = DOMHelper.parse(file);
         config = new Configuration(doc);
         driversCfg = config.getChild(DRIVERS);
         filesystemsCfg = config.getChild(FILESYSTEMS);
         uiCfg = config.getChild(UI);
      }
      catch ( SAXException e ) {
View Full Code Here


      bos.close();
   }

   public Map getNamespaceMap() {
      if ( nsMap == null ) {
         Configuration nsCfg = config.getChild(NAMESPACES, true);
         nsMap = new TreeMap();
         nsCfg.processChildren(NAMESPACE, new ConfigurationCallback() {
            public void process(Configuration cfg) {
               String prefix = cfg.getAttribute(PREFIX);
               String uri = cfg.getAttribute(URI);
               nsMap.put(prefix, uri);
            }
View Full Code Here

   }

   public void setNamespaceMap(Map nsMap) {
      this.nsMap = nsMap;

      Configuration nsCfg = config.getChild(NAMESPACES, true);

      Configuration[] children = nsCfg.getChildren();
      for ( int i = 0 ; i < children.length; i++ )
         children[i].delete();

      Iterator iter = nsMap.entrySet().iterator();
      while ( iter.hasNext() ) {
         Map.Entry entry = (Map.Entry)iter.next();
         String prefix = (String)entry.getKey();
         String uri = (String)entry.getValue();
         Configuration c = nsCfg.add(NAMESPACE);
         c.setAttribute(PREFIX, prefix);
         c.setAttribute(URI, uri);
      }
   }
View Full Code Here

            String className = cfg.getAttribute(CLASS);
            driverConfig.setLabel(lbl);
            driverConfig.setClassName(className);

            final Map propsMap = driverConfig.getProperties();
            Configuration propsCfg = cfg.getChild(PROPERTIES);
            if ( propsCfg != null ) {
               propsCfg.processChildren(PROPERTY, new ConfigurationCallback() {
                  public void process(Configuration pcfg) {
                     propsMap.put(pcfg.getAttribute(NAME), pcfg.getAttribute(VALUE));
                  }
               });
            }
View Full Code Here

            if ( lbl.equals(label) )
               cfg.delete();
         }
      });

      Configuration driverCfg = driversCfg.add(DRIVER);
      driverCfg.setAttribute(LABEL, driverConfig.getLabel());
      driverCfg.setAttribute(CLASS, driverConfig.getClassName());
      Configuration propsCfg = driverCfg.getChild(PROPERTIES, true);
      Map propsMap = driverConfig.getProperties();
      Iterator iter = propsMap.entrySet().iterator();
      while ( iter.hasNext() ) {
         Map.Entry entry = (Map.Entry)iter.next();
         String name = (String)entry.getKey();
         String value = (String)entry.getValue();
         Configuration propCfg = propsCfg.add(PROPERTY);
         propCfg.setAttribute(NAME, name);
         propCfg.setAttribute(VALUE, value);
      }
   }
View Full Code Here

            if ( lbl.equals(label) )
               cfg.delete();
         }
      });

      Configuration filesystemCfg = filesystemsCfg.add(FILESYSTEM);
      filesystemCfg.setAttribute(LABEL, filesystemConfig.getLabel());
      filesystemCfg.setAttribute(DIRECTORY, filesystemConfig.getDirectory());
   }
View Full Code Here

   }

   public Configuration getConfig() {
      Document doc = DOMHelper.newDocument();
      doc.appendChild(doc.createElement(CONFIG));
      Configuration config = new Configuration(doc);

      if ( dbName != null )
         config.setAttribute(NAME, dbName);
      else
         config.setAttribute(NAME, "db");

      if ( dbRoot != null )
         config.setAttribute(DBROOT, dbRoot.getPath());
      else
         config.setAttribute(DBROOT, "./db");

      Configuration securityCfg = config.add(SECURITY);
      if ( security != null )
         securityCfg.setAttribute(CLASS, security.getName());
      else
         securityCfg.setAttribute(CLASS, DEFAULT_SECURITYMANAGER.getName());

      Configuration queryEngineCfg = config.add(QUERYENGINE);
      Iterator iter;
      if ( queryResolvers != null )
         iter = queryResolvers.iterator();
      else
         iter = DEFAULT_RESOLVERS.iterator();

      while ( iter.hasNext() ) {
         Class c = (Class)iter.next();
         Configuration resolverCfg = queryEngineCfg.add(RESOLVER);
         resolverCfg.setAttribute(CLASS, c.getName());
      }

      return config;
   }
View Full Code Here

         System.err.println("Invalid Type '" + sType + "' - Falling back to " + COMPRESSED);
         type = ITYPE_COMPRESSED;
      }

      // If no Filer is defined, skip Symbols and Indexes
      Configuration filerConfig = config.getChild(FILER);
      if ( filerConfig != null ) {
         if ( config.getBooleanAttribute(CACHE, true) )
            cache = getDatabase().getCache();

         // Symbol Table Setup
         Configuration symConfig = config.getChild(SYMBOLS);
         internalSymbols = (symConfig != null);
         if ( internalSymbols ) {
            try {
               symbols = new SymbolTable(symConfig.getElement());
            }
            catch ( Exception e ) {
               e.printStackTrace(System.err);
            }
         }
         else {
            try {
               symbols = getSystemCollection().loadSymbols(this);
            }
            catch ( Exception e ) {
               e.printStackTrace(System.err);
            }
         }

         String className = filerConfig.getAttribute(CLASS);
         try {
            filer = (Filer)ClassResolver.get(className).newInstance();
            filer.setCollection(this);
            filer.setConfig(filerConfig);
            if ( !filer.exists() )
               filer.create();
            filer.open();
         }
         catch ( Exception e ) {
            System.err.println("Filer '" + className + "' not available");
         }

         // Index Manager
         try {
            indexes = new IndexManager(this);
            Configuration idxConfig = config.getChild(INDEXES, true);
            indexes.setConfig(idxConfig);
         }
         catch ( Exception e ) {
            e.printStackTrace(System.err);
         }

         // Trigger Manager
         triggers = new TriggerManager(this);
         try {
            Configuration triggerConfig = config.getChild(TRIGGERS, true);
            triggers.setConfig(triggerConfig);
         }
         catch ( Exception e ) {
            e.printStackTrace(System.err);
         }
      }

      // Extension Manager
      extensions = new ExtensionManager(this);
      try {
         Configuration objConfig = config.getChild(EXTENSIONS, true);
         extensions.setConfig(objConfig);
      }
      catch ( Exception e ) {
         e.printStackTrace(System.err);
      }
View Full Code Here

            File homeDir = new File(System.getProperty(dbXML.PROP_DBXML_HOME));
            setCollectionRoot(new File(homeDir, "db"));
         }

         try {
            Configuration queryCfg = config.getChild(QUERYENGINE);
            if ( queryCfg != null )
               engine.setConfig(queryCfg);
         }
         catch ( Exception e ) {
            e.printStackTrace(System.err);
            throw new dbXMLException("Couldn't initialize Query Engine", e);
         }

         try {
            sysCol = new SystemCollection(this, magicUser, userStack);
            try {
               sysCol.init();
            }
            catch ( dbXMLException e ) {
               e.printStackTrace(System.err);
            }
            collections.put(sysCol.getName(), sysCol);
         }
         catch ( Exception e ) {
            e.printStackTrace(System.err);
            throw new dbXMLException("Couldn't initialize System Collection", e);
         }

         Transaction tx = new Transaction();
         try {
            // Bootstrap from the database itself...  This is accomplished
            // by intercepting the setConfig call and using a Configuration
            // retrieved from the database instead of the standard config
            Collection col = sysCol.getCollection(SystemCollection.CONFIGS);
            DOMAdapter domAdapter = new DOMAdapter(col);
            Document colDoc = domAdapter.getDocument(tx, COLKEY);

            if ( colDoc == null ) {
               colDoc = DOMHelper.newDocument();
               Element root = colDoc.createElement(DATABASE);
               root.setAttribute(NAME, name);
               colDoc.appendChild(root);

               domAdapter.setDocument(tx, COLKEY, colDoc);
            }

            super.setConfig(new Configuration(colDoc));
         }
         catch ( Throwable e ) {
            tx.cancel();
            e.printStackTrace(System.err);
            throw new dbXMLException("Couldn't bootstrap Database", e);
         }
         finally {
            if ( tx.getStatus() == Transaction.ACTIVE )
               tx.commit();
         }

         try {
            Configuration securityCfg = config.getChild(SECURITY);
            if ( securityCfg != null ) {
               String className = securityCfg.getAttribute(CLASS);
               security = (SecurityManager)ClassResolver.get(className).newInstance();
               security.setDatabase(this);
               security.setMagicUser(magicUser);
               security.setUserStack(userStack);
               security.setConfig(securityCfg);
View Full Code Here

      File homeFile = new File(home);
      File cfgFile = new File(homeFile, "config/commands.xml");
      Document doc = DOMHelper.parse(cfgFile);

      Configuration cfg = new Configuration(doc);
      final String[] lastCatName = new String[1];
      final Map helpMap = new HashMap();
      final List catList = new ArrayList();

      setProperties(cfg);

      cfg.processChildren(CATEGORY, new ConfigurationCallback() {
         public void process(Configuration cc) {
            String name = cc.getAttribute(NAME);
            lastCatName[0] = name;
            String desc = cc.getAttribute(DESCRIPTION);
            catList.add(StringUtilities.leftJustify(name, 15) + " " + desc);
View Full Code Here

TOP

Related Classes of com.dbxml.util.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.