Example usage for java.util.concurrent ThreadFactory ThreadFactory

List of usage examples for java.util.concurrent ThreadFactory ThreadFactory

Introduction

In this page you can find the example usage for java.util.concurrent ThreadFactory ThreadFactory.

Prototype

ThreadFactory

Source Link

Usage

From source file:org.energy_home.jemma.javagal.layers.business.GalController.java

/**
 * Creates a new instance with a {@code PropertiesManager} as the desired
 * configuration./* www .j  av  a2s  .  c om*/
 * 
 * @param _properties
 *            the PropertiesManager containing the desired configuration for
 *            the Gal controller.
 * @throws Exception
 *             if an error occurs.
 */
public GalController(PropertiesManager _properties) throws Exception {
    PropertiesManager = _properties;
    zdoManager = new ZdoManager(this);
    apsManager = new ApsMessageManager(this);
    messageManager = new MessageManager(this);
    _gatewayEventManager = new GatewayEventManager(this);
    manageMapPanId = new ManageMapPanId(this);
    _lockerStartDevice = new ParserLocker();
    _discoveryManager = new Discovery_Freshness_ForcePing(this);
    executor = Executors.newFixedThreadPool(getPropertiesManager().getNumberOfThreadForAnyPool(),
            new ThreadFactory() {

                public Thread newThread(Runnable r) {

                    return new Thread(r, "THPool-GalController");
                }
            });

    if (executor instanceof ThreadPoolExecutor) {
        ((ThreadPoolExecutor) executor).setKeepAliveTime(getPropertiesManager().getKeepAliveThread(),
                TimeUnit.MINUTES);
        ((ThreadPoolExecutor) executor).allowCoreThreadTimeOut(true);
    }
    initializeGAL();
}

From source file:com.boylesoftware.web.AbstractWebApplication.java

/**
 * Get executor service. This method is called once during the application
 * initialization. The executor service is automatically shut down by the
 * framework when the application goes down.
 *
 * <p>Default implementation returns a fixed size thread pool with number
 * of threads specified by the//from  w w w  .j  av  a  2 s. c o m
 * {@link ApplicationConfiguration#ASYNC_THREADS} application configuration
 * property. If the application configuration property is undefined, default
 * number of threads is {@value #DEFAULT_ASYNC_THREADS}.
 *
 * @param sc Servlet context.
 * @param config Application configuration.
 *
 * @return The executor service.
 *
 * @throws UnavailableException If the executor service is unavailable.
 * Throwing this exception makes the web-application fail to start.
 */
@SuppressWarnings("unused")
protected ExecutorService getExecutorService(final ServletContext sc, final ApplicationConfiguration config)
        throws UnavailableException {

    final ThreadGroup threadGroup = new ThreadGroup("AsyncExecutors");

    final int numThreads = config.getConfigProperty(ApplicationConfiguration.ASYNC_THREADS, Integer.class,
            Integer.valueOf(DEFAULT_ASYNC_THREADS)).intValue();

    return Executors.newFixedThreadPool(numThreads, new ThreadFactory() {

        private int nextThreadNum = 0;

        @Override
        public Thread newThread(final Runnable r) {

            final String threadName = "async-executor-" + (this.nextThreadNum++);

            LogFactory.getLog(this.getClass())
                    .debug("starting asynchronous request processing thread " + threadName);

            return new Thread(threadGroup, r, threadName);
        }
    });
}

From source file:org.wso2.bpel.Axis2BasedODEServer.java

