Ejemplo n.º 1
0
  @SuppressWarnings("unchecked")
  private void initTxMgr() throws ServletException {
    if (_odeConfig.getDbMode().equals(OdeConfigProperties.DatabaseMode.EXTERNAL)
        && _odeConfig
            .getTxFactoryClass()
            .equals(OdeConfigProperties.DEFAULT_TX_FACTORY_CLASS_NAME)) {
      throw new ServletException(
          "No external transaction manager factory configured. Please use the INTERNAL mode or configure an external transaction manager that is associated with external datasource.");
    }

    String txFactoryName = _odeConfig.getTxFactoryClass();
    __log.debug("Initializing transaction manager using " + txFactoryName);
    try {
      Class txFactClass = this.getClass().getClassLoader().loadClass(txFactoryName);
      Object txFact = txFactClass.newInstance();
      _txMgr =
          (TransactionManager)
              txFactClass.getMethod("getTransactionManager", (Class[]) null).invoke(txFact);
      if (__logTx.isDebugEnabled() && System.getProperty("ode.debug.tx") != null)
        _txMgr = new DebugTxMgr(_txMgr);
    } catch (Exception e) {
      __log.fatal("Couldn't initialize a transaction manager with factory: " + txFactoryName, e);
      throw new ServletException(
          "Couldn't initialize a transaction manager with factory: " + txFactoryName, e);
    }
  }