示例#1
0
文件: ODEServer.java 项目: rrialq/ode
  /**
   * Shutdown the service engine. This performs cleanup before the BPE is terminated. Once this
   * method has been called, init() must be called before the transformation engine can be started
   * again with a call to start().
   *
   * @throws AxisFault if the engine is unable to shut down.
   */
  public void shutDown() throws AxisFault {

    ClassLoader old = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    try {
      if (_poller != null)
        try {
          __log.debug("shutting down poller");
          _poller.stop();
          _poller = null;
        } catch (Throwable t) {
          __log.debug("Error stopping poller.", t);
        }

      if (_bpelServer != null)
        try {
          __log.debug("shutting down ODE server.");
          _bpelServer.shutdown();
          _bpelServer = null;
        } catch (Throwable ex) {
          __log.debug("Error stopping services.", ex);
        }

      if (_cronScheduler != null) {
        try {
          __log.debug("shutting down cron scheduler.");
          _cronScheduler.shutdown();
          _cronScheduler = null;
        } catch (Exception ex) {
          __log.debug("Cron scheduler couldn't be shutdown.", ex);
        }
      }

      if (_scheduler != null)
        try {
          __log.debug("shutting down scheduler.");
          _scheduler.shutdown();
          _scheduler = null;
        } catch (Exception ex) {
          __log.debug("Scheduler couldn't be shutdown.", ex);
        }

      if (_store != null)
        try {
          _store.shutdown();
          _store = null;
        } catch (Throwable t) {
          __log.debug("Store could not be shutdown.", t);
        }

      if (_daoCF != null)
        try {
          _daoCF.shutdown();
        } catch (Throwable ex) {
          __log.debug("DOA shutdown failed.", ex);
        } finally {
          _daoCF = null;
        }

      if (_db != null)
        try {
          _db.shutdown();

        } catch (Throwable ex) {
          __log.debug("DB shutdown failed.", ex);
        } finally {
          _db = null;
        }

      if (_txMgr != null) {
        __log.debug("shutting down transaction manager.");
        _txMgr = null;
      }

      if (_connector != null) {
        try {
          __log.debug("shutdown BpelConnector");
          _connector.shutdown();
          _connector = null;
        } catch (Throwable t) {
          __log.error("Unable to cleanup temp files.", t);
        }
      }
      if (httpConnectionManager != null) {
        __log.debug("shutting down HTTP connection manager.");
        try {
          httpConnectionManager.shutdown();
          httpConnectionManager = null;
        } catch (Throwable t) {
          __log.error("Unable to shut down HTTP connection manager.", t);
        }
      }
      if (idleConnectionTimeoutThread != null) {
        __log.debug("shutting down Idle Connection Timeout Thread.");
        try {
          idleConnectionTimeoutThread.shutdown();
          idleConnectionTimeoutThread = null;
        } catch (Throwable t) {
          __log.error("Unable to shut down Idle Connection Timeout Thread.", t);
        }
      }
      try {
        __log.debug("cleaning up temporary files.");
        TempFileManager.cleanup();
      } catch (Throwable t) {
        __log.error("Unable to cleanup temp files.", t);
      }

      if (_executorService != null) {
        _executorService.shutdownNow();
        _executorService = null;
      }

      __log.info(__msgs.msgOdeShutdownCompleted());
    } finally {
      Thread.currentThread().setContextClassLoader(old);
    }
  }
示例#2
0
文件: ODEServer.java 项目: rrialq/ode
  public void init(
      String contextPath, ConfigurationContext configContext, ODEConfigProperties config)
      throws ServletException {
    _configContext = configContext;
    String rootDir = System.getProperty("org.apache.ode.rootDir");
    if (rootDir != null) _appRoot = new File(rootDir);
    else _appRoot = new File(contextPath);

    if (!_appRoot.isDirectory())
      throw new IllegalArgumentException(_appRoot + " does not exist or is not a directory");
    TempFileManager.setWorkingDirectory(_appRoot);

    __log.debug("Loading properties");
    String confDir = System.getProperty("org.apache.ode.configDir");
    _configRoot = confDir == null ? new File(_appRoot, "conf") : new File(confDir);
    if (!_configRoot.isDirectory())
      throw new IllegalArgumentException(_configRoot + " does not exist or is not a directory");

    try {
      if (config == null) {
        _odeConfig = new ODEConfigProperties(_configRoot);
        _odeConfig.load();
      } else {
        _odeConfig = config;
      }
    } catch (FileNotFoundException fnf) {
      String errmsg = __msgs.msgOdeInstallErrorCfgNotFound(_odeConfig.getFile());
      __log.warn(errmsg);
    } catch (Exception ex) {
      String errmsg = __msgs.msgOdeInstallErrorCfgReadError(_odeConfig.getFile());
      __log.error(errmsg, ex);
      throw new ServletException(errmsg, ex);
    }

    String wdir = _odeConfig.getWorkingDir();
    if (wdir == null) _workRoot = _appRoot;
    else _workRoot = new File(wdir.trim());
    if (!_workRoot.isDirectory())
      throw new IllegalArgumentException(_workRoot + " does not exist or is not a directory");

    __log.debug("Initializing transaction manager");
    initTxMgr();
    if (txMgrCreatedCallback != null) {
      txMgrCreatedCallback.run();
    }
    __log.debug("Creating data source.");
    initDataSource();
    __log.debug("Starting DAO.");
    initDAO();
    EndpointReferenceContextImpl eprContext = new EndpointReferenceContextImpl(this);
    __log.debug("Initializing BPEL process store.");
    initProcessStore(eprContext);
    __log.debug("Initializing BPEL server.");
    initBpelServer(eprContext);
    __log.debug("Initializing HTTP connection manager");
    initHttpConnectionManager();

    // Register BPEL event listeners configured in axis2.properties file.
    registerEventListeners();
    registerMexInterceptors();
    registerExternalVariableModules();

    _store.loadAll();

    try {
      _bpelServer.start();
    } catch (Exception ex) {
      String errmsg = __msgs.msgOdeBpelServerStartFailure();
      __log.error(errmsg, ex);
      throw new ServletException(errmsg, ex);
    }

    _poller = getDeploymentPollerExt();
    if (_poller == null) {
      _poller = new DeploymentPoller(_store.getDeployDir(), this);
    }

    _mgtService = new ManagementService();
    _mgtService.enableService(
        _configContext.getAxisConfiguration(), _bpelServer, _store, _appRoot.getAbsolutePath());

    try {
      __log.debug("Initializing Deployment Web Service");
      new DeploymentWebService()
          .enableService(
              _configContext.getAxisConfiguration(),
              _store,
              _poller,
              _appRoot.getAbsolutePath(),
              _workRoot.getAbsolutePath());
    } catch (Exception e) {
      throw new ServletException(e);
    }

    __log.debug("Starting scheduler");
    _scheduler.start();

    __log.debug("Initializing JCA adapter.");
    initConnector();

    _poller.start();
    __log.info(__msgs.msgPollingStarted(_store.getDeployDir().getAbsolutePath()));
    __log.info(__msgs.msgOdeStarted());
  }