private void initBpelServer(EndpointReferenceContextImpl eprContext) {
    if (__log.isDebugEnabled()) {
        __log.debug("ODE initializing");
    }/*from  w  w  w  .  j  a  v  a 2 s. c o  m*/
    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);

    _server = new BpelServerImpl();
    _scheduler = createScheduler();
    _scheduler.setJobProcessor(_server);

    _server.setDaoConnectionFactory(_daoCF);
    _server.setInMemDaoConnectionFactory(
            new BpelDAOConnectionFactoryImpl(_scheduler, _odeConfig.getInMemMexTtl()));
    _server.setEndpointReferenceContext(eprContext);
    _server.setMessageExchangeContext(new MessageExchangeContextImpl(this));
    _server.setBindingContext(new BindingContextImpl(this, _store));
    _server.setScheduler(_scheduler);
    if (_odeConfig.isDehydrationEnabled()) {
        CountLRUDehydrationPolicy dehy = new CountLRUDehydrationPolicy();
        // dehy.setProcessMaxAge(10000);
        _server.setDehydrationPolicy(dehy);
    }
    _server.setConfigProperties(_odeConfig.getProperties());
    _server.init();
}

From source file:com.hubcap.task.TaskRunner.java

/**
 * Starts the ThreadPoolExecutor which builds a set of TaskRunner instances
 * which will wait for inputs (from the user)
 *///  w w w . ja  v a2s  . c om
public static void startThreadPool() {
    if (!isTaskSystemReady) {
        System.out.println("startThreadPool()");

        isTaskSystemReady = true;

        // used to id the threads 'atomically'
        final AtomicLong count = new AtomicLong(0);
        if (TaskRunner.taskRunnerThreadFactory == null) {

            TaskRunner.taskRunnerThreadFactory = new ThreadFactory() {

                @Override
                public Thread newThread(Runnable r) {
                    if (runningTasks.contains(r)) {
                        throw new IllegalStateException("Cannot add duplicate runnable to running tasks");
                    }

                    Thread thread = new Thread(r);
                    thread.setDaemon(false);
                    thread.setName("HubcapTaskRunnerThread-" + count.getAndIncrement());
                    taskThreads.add(thread);
                    return thread;
                }
            };

            // calculates the current stable thread count based on the
            // assumption
            // that it takes 'X' times the amount of time to transfer data
            // (from github)
            // as it does to process said data (including Gson
            // transformation)
            // and the limit of Y% use of CPU. MAX_THREADS provides a safe
            // and stable cap for
            // systems that are so 'badass' that we would break the cap. \
            // (i.e. i have 32 cores and 12 disks = (2*32*12*1(1+5/1) =
            // 4600 threads, a bit high)...)
            int numThreads = ThreadUtils.getStableThreadCount(CPU_LOAD_TR, CPU_WAIT_TR, CPU_COMPUTE_TR,
                    Constants.MAX_TASK_RUNNER_THREADS);

            System.out.println("creating: " + numThreads + " threads for hubcap");
            TaskRunner.taskRunnerThreadPool = Executors.newFixedThreadPool(numThreads,
                    TaskRunner.taskRunnerThreadFactory);
            for (int i = 0; i < numThreads; ++i) {
                TaskRunner tr = new TaskRunner();
                taskRunnerThreadPool.execute(tr);
            }

            // pass the monitoring code to another thread
            // so we don't block the REPL loop
            monitorThread = new Thread(new Runnable() {

                @Override
                public void run() {

                    while (!taskRunnerThreadPool.isShutdown()) {
                        try {
                            TaskRunner.rebalance();
                            Thread.sleep(Constants.POOL_SHUTDOWN_CHECK_INTERVAL);

                        } catch (InterruptedException ex) {
                            if (ProcessModel.instance().getVerbose()) {
                                ErrorUtils.printStackTrace(ex);
                            }
                            break;
                        }
                    }

                    System.out.println("Thread Pool was shutdown");

                    while (!taskRunnerThreadPool.isTerminated()) {
                        try {
                            Thread.sleep(Constants.POOL_TERM_CHECK_INTERVAL);
                        } catch (InterruptedException ex) {
                            ErrorUtils.printStackTrace(ex);
                            break;
                        }
                    }

                    System.out.println("Thread pool terminated.");
                }
            });

            monitorThread.setName("TaskMonDaemon");
            monitorThread.setDaemon(false);

            // start monitoring
            monitorThread.start();

            System.out.println("Thread pool started!");
        }
    } else {
        throw new IllegalStateException("Hubcap task runner can only be initialized once!");
    }
}

