Package com.ibatis.common.xml

Examples of com.ibatis.common.xml.Nodelet


      }
    });
  }

  private void addTypeHandlerNodelets() {
    parser.addNodelet("/sqlMapConfig/typeHandler", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("building a building custom type handler");
        try {
          TypeHandlerFactory typeHandlerFactory = vars.client.getDelegate().getTypeHandlerFactory();
View Full Code Here


      }
    });
  }

  private void addTransactionManagerNodelets() {
    parser.addNodelet("/sqlMapConfig/transactionManager/end()", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("configuring the transaction manager");

        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);


        String type = attributes.getProperty("type");
        type = vars.typeHandlerFactory.resolveAlias(type);

        TransactionManager txManager = null;
        try {
          vars.errorCtx.setMoreInfo("Check the transaction manager type or class.");
          TransactionConfig config = (TransactionConfig) Resources.instantiate(type);
          config.setDataSource(vars.dataSource);
          config.setMaximumConcurrentTransactions(vars.client.getDelegate().getMaxTransactions());
          vars.errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration.");
          config.initialize(vars.txProps);
          vars.errorCtx.setMoreInfo(null);
          txManager = new TransactionManager(config);
          txManager.setForceCommit("true".equals(attributes.getProperty("commitRequired")));
        } catch (Exception e) {
          if (e instanceof SqlMapException) {
            throw (SqlMapException) e;
          } else {
            throw new SqlMapException("Error initializing TransactionManager.  Could not instantiate TransactionConfig.  Cause: " + e, e);
          }
        }

        vars.client.getDelegate().setTxManager(txManager);
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/property", new Nodelet() {
      public void process(Node node) throws Exception {
        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);
        String name = attributes.getProperty("name");
        String value = NodeletUtils.parsePropertyTokens(attributes.getProperty("value"), vars.properties);
        vars.txProps.setProperty(name, value);
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.dsProps = new Properties();
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource/end()", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("configuring the data source");

        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);

        String type = attributes.getProperty("type");
        type = vars.typeHandlerFactory.resolveAlias(type);

        try {
          vars.errorCtx.setMoreInfo("Check the data source type or class.");
          DataSourceFactory dsFactory = (DataSourceFactory) Resources.instantiate(type);
          vars.errorCtx.setMoreInfo("Check the data source properties or configuration.");
          dsFactory.initialize(vars.dsProps);
          vars.dataSource = dsFactory.getDataSource();
          vars.errorCtx.setMoreInfo(null);
        } catch (Exception e) {
          if (e instanceof SqlMapException) {
            throw (SqlMapException) e;
          } else {
            throw new SqlMapException("Error initializing DataSource.  Could not instantiate DataSourceFactory.  Cause: " + e, e);
          }
        }
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource/property", new Nodelet() {
      public void process(Node node) throws Exception {
        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);
        String name = attributes.getProperty("name");
        String value = NodeletUtils.parsePropertyTokens(attributes.getProperty("value"), vars.properties);
        vars.dsProps.setProperty(name, value);
