Example usage for org.springframework.core.task SimpleAsyncTaskExecutor setThreadNamePrefix

List of usage examples for org.springframework.core.task SimpleAsyncTaskExecutor setThreadNamePrefix

Introduction

In this page you can find the example usage for org.springframework.core.task SimpleAsyncTaskExecutor setThreadNamePrefix.

Prototype

public void setThreadNamePrefix(@Nullable String threadNamePrefix) 

Source Link

Document

Specify the prefix to use for the names of newly created threads.

Usage

From source file:nl.rav.comparision.integration.unitofwork.java.UnitOfWorkSpringTest.java

private void createRouteBuilder() {
    handler = new AbstractReplyProducingMessageHandler() {
        @Override//from w  ww  .j  a va  2  s .c om
        protected Object handleRequestMessage(Message<?> requestMessage) {
            return "baz";
        }
    };
    AbstractReplyProducingMessageHandler handler2 = new AbstractReplyProducingMessageHandler() {
        @Override
        protected Object handleRequestMessage(Message<?> requestMessage) {
            if (doFail.get()) {
                throw new RuntimeException("qux");
            }
            return requestMessage.getPayload();
        }
    };

    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setThreadNamePrefix("test-");
    ExecutorChannel intermediate = new ExecutorChannel(taskExecutor);
    handler.setOutputChannel(intermediate);
    intermediate.subscribe(handler2);

    replies = new QueueChannel();
    handler2.setOutputChannel(replies);

    successChannel = new QueueChannel();
    failureChannel = new QueueChannel();
    ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice();
    advice.setBeanFactory(mock(BeanFactory.class));
    advice.setSuccessChannel(successChannel);
    advice.setFailureChannel(failureChannel);
    advice.setOnSuccessExpression("'foo'");
    advice.setOnFailureExpression("'bar:' + #exception.message");

    List<Advice> adviceChain = new ArrayList<Advice>();
    adviceChain.add(advice);
    handler.setAdviceChain(adviceChain);
    handler.afterPropertiesSet();
    handler2.setAdviceChain(adviceChain);
    handler2.afterPropertiesSet();
}

From source file:org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration.java

private TaskExecutor createDefaultTaskExecutor() {
    // create thread-pool for starting contexts
    ThreadGroup threadGroup = new ThreadGroup(
            "eclipse-gemini-blueprint-extender[" + ObjectUtils.getIdentityHexString(this) + "]-threads");
    threadGroup.setDaemon(false);//from   www  . j  a va2  s.c om

    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setThreadGroup(threadGroup);
    taskExecutor.setThreadNamePrefix("EclipseGeminiBlueprintExtenderThread-");

    isTaskExecutorManagedInternally = true;

    return taskExecutor;
}

From source file:org.springframework.osgi.extender.internal.support.ExtenderConfiguration.java

private TaskExecutor createDefaultTaskExecutor() {
    // create thread-pool for starting contexts
    ThreadGroup threadGroup = new ThreadGroup(
            "spring-osgi-extender[" + ObjectUtils.getIdentityHexString(this) + "]-threads");
    threadGroup.setDaemon(false);//  w  ww.  ja  va2 s.  co m

    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setThreadGroup(threadGroup);
    taskExecutor.setThreadNamePrefix("SpringOsgiExtenderThread-");

    isTaskExecutorManagedInternally = true;

    return taskExecutor;
}