• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SyncTaskExecutor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.core.task.SyncTaskExecutor的典型用法代码示例。如果您正苦于以下问题:Java SyncTaskExecutor类的具体用法?Java SyncTaskExecutor怎么用?Java SyncTaskExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SyncTaskExecutor类属于org.springframework.core.task包,在下文中一共展示了SyncTaskExecutor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initializeExtensionWithProperties

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
private void initializeExtensionWithProperties(
        final ActorInfoContributorConfiguration.GroupProperties.GroupType primary,
        final ActorInfoContributorConfiguration.GroupProperties.GroupType secondary)
{
    ActorInfoContributorConfiguration.GroupProperties groupProperties =
            new ActorInfoContributorConfiguration.GroupProperties();
    groupProperties.setPrimary(primary);
    groupProperties.setSecondary(secondary);
    extension = new ActorInfoContributorLifetimeExtension(reference ->
    {
        // Ideally this would be a mock, but since Mockito keeps references in memory to arguments passed
        // to mocked methods, and some of these tests rely on actor instances being garbage collected, it's
        // necessary to create the fake object manually like so.
        Class<? extends AbstractActor> referenceClass = reference.getClass();
        if (FakeActorImpl.class.isAssignableFrom(referenceClass))
        {
            return FakeActor.class;
        }
        else if (OtherFakeActorImpl.class.isAssignableFrom(referenceClass))
        {
            return OtherFakeActor.class;
        }
        return null;
    }, new ActorInfoDetailsContainer(groupProperties), new SyncTaskExecutor());
    extension.start().join();
}
 
开发者ID:orbit,项目名称:orbit-spring,代码行数:27,代码来源:ActorInfoContributorTest.java


示例2: buildMachineNoTransition

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
public StateMachine<States, Events> buildMachineNoTransition() throws Exception {
    StateMachineBuilder.Builder<States, Events> builder = StateMachineBuilder.builder();

    builder.configureConfiguration()
           .withConfiguration()
           .taskExecutor(new SyncTaskExecutor())
    ;

    builder.configureStates()
           .withStates()
           .initial(States.SI)
           .state(States.S1)
           .states(EnumSet.allOf(States.class))
    ;


    return builder.build();
}
 
开发者ID:WorkingDevelopers,项目名称:spring-state-machine-chart-dumper,代码行数:19,代码来源:T1.java


示例3: buildMachineOnlyNormalStates

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
public StateMachine<States, Events> buildMachineOnlyNormalStates() throws Exception {
    StateMachineBuilder.Builder<States, Events> builder = StateMachineBuilder.builder();

    builder.configureConfiguration()
           .withConfiguration()
           .taskExecutor(new SyncTaskExecutor())
    ;

    builder.configureStates()
           .withStates()
           .states(EnumSet.allOf(States.class))
    ;


    return builder.build();
}
 
开发者ID:WorkingDevelopers,项目名称:spring-state-machine-chart-dumper,代码行数:17,代码来源:T1.java


示例4: initializeDefaultTaskExecutor

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
/**
 *
 */