From source file:com.raycloud.cobarclient.mybatis.spring.MySqlSessionTemplate.java

public void afterPropertiesSet() throws Exception {
    /****HOOK***/
    if (shards == null || shards.isEmpty())
        throw new IllegalArgumentException("'shards' argument is required.");
    if (router == null)
        throw new IllegalArgumentException("'router' argument is required");
    if (executor == null) {
        useDefaultExecutor = true;/*from  w ww . ja  v  a2s.com*/
        executor = Executors.newCachedThreadPool(new ThreadFactory() {
            public Thread newThread(Runnable runnable) {
                return new Thread(runnable, "Sql-Executor-thread");
            }
        });
    }
    for (Shard shard : shards) {
        Environment environment = new Environment(shard.getId(), this.transactionFactory,
                shard.getDataSource());
        environmentMap.put(shard.getId(), environment);
    }
}

From source file:password.pwm.util.Helper.java

public static ThreadFactory makePwmThreadFactory(final String namePrefix, final boolean daemon) {
    return new ThreadFactory() {
        private final ThreadFactory realThreadFactory = Executors.defaultThreadFactory();

        @Override//from ww w  . ja  va 2s .c o m
        public Thread newThread(final Runnable r) {
            final Thread t = realThreadFactory.newThread(r);
            t.setDaemon(daemon);
            if (namePrefix != null) {
                final String newName = namePrefix + t.getName();
                t.setName(newName);
            }
            return t;
        }
    };
}

From source file:edu.umass.cs.gigapaxos.PaxosManager.java

/**
 * @param id/*from   w  w w.  j a  va 2s  .c om*/
 *            My node ID.
 * @param unstringer
 *            An instance of Stringifiable that can convert String to
 *            NodeIDType.
 * @param niot
 *            InterfaceNIOTransport or InterfaceMessenger object used for
 *            messaging.
 * @param pi
 *            InterfaceReplicable application controlled by gigapaxos.
 *            Currently, all paxos instances must correspond to a single
 *            umbrella application even though each createPaxosInstance
 *            method explicitly specifies the app and this information is
 *            stored explicitly inside a paxos instance. The reason for the
 *            single umbrella app restriction is that we won't have a
 *            pointer to the appropriate app upon recovery otherwise.
 * @param paxosLogFolder
 *            Paxos logging folder.
 * @param enableNullCheckpoints
 *            Whether null checkpoints are enabled. We need this flag to be
 *            enabled if we intend to reconfigure paxos groups managed by
 *            this PaxosManager. Otherwise, we can not distinguish between a
 *            null checkpoint and no checkpoint, so the next epoch members
 *            may be waiting forever for the previous epoch's final state
 *            (that happens to be null). This flag needs to be set at
 *            construction time and can not be changed thereafter.
 */
public PaxosManager(NodeIDType id, Stringifiable<NodeIDType> unstringer,
        InterfaceNIOTransport<NodeIDType, JSONObject> niot, Replicable pi, String paxosLogFolder,
        boolean enableNullCheckpoints) {
    this.myID = this.integerMap.put(id);// id.hashCode();
    this.executor = Executors.newScheduledThreadPool(1, new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            Thread thread = Executors.defaultThreadFactory().newThread(r);
            thread.setName(PaxosManager.class.getSimpleName() + myID);
            return thread;
        }
    });
    this.unstringer = unstringer;
    this.largeCheckpointer = new LargeCheckpointer(paxosLogFolder, this.myID + "");
    this.myApp = LargeCheckpointer.wrap(pi, largeCheckpointer);
    this.FD = new FailureDetection<NodeIDType>(id, niot, paxosLogFolder);
    this.pinstances = new MultiArrayMap<String, PaxosInstanceStateMachine>(
            Config.getGlobalInt(PC.PINSTANCES_CAPACITY));
    this.corpses = new HashMap<String, PaxosInstanceStateMachine>();
    // this.activePaxii = new HashMap<String, ActivePaxosState>();
    this.messenger = (new PaxosMessenger<NodeIDType>(niot, this.integerMap));
    this.paxosLogger = new SQLPaxosLogger(this.myID, id.toString(), paxosLogFolder,
            this.wrapMessenger(this.messenger));
    this.nullCheckpointsEnabled = enableNullCheckpoints;
    // periodically remove active state for idle paxii
    executor.scheduleWithFixedDelay(new Deactivator(), 0, Config.getGlobalInt(PC.DEACTIVATION_PERIOD),
            TimeUnit.MILLISECONDS);
    this.pendingDigests = new PendingDigests(this.outstanding.requests,
            Config.getGlobalInt(PC.NUM_MESSAGE_DIGESTS), new PendingDigests.PendingDigestCallback() {
                public void callback(AcceptPacket accept) {
                    PaxosManager.this.callbackDigestedAcceptTimeout(accept);
                }
            });
    this.initOutstandingMonitor();
    (this.requestBatcher = new RequestBatcher(this)).start();
    (this.ppBatcher = new PaxosPacketBatcher(this)).start();
    testingInitialization();
    // needed to unclose when testing multiple runs of open and close
    open();
    // so paxos packets will come to me before anyone else
    niot.precedePacketDemultiplexer(
            Config.getGlobalString(PC.JSON_LIBRARY).equals("org.json") ? new JSONDemultiplexer()
                    : new FastDemultiplexer());
    initiateRecovery();
    if (!Config.getGlobalBoolean(PC.DELAY_PROFILER))
        DelayProfiler.disable();
}

From source file:org.gtdfree.ApplicationHelper.java

public static synchronized void executeInBackground(Runnable r) {

    if (backgroundExecutor == null) {
        backgroundExecutor = new ThreadPoolExecutor(0, 1, 1, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {

                    @Override/*w ww.j  a v  a  2  s  .co  m*/
                    public Thread newThread(Runnable r) {
                        Thread t = new Thread(r);
                        t.setName("BackgroundExecutor"); //$NON-NLS-1$
                        t.setPriority(Thread.MIN_PRIORITY);
                        t.setDaemon(false);
                        return t;
                    }
                });
    }

    backgroundExecutor.execute(r);

}

From source file:org.epics.archiverappliance.config.DefaultConfigService.java

@Override
public void initialize(ServletContext sce) throws ConfigException {
    this.servletContext = sce;
    String contextPath = sce.getContextPath();
    logger.info("DefaultConfigService was created with a servlet context " + contextPath);

    try {/*w  ww. ja  va  2 s . c  o  m*/
        String pathToVersionTxt = sce.getRealPath("ui/comm/version.txt");
        logger.debug("The full path to the version.txt is " + pathToVersionTxt);
        List<String> lines = Files.readAllLines(Paths.get(pathToVersionTxt), Charset.forName("UTF-8"));
        for (String line : lines) {
            configlogger.info(line);
        }
    } catch (Throwable t) {
        logger.fatal("Unable to determine appliance version", t);
    }

    try {
        // We first try Java system properties for this appliance's identity
        // If a property is not defined, then we check the environment.
        // This gives us the ability to cater to unit tests as well as running using buildAndDeploy scripts without touching the server.xml file.
        // Probably not the most standard way but suited to this need.
        // Finally, we use the local machine's hostname as the myidentity.
        myIdentity = System.getProperty(ARCHAPPL_MYIDENTITY);
        if (myIdentity == null) {
            myIdentity = System.getenv(ARCHAPPL_MYIDENTITY);
            if (myIdentity != null) {
                logger.info("Obtained my identity from environment variable " + myIdentity);
            } else {
                logger.info("Using the local machine's hostname " + myIdentity + " as my identity");
                myIdentity = InetAddress.getLocalHost().getCanonicalHostName();
            }
            if (myIdentity == null) {
                throw new ConfigException("Unable to determine identity of this appliance");
            }
        } else {
            logger.info("Obtained my identity from Java system properties " + myIdentity);
        }

        logger.info("My identity is " + myIdentity);
    } catch (Exception ex) {
        String msg = "Cannot determine this appliance's identity using either the environment variable "
                + ARCHAPPL_MYIDENTITY + " or the java system property " + ARCHAPPL_MYIDENTITY;
        configlogger.fatal(msg);
        throw new ConfigException(msg, ex);
    }
    // Appliances should be local and come straight from persistence.
    try {
        appliances = AppliancesList.loadAppliancesXML(servletContext);
    } catch (Exception ex) {
        throw new ConfigException("Exception loading appliances.xml", ex);
    }

    myApplianceInfo = appliances.get(myIdentity);
    if (myApplianceInfo == null)
        throw new ConfigException("Unable to determine applianceinfo using identity " + myIdentity);
    configlogger.info("My identity is " + myApplianceInfo.getIdentity() + " and my mgmt URL is "
            + myApplianceInfo.getMgmtURL());

    // To make sure we are not starting multiple appliance with the same identity, we make sure that the hostnames match
    try {
        String machineHostName = InetAddress.getLocalHost().getCanonicalHostName();
        String[] myAddrParts = myApplianceInfo.getClusterInetPort().split(":");
        String myHostNameFromInfo = myAddrParts[0];
        if (myHostNameFromInfo.equals("localhost")) {
            logger.debug(
                    "Using localhost for the cluster inet port. If you are indeed running a cluster, the cluster members will not join the cluster.");
        } else if (myHostNameFromInfo.equals(machineHostName)) {
            logger.debug(
                    "Hostname from config and hostname from InetAddress match exactly; we are correctly configured "
                            + machineHostName);
        } else if (InetAddressValidator.getInstance().isValid(myHostNameFromInfo)) {
            logger.debug("Using ipAddress for cluster config " + myHostNameFromInfo);
        } else {
            String msg = "The hostname from appliances.xml is " + myHostNameFromInfo
                    + " and from a call to InetAddress.getLocalHost().getCanonicalHostName() (typially FQDN) is "
                    + machineHostName
                    + ". These are not identical. They are probably equivalent but to prevent multiple appliances binding to the same identity we enforce this equality.";
            configlogger.fatal(msg);
            throw new ConfigException(msg);
        }
    } catch (UnknownHostException ex) {
        configlogger.error(
                "Got an UnknownHostException when trying to determine the hostname. This happens when DNS is not set correctly on this machine (for example, when using VM's. See the documentation for InetAddress.getLocalHost().getCanonicalHostName()");
    }

    try {
        String archApplPropertiesFileName = System.getProperty(ARCHAPPL_PROPERTIES_FILENAME);
        if (archApplPropertiesFileName == null) {
            archApplPropertiesFileName = System.getenv(ARCHAPPL_PROPERTIES_FILENAME);
        }
        if (archApplPropertiesFileName == null) {
            archApplPropertiesFileName = new URL(this.getClass().getClassLoader()
                    .getResource(DEFAULT_ARCHAPPL_PROPERTIES_FILENAME).toString()).getPath();
            configlogger.info(
                    "Loading archappl.properties from the webapp classpath " + archApplPropertiesFileName);
        } else {
            configlogger.info("Loading archappl.properties using the environment/JVM property from "
                    + archApplPropertiesFileName);
        }
        try (InputStream is = new FileInputStream(new File(archApplPropertiesFileName))) {
            archapplproperties.load(is);
            configlogger.info(
                    "Done loading installation specific properties file from " + archApplPropertiesFileName);
        } catch (Exception ex) {
            throw new ConfigException(
                    "Exception loading installation specific properties file " + archApplPropertiesFileName,
                    ex);
        }
    } catch (ConfigException cex) {
        throw cex;
    } catch (Exception ex) {
        configlogger.fatal("Exception loading the appliance properties file", ex);
    }

    switch (contextPath) {
    case "/mgmt":
        warFile = WAR_FILE.MGMT;
        this.mgmtRuntime = new MgmtRuntimeState(this);
        break;
    case "/engine":
        warFile = WAR_FILE.ENGINE;
        this.engineContext = new EngineContext(this);
        break;
    case "/retrieval":
        warFile = WAR_FILE.RETRIEVAL;
        this.retrievalState = new RetrievalState(this);
        break;
    case "/etl":
        this.etlPVLookup = new PBThreeTierETLPVLookup(this);
        warFile = WAR_FILE.ETL;
        break;
    default:
        logger.error("We seem to have introduced a new component into the system " + contextPath);
    }

    String pvName2KeyMappingClass = this.getInstallationProperties()
            .getProperty(ARCHAPPL_PVNAME_TO_KEY_MAPPING_CLASSNAME);
    if (pvName2KeyMappingClass == null || pvName2KeyMappingClass.equals("")
            || pvName2KeyMappingClass.length() < 1) {
        logger.info("Using the default key mapping class");
        pvName2KeyConverter = new ConvertPVNameToKey();
        pvName2KeyConverter.initialize(this);
    } else {
        try {
            logger.info("Using " + pvName2KeyMappingClass + " as the name to key mapping class");
            pvName2KeyConverter = (PVNameToKeyMapping) Class.forName(pvName2KeyMappingClass).newInstance();
            pvName2KeyConverter.initialize(this);
        } catch (Exception ex) {
            logger.fatal("Cannot initialize pv name to key mapping class " + pvName2KeyMappingClass, ex);
            throw new ConfigException(
                    "Cannot initialize pv name to key mapping class " + pvName2KeyMappingClass, ex);
        }
    }

    String runtimeFieldsListStr = this.getInstallationProperties()
            .getProperty("org.epics.archiverappliance.config.RuntimeKeys");
    if (runtimeFieldsListStr != null && !runtimeFieldsListStr.isEmpty()) {
        logger.debug("Got runtime fields from the properties file " + runtimeFieldsListStr);
        String[] runTimeFieldsArr = runtimeFieldsListStr.split(",");
        for (String rf : runTimeFieldsArr) {
            this.runTimeFields.add(rf.trim());
        }
    }

    startupExecutor = Executors.newScheduledThreadPool(1, new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            Thread t = new Thread(r);
            t.setName("Startup executor");
            return t;
        }
    });

    this.addShutdownHook(new Runnable() {
        @Override
        public void run() {
            logger.info("Shutting down startup scheduled executor...");
            startupExecutor.shutdown();
        }
    });

    this.startupState = STARTUP_SEQUENCE.READY_TO_JOIN_APPLIANCE;
    if (this.warFile == WAR_FILE.MGMT) {
        logger.info("Scheduling webappReady's for the mgmt webapp ");
        MgmtPostStartup mgmtPostStartup = new MgmtPostStartup(this);
        ScheduledFuture<?> postStartupFuture = startupExecutor.scheduleAtFixedRate(mgmtPostStartup, 10, 20,
                TimeUnit.SECONDS);
        mgmtPostStartup.setCancellingFuture(postStartupFuture);
    } else {
        logger.info("Scheduling webappReady's for the non-mgmt webapp " + this.warFile.toString());
        NonMgmtPostStartup nonMgmtPostStartup = new NonMgmtPostStartup(this, this.warFile.toString());
        ScheduledFuture<?> postStartupFuture = startupExecutor.scheduleAtFixedRate(nonMgmtPostStartup, 10, 20,
                TimeUnit.SECONDS);
        nonMgmtPostStartup.setCancellingFuture(postStartupFuture);
    }

    // Measure some JMX metrics once a minute
    startupExecutor.scheduleAtFixedRate(new Runnable() {
        @Override
        public void run() {
            processMetrics.takeMeasurement();
        }
    }, 60, 60, TimeUnit.SECONDS);
}

From source file:org.apache.ode.axis2.ODEServer.java

private void initBpelServer(EndpointReferenceContextImpl eprContext) {
    if (__log.isDebugEnabled()) {
        __log.debug("ODE initializing");
    }// w ww .j av a 2  s  .c o m
    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());
}