View Full Code Here

      }
    });
  }

  protected void addSqlMapNodelets() {
    parser.addNodelet("/sqlMapConfig/sqlMap", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("loading the SQL Map resource");

        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);
View Full Code Here

      }
    });
  }

  private void addResultObjectFactoryNodelets() {
    parser.addNodelet("/sqlMapConfig/resultObjectFactory", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("configuring the Result Object Factory");

        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);

        String type = attributes.getProperty("type");

        ResultObjectFactory rof;
        try {
          rof = (ResultObjectFactory) Resources.instantiate(type);
          vars.delegate.setResultObjectFactory(rof);
        } catch (Exception e) {
          throw new SqlMapException("Error instantiating resultObjectFactory: " + type, e);
        }
      }
    });
    parser.addNodelet("/sqlMapConfig/resultObjectFactory/property", new Nodelet() {
      public void process(Node node) throws Exception {
        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);
        String name = attributes.getProperty("name");
        String value = NodeletUtils.parsePropertyTokens(attributes.getProperty("value"), vars.properties);
        vars.delegate.getResultObjectFactory().setProperty(name, value);
View Full Code Here

      throw new NestedRuntimeException("Error occurred.  Cause: " + e, e);
    }
  }

  private void addSqlMapConfigNodelets() {
    parser.addNodelet("/sqlMapConfig/end()", new Nodelet() {
      public void process(Node node) throws Exception {
        Iterator cacheNames = vars.client.getDelegate().getCacheModelNames();

        while (cacheNames.hasNext()) {
          String cacheName = (String) cacheNames.next();
View Full Code Here

      }
    });
  }

  private void addGlobalPropNodelets() {
    parser.addNodelet("/sqlMapConfig/properties", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("loading global properties");

        Properties attributes = NodeletUtils.parseAttributes(node);
        String resource = attributes.getProperty("resource");
View Full Code Here

      }
    });
  }

  private void addSettingsNodelets() {
    parser.addNodelet("/sqlMapConfig/settings", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("loading settings properties");

        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);
View Full Code Here

      }
    });
  }

  private void addTypeAliasNodelets() {
    parser.addNodelet("/sqlMapConfig/typeAlias", new Nodelet() {
      public void process(Node node) throws Exception {
        Properties prop = NodeletUtils.parseAttributes(node, vars.properties);
        String alias = prop.getProperty("alias");
        String type = prop.getProperty("type");
        vars.typeHandlerFactory.putTypeAlias(alias, type);
View Full Code Here

      }
    });
  }

  private void addTypeHandlerNodelets() {
    parser.addNodelet("/sqlMapConfig/typeHandler", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("building a building custom type handler");
        try {
          TypeHandlerFactory typeHandlerFactory = vars.client.getDelegate().getTypeHandlerFactory();
View Full Code Here

      }
    });
  }

  private void addTransactionManagerNodelets() {
    parser.addNodelet("/sqlMapConfig/transactionManager/end()", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("configuring the transaction manager");

        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);


        String type = attributes.getProperty("type");
        type = vars.typeHandlerFactory.resolveAlias(type);

        TransactionManager txManager = null;
        try {
          vars.errorCtx.setMoreInfo("Check the transaction manager type or class.");
          TransactionConfig config = (TransactionConfig) Resources.instantiate(type);
          config.setDataSource(vars.dataSource);
          config.setMaximumConcurrentTransactions(vars.client.getDelegate().getMaxTransactions());
          vars.errorCtx.setMoreInfo("Check the transactio nmanager properties or configuration.");
          config.initialize(vars.txProps);
          vars.errorCtx.setMoreInfo(null);
          txManager = new TransactionManager(config);
          txManager.setForceCommit("true".equals(attributes.getProperty("commitRequired")));
        } catch (Exception e) {
          if (e instanceof SqlMapException) {
            throw (SqlMapException) e;
          } else {
            throw new SqlMapException("Error initializing TransactionManager.  Could not instantiate TransactionConfig.  Cause: " + e, e);
          }
        }

        vars.client.getDelegate().setTxManager(txManager);
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/property", new Nodelet() {
      public void process(Node node) throws Exception {
        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);
        String name = attributes.getProperty("name");
        String value = NodeletUtils.parsePropertyTokens(attributes.getProperty("value"), vars.properties);
        vars.txProps.setProperty(name, value);
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.dsProps = new Properties();
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource/end()", new Nodelet() {
      public void process(Node node) throws Exception {
        vars.errorCtx.setActivity("configuring the data source");

        Properties attributes = NodeletUtils.parseAttributes(node);

        String type = attributes.getProperty("type");
        type = vars.typeHandlerFactory.resolveAlias(type);

        try {
          vars.errorCtx.setMoreInfo("Check the data source type or class.");
          DataSourceFactory dsFactory = (DataSourceFactory) Resources.instantiate(type);
          vars.errorCtx.setMoreInfo("Check the data source properties or configuration.");
          dsFactory.initialize(vars.dsProps);
          vars.dataSource = dsFactory.getDataSource();
          vars.errorCtx.setMoreInfo(null);
        } catch (Exception e) {
          if (e instanceof SqlMapException) {
            throw (SqlMapException) e;
          } else {
            throw new SqlMapException("Error initializing DataSource.  Could not instantiate DataSourceFactory.  Cause: " + e, e);
          }
        }
      }
    });
    parser.addNodelet("/sqlMapConfig/transactionManager/dataSource/property", new Nodelet() {
      public void process(Node node) throws Exception {
        Properties attributes = NodeletUtils.parseAttributes(node, vars.properties);
        String name = attributes.getProperty("name");
        String value = NodeletUtils.parsePropertyTokens(attributes.getProperty("value"), vars.properties);
        vars.dsProps.setProperty(name, value);
View Full Code Here

TOP

Related Classes of com.ibatis.common.xml.Nodelet

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.