public void initializeDefaultTaskExecutor() {
	if (taskThreadCount > 1) {
		ThreadPoolTaskExecutor tpte = new ThreadPoolTaskExecutor();
		tpte.setCorePoolSize(taskThreadCount);

		// 10 minutes should be plenty of time to wait for REST API modules to be loaded
		tpte.setAwaitTerminationSeconds(60 * 10);
		tpte.setWaitForTasksToCompleteOnShutdown(true);

		tpte.afterPropertiesSet();
		this.taskExecutor = tpte;
	} else {
		this.taskExecutor = new SyncTaskExecutor();
	}
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:19,代码来源:DefaultModulesLoader.java


示例5: initializeDefaultTaskExecutor

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
protected void initializeDefaultTaskExecutor() {
	if (threadCount > 1) {
		if (logger.isDebugEnabled()) {
			logger.debug("Initializing thread pool with a count of " + threadCount);
		}
		ThreadPoolTaskExecutor tpte = new ThreadPoolTaskExecutor();
		tpte.setCorePoolSize(threadCount);

		// By default, wait for tasks to finish, and wait up to an hour
		tpte.setWaitForTasksToCompleteOnShutdown(true);
		tpte.setAwaitTerminationSeconds(60 * 60);

		tpte.afterPropertiesSet();
		this.taskExecutor = tpte;
	} else {
		if (logger.isDebugEnabled()) {
			logger.debug("Thread count is 1, so using a synchronous TaskExecutor");
		}
		this.taskExecutor = new SyncTaskExecutor();
	}
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:22,代码来源:BatchWriterSupport.java


示例6: getInputStream_existingObject_returnsInputStreamWithContent

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Test
public void getInputStream_existingObject_returnsInputStreamWithContent() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    ObjectMetadata objectMetadata = mock(ObjectMetadata.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(objectMetadata);

    S3Object s3Object = new S3Object();
    s3Object.setObjectMetadata(objectMetadata);
    s3Object.setObjectContent(new ByteArrayInputStream(new byte[]{42}));
    when(amazonS3.getObject(any(GetObjectRequest.class))).thenReturn(s3Object);

    //Act
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Assert
    assertTrue(simpleStorageResource.exists());
    assertEquals(42, simpleStorageResource.getInputStream().read());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:SimpleStorageResourceTest.java


示例7: writeFile_forNewFile_writesFileContent

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Test
public void writeFile_forNewFile_writesFileContent() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucketName", "objectName", new SyncTaskExecutor());
    String messageContext = "myFileContent";
    when(amazonS3.putObject(eq("bucketName"), eq("objectName"), any(InputStream.class), any(ObjectMetadata.class))).thenAnswer((Answer<PutObjectResult>) invocation -> {
        assertEquals("bucketName", invocation.getArguments()[0]);
        assertEquals("objectName", invocation.getArguments()[1]);
        byte[] content = new byte[messageContext.length()];
        assertEquals(content.length, ((InputStream) invocation.getArguments()[2]).read(content));
        assertEquals(messageContext, new String(content));
        return new PutObjectResult();
    });
    OutputStream outputStream = simpleStorageResource.getOutputStream();

    //Act
    outputStream.write(messageContext.getBytes());
    outputStream.flush();
    outputStream.close();

    //Assert
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:24,代码来源:SimpleStorageResourceTest.java


示例8: createResourceLoader_withoutExecutorSettings_executorConfigured

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Test
public void createResourceLoader_withoutExecutorSettings_executorConfigured() throws Exception {

    //Arrange
    this.context = new AnnotationConfigApplicationContext();
    this.context.register(ContextResourceLoaderAutoConfiguration.class);
    this.context.register(ApplicationBean.class);

    //Act
    this.context.refresh();

    //Assert
    PathMatchingSimpleStorageResourcePatternResolver resourceLoader = this.context.getBean(ApplicationBean.class).getResourceLoader();
    assertNotNull(resourceLoader);

    SimpleStorageResourceLoader simpleStorageResourceLoader = (SimpleStorageResourceLoader) ReflectionTestUtils.getField(resourceLoader, "simpleStorageResourceLoader");
    SyncTaskExecutor taskExecutor = (SyncTaskExecutor) ReflectionTestUtils.getField(simpleStorageResourceLoader, "taskExecutor");
    assertNotNull(taskExecutor);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:ContextResourceLoaderAutoConfigurationTest.java


示例9: getStateMachineConfiguration

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
protected MachineConfiguration<S, E> getStateMachineConfiguration() {
    StateMachineConfigurationBuilder<S, E> configurationBuilder =
            new StateMachineConfigurationBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineStateBuilder<S, E> stateBuilder =
            new StateMachineStateBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineTransitionBuilder<S, E> transitionBuilder =
            new StateMachineTransitionBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineListener<S, E> listener =
            new StateMachineListenerAdapter<S, E>() {
                @Override
                public void stateChanged(State<S, E> from, State<S, E> to) {
                    LOGGER.debug("state changed from {} to {}", from, to);
                }

                @Override
                public void eventNotAccepted(Message<E> event) {
                    LOGGER.error("{} not accepted event: {}", getClass().getSimpleName(), event);
                }
            };
    return new MachineConfiguration<>(configurationBuilder, stateBuilder, transitionBuilder, listener, new SyncTaskExecutor());
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:22,代码来源:AbstractFlowConfiguration.java


示例10: setup

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    underTest = spy(new TestAction());
    underTest.setFailureEvent(Event.FAILURE);
    MockitoAnnotations.initMocks(this);
    BDDMockito.given(flow.getFlowId()).willReturn(FLOW_ID);
    BDDMockito.given(runningFlows.get(anyString())).willReturn(flow);
    StateMachineConfigurationBuilder<State, Event> configurationBuilder =
            new StateMachineConfigurationBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    configurationBuilder.setTaskExecutor(new SyncTaskExecutor());
    StateMachineStateBuilder<State, Event> stateBuilder =
            new StateMachineStateBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    stateBuilder.withStates().initial(State.INIT).state(State.DOING, underTest, null);
    StateMachineTransitionBuilder<State, Event> transitionBuilder =
            new StateMachineTransitionBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    transitionBuilder.withExternal().source(State.INIT).target(State.DOING).event(Event.DOIT);
    stateMachine = new ObjectStateMachineFactory<>(configurationBuilder.build(), transitionBuilder.build(), stateBuilder.build()).getStateMachine();
    stateMachine.start();
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:20,代码来源:AbstractActionTest.java


示例11: getStateMachineConfiguration

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Override
protected FlowConfiguration.MachineConfiguration<State, Event> getStateMachineConfiguration() {
    StateMachineConfigurationBuilder<State, Event> configurationBuilder =
            new StateMachineConfigurationBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineStateBuilder<State, Event> stateBuilder =
            new StateMachineStateBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineTransitionBuilder<State, Event> transitionBuilder =
            new StateMachineTransitionBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineListener<State, Event> listener =
            new StateMachineListenerAdapter<State, Event>() {
                @Override
                public void eventNotAccepted(Message<Event> event) {
                    throw new NotAcceptedException();
                }
            };
    return new FlowConfiguration.MachineConfiguration<State, Event>(configurationBuilder, stateBuilder, transitionBuilder, listener,
            new SyncTaskExecutor());
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:19,代码来源:AbstractFlowConfigurationTest.java


示例12: main

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
  ClassPathXmlApplicationContext c = new ClassPathXmlApplicationContext(
      "billing_job.xml");
  SimpleJobLauncher launcher = new SimpleJobLauncher();
  launcher.setJobRepository((JobRepository) c.getBean("jobRepository"));
  launcher.setTaskExecutor(new SyncTaskExecutor());
  try {
    Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
    parameters.put(RUN_MONTH_KEY, new JobParameter("2011-2"));
    JobExecution je = launcher.run((Job) c.getBean("billingJob"),
        new JobParameters(parameters));
    System.out.println(je);
    System.out.println(je.getJobInstance());
    System.out.println(je.getStepExecutions());
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:kevin-ww,项目名称:text.classfication,代码行数:22,代码来源:Main2.java


示例13: main

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
public static void main(String[] args) {
  ClassPathXmlApplicationContext c = new ClassPathXmlApplicationContext(
      "message_job.xml");
  SimpleJobLauncher launcher = new SimpleJobLauncher();
  launcher.setJobRepository((JobRepository) c.getBean("jobRepository"));
  launcher.setTaskExecutor(new SyncTaskExecutor());
  try {
    Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
    parameters.put(RUN_MONTH_KEY, new JobParameter("2011-10"));
    JobExecution je = launcher.run((Job) c.getBean("messageJob"),
        new JobParameters(parameters));
    System.out.println(je);
    System.out.println(je.getJobInstance());
    System.out.println(je.getStepExecutions());
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:kevin-ww,项目名称:text.classfication,代码行数:19,代码来源:Main.java


示例14: connect

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
private ListenableFuture<WebSocketSession> connect(RestOperations restTemplate, ClientHttpResponse... responses)
		throws Exception {

	RestTemplateXhrTransport transport = new RestTemplateXhrTransport(restTemplate);
	transport.setTaskExecutor(new SyncTaskExecutor());

	SockJsUrlInfo urlInfo = new SockJsUrlInfo(new URI("http://example.com"));
	HttpHeaders headers = new HttpHeaders();
	headers.add("h-foo", "h-bar");
	TransportRequest request = new DefaultTransportRequest(urlInfo, headers, headers,
			transport, TransportType.XHR, CODEC);

	return transport.connect(request, this.webSocketHandler);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:RestTemplateXhrTransportTests.java


示例15: getJobLauncher

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Override
public JobLauncher getJobLauncher() throws Exception {
	SimpleJobLauncher launcher = new SimpleJobLauncher();
	launcher.setJobRepository(this.jobRepository);
	launcher.setTaskExecutor(new SyncTaskExecutor());
	return launcher;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:JobLauncherCommandLineRunnerTests.java


示例16: buildMachine

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
public StateMachine<States, Events> buildMachine() throws Exception {
    StateMachineBuilder.Builder<States, Events> builder = StateMachineBuilder.builder();

    builder.configureConfiguration()
           .withConfiguration()
           .taskExecutor(new SyncTaskExecutor())
    ;

    builder.configureStates()
           .withStates()
           .initial(States.SI)
           .state(States.S1, new Action<States, Events>() {
               @Override
               public void execute(StateContext<States, Events> context) {
                   System.out.print("test");
               }
           }, null)
           .states(EnumSet.allOf(States.class))
    ;

    builder.configureTransitions()
           .withExternal()
           .source(States.SI).target(States.S1)
           .event(Events.E1)
           .and()
           .withLocal()
           .source(States.S2).target(States.S3)
           .event(Events.E1)
           .and()
           .withExternal()
           .source(States.S2).target(States.SE)
           .event(Events.E2)
           .and()
           .withExternal()
           .source(States.S1).target(States.SE)
           .event(Events.E2);

    return builder.build();
}
 
开发者ID:WorkingDevelopers,项目名称:spring-state-machine-chart-dumper,代码行数:40,代码来源:T1.java


示例17: buildUmlMachine

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
public StateMachine<String, String> buildUmlMachine(String aPath) throws Exception {
    StateMachineBuilder.Builder<String, String> builder = StateMachineBuilder.builder();

    builder.configureModel().withModel().factory(new UmlStateMachineModelFactory(
            aPath
    ));
    builder.configureConfiguration()
           .withConfiguration()
           .taskExecutor(new SyncTaskExecutor())
    ;
    return builder.build();
}
 
开发者ID:WorkingDevelopers,项目名称:spring-state-machine-chart-dumper,代码行数:13,代码来源:SMHierarch1.java


示例18: setUp

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Before
public void setUp() throws ServiceInstanceExistsException,
		ServiceBrokerException {
	MockitoAnnotations.initMocks(this);
	service = new LCServiceInstanceService(copyProvider, dataProvider,
			"source_instance_id", brokerRepo, instanceManager,
			new SyncTaskExecutor(), dataProviderService);

}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:10,代码来源:LCServiceInstanceServiceCopyTest.java


示例19: testSingleThreaded

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Test
public void testSingleThreaded() throws Exception {
    respondSuccess(NUMBER_OF_EMPLOYEES);

    setExecutor(new SyncTaskExecutor());
    jobExecution = jobLauncher.run(job, jobParams);
    printExecutionTime("SingleThreaded", jobExecution);
}
 
开发者ID:cegeka,项目名称:batchers,代码行数:9,代码来源:ThreadedPerformanceTest.java


示例20: exists_withExistingObjectMetadata_returnsTrue

import org.springframework.core.task.SyncTaskExecutor; //导入依赖的package包/类
@Test
public void exists_withExistingObjectMetadata_returnsTrue() throws Exception {
    //Arrange
    AmazonS3 amazonS3 = mock(AmazonS3.class);
    when(amazonS3.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(new ObjectMetadata());

    //Act
    SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucket", "object", new SyncTaskExecutor());

    //Assert
    assertTrue(simpleStorageResource.exists());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:13,代码来源:SimpleStorageResourceTest.java



注:本文中的org.springframework.core.task.SyncTaskExecutor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ByteCode类代码示例发布时间:2022-05-21
下一篇:
Java IInfoProvider类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap