@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); } }
protected void initProcessStore(EndpointReferenceContext eprContext) { _store = createProcessStore(eprContext, _db.getDataSource()); _store.registerListener(new ProcessStoreListenerImpl()); _store.setDeployDir( _odeConfig.getDeployDir() != null ? new File(_odeConfig.getDeployDir()) : new File(_workRoot, "processes")); _store.setConfigDir(_configRoot); }
/** * Initialize the DAO. * * @throws ServletException */ protected void initDAO() throws ServletException { __log.info(__msgs.msgOdeUsingDAOImpl(_odeConfig.getDAOConnectionFactory())); try { _daoCF = _db.createDaoCF(); } catch (Exception ex) { String errmsg = __msgs.msgDAOInstantiationFailed(_odeConfig.getDAOConnectionFactory()); __log.error(errmsg, ex); throw new ServletException(errmsg, ex); } }
private void initConnector() throws ServletException { int port = _odeConfig.getConnectorPort(); if (port == 0) { __log.info("Skipping connector initialization."); } else { _connector = new BpelServerConnector(); _connector.setBpelServer(_bpelServer); _connector.setProcessStore(_store); _connector.setPort(_odeConfig.getConnectorPort()); _connector.setId("jcaServer"); try { _connector.start(); } catch (Exception e) { __log.error("Failed to initialize JCA connector.", e); } } }
protected Scheduler createScheduler() { SimpleScheduler scheduler = new SimpleScheduler( new GUID().toString(), new JdbcDelegate(_db.getDataSource()), _odeConfig.getProperties()); scheduler.setExecutorService(_executorService); scheduler.setTransactionManager(_txMgr); return scheduler; }
private void initHttpConnectionManager() throws ServletException { httpConnectionManager = new MultiThreadedHttpConnectionManager(); // settings may be overridden from ode-axis2.properties using the same properties as HttpClient // /!\ If the size of the conn pool is smaller than the size of the thread pool, the thread pool // might get starved. int max_per_host = Integer.parseInt( _odeConfig.getProperty( HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, "" + _odeConfig.getPoolMaxSize())); int max_total = Integer.parseInt( _odeConfig.getProperty( HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, "" + _odeConfig.getPoolMaxSize())); if (__log.isDebugEnabled()) { __log.debug(HttpConnectionManagerParams.MAX_HOST_CONNECTIONS + "=" + max_per_host); __log.debug(HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS + "=" + max_total); } if (max_per_host < 1 || max_total < 1) { String errmsg = HttpConnectionManagerParams.MAX_HOST_CONNECTIONS + " and " + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS + " must be positive integers!"; __log.error(errmsg); throw new ServletException(errmsg); } httpConnectionManager.getParams().setDefaultMaxConnectionsPerHost(max_per_host); httpConnectionManager.getParams().setMaxTotalConnections(max_total); // Register the connection manager to a idle check thread idleConnectionTimeoutThread = new IdleConnectionTimeoutThread(); idleConnectionTimeoutThread.setName("Http_Idle_Connection_Timeout_Thread"); long idleConnectionTimeout = Long.parseLong(_odeConfig.getProperty("http.idle.connection.timeout", "30000")); long idleConnectionCheckInterval = Long.parseLong(_odeConfig.getProperty("http.idle.connection.check.interval", "30000")); if (__log.isDebugEnabled()) { __log.debug("http.idle.connection.timeout=" + idleConnectionTimeout); __log.debug("http.idle.connection.check.interval=" + idleConnectionCheckInterval); } idleConnectionTimeoutThread.setConnectionTimeout(idleConnectionTimeout); idleConnectionTimeoutThread.setTimeoutInterval(idleConnectionCheckInterval); idleConnectionTimeoutThread.addConnectionManager(httpConnectionManager); idleConnectionTimeoutThread.start(); }
private void registerMexInterceptors() { String listenersStr = _odeConfig.getMessageExchangeInterceptors(); if (listenersStr != null) { for (StringTokenizer tokenizer = new StringTokenizer(listenersStr, ",;"); tokenizer.hasMoreTokens(); ) { String interceptorCN = tokenizer.nextToken(); try { _bpelServer.registerMessageExchangeInterceptor( (MessageExchangeInterceptor) Class.forName(interceptorCN).newInstance()); __log.info(__msgs.msgMessageExchangeInterceptorRegistered(interceptorCN)); } catch (Exception e) { __log.warn( "Couldn't register the event listener " + interceptorCN + ", the class couldn't be " + "loaded properly: " + e); } } } }
private void initBpelServer(EndpointReferenceContextImpl eprContext) { if (__log.isDebugEnabled()) { __log.debug("ODE initializing"); } ThreadFactory threadFactory = new ThreadFactory() { int threadNumber = 0; public Thread newThread(Runnable r) { threadNumber += 1; Thread t = new Thread(r, "ODEServer-" + threadNumber); t.setDaemon(true); return t; } }; if (_odeConfig.getThreadPoolMaxSize() == 0) _executorService = Executors.newCachedThreadPool(threadFactory); else _executorService = Executors.newFixedThreadPool(_odeConfig.getThreadPoolMaxSize(), threadFactory); { List<String> targets = new ArrayList<String>(); Collections.addAll( targets, _odeConfig.getProperty("cluster.localRoute.targets", "").split(",")); _clusterUrlTransformer = new ClusterUrlTransformer( targets, _odeConfig.getProperty( "cluster.localRoute.base", "http://localhost:8080/ode/processes/")); } _bpelServer = new BpelServerImpl(); _scheduler = createScheduler(); _scheduler.setJobProcessor(_bpelServer); BpelServerImpl.PolledRunnableProcessor polledRunnableProcessor = new BpelServerImpl.PolledRunnableProcessor(); polledRunnableProcessor.setPolledRunnableExecutorService(_executorService); polledRunnableProcessor.setContexts(_bpelServer.getContexts()); _scheduler.setPolledRunnableProcesser(polledRunnableProcessor); _cronScheduler = new CronScheduler(); _cronScheduler.setScheduledTaskExec(_executorService); _cronScheduler.setContexts(_bpelServer.getContexts()); _bpelServer.setCronScheduler(_cronScheduler); _bpelServer.setDaoConnectionFactory(_daoCF); _bpelServer.setInMemDaoConnectionFactory( new BpelDAOConnectionFactoryImpl(_scheduler, _odeConfig.getInMemMexTtl())); _bpelServer.setEndpointReferenceContext(eprContext); _bpelServer.setMessageExchangeContext(new MessageExchangeContextImpl(this)); _bpelServer.setBindingContext(new BindingContextImpl(this)); _bpelServer.setScheduler(_scheduler); if (_odeConfig.isDehydrationEnabled()) { CountLRUDehydrationPolicy dehy = new CountLRUDehydrationPolicy(); dehy.setProcessMaxAge(_odeConfig.getDehydrationMaximumAge()); dehy.setProcessMaxCount(_odeConfig.getDehydrationMaximumCount()); _bpelServer.setDehydrationPolicy(dehy); } _bpelServer.setMigrationTransactionTimeout(_odeConfig.getMigrationTransactionTimeout()); _bpelServer.setConfigProperties(_odeConfig.getProperties()); _bpelServer.init(); _bpelServer.setInstanceThrottledMaximumCount(_odeConfig.getInstanceThrottledMaximumCount()); _bpelServer.setProcessThrottledMaximumCount(_odeConfig.getProcessThrottledMaximumCount()); _bpelServer.setProcessThrottledMaximumSize(_odeConfig.getProcessThrottledMaximumSize()); _bpelServer.setHydrationLazy(_odeConfig.isHydrationLazy()); _bpelServer.setHydrationLazyMinimumSize(_odeConfig.getHydrationLazyMinimumSize()); }
protected ProcessStoreImpl createProcessStore( EndpointReferenceContext eprContext, DataSource ds) { return new ProcessStoreImpl( eprContext, ds, _odeConfig.getDAOConnectionFactory(), _odeConfig, false); }
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()); }