@Override public void start() { if (this.gatherEndpoint != null) { this.gatherEndpoint.start(); } }
@Override // guarded by super#lifecycleLock protected void doStop() { if (this.replyMessageCorrelator != null) { this.replyMessageCorrelator.stop(); } }
@Override protected void onInit() { super.onInit(); if (!this.autoStartupSetExplicitly) { String[] endpointNamePatterns = getIntegrationProperty(IntegrationProperties.ENDPOINTS_NO_AUTO_STARTUP, String[].class); for (String pattern : endpointNamePatterns) { if (PatternMatchUtils.simpleMatch(pattern, getComponentName())) { this.autoStartup = false; break; } } } if (StringUtils.hasText(this.role)) { try { this.roleController = getBeanFactory() .getBean(IntegrationContextUtils.INTEGRATION_LIFECYCLE_ROLE_CONTROLLER, SmartLifecycleRoleController.class); this.roleController.addLifecycleToRole(this.role, this); } catch (NoSuchBeanDefinitionException e) { this.logger.trace("No LifecycleRoleController in the context"); } } }
@Test public void methodInvokingFilterRejects() { this.input.send(new GenericMessage<String>("foo")); Message<?> reply = this.output.receive(0); assertNull(reply); assertTrue(this.testBean.isRunning()); this.pojoFilter.stop(); assertFalse(this.testBean.isRunning()); this.pojoFilter.start(); assertTrue(this.testBean.isRunning()); }
this.subscriberIds.add(clientId); synchronized (this.consumerEndpoint) { if (!this.consumerEndpoint.isRunning()) { this.consumerEndpoint.start(); this.subscriberIds.remove(clientId); synchronized (this.consumerEndpoint) { if (this.subscriberIds.isEmpty() && this.consumerEndpoint.isRunning()) { this.consumerEndpoint.stop();
this.endpoint = new ReactiveStreamsConsumer(channel, this.handler); this.endpoint.setBeanName(this.beanName); this.endpoint.setBeanFactory(this.beanFactory); if (this.autoStartup != null) { this.endpoint.setAutoStartup(this.autoStartup); this.endpoint.setPhase(phaseToSet); this.endpoint.setRole(this.role); if (this.taskScheduler != null) { this.endpoint.setTaskScheduler(this.taskScheduler); this.endpoint.afterPropertiesSet(); this.initialized = true;
@Override public boolean isRunning() { return (this.endpoint != null) && this.endpoint.isRunning(); }
@Test public void testIntegrationContextComponents() { assertEquals("true", this.integrationProperties.get(IntegrationProperties.THROW_EXCEPTION_ON_LATE_REPLY)); assertEquals("20", this.integrationProperties.get(IntegrationProperties.TASK_SCHEDULER_POOL_SIZE)); assertEquals(this.integrationProperties, this.serviceActivator.getIntegrationProperties()); assertEquals(20, TestUtils.getPropertyValue(this.taskScheduler, "poolSize")); assertFalse(this.serviceActivator.isAutoStartup()); assertFalse(this.serviceActivator.isRunning()); assertTrue(this.serviceActivatorExplicit.isAutoStartup()); assertTrue(this.serviceActivatorExplicit.isRunning()); }
autoStartup = getBeanFactory().resolveEmbeddedValue(autoStartup); if (StringUtils.hasText(autoStartup)) { endpoint.setAutoStartup(Boolean.parseBoolean(autoStartup)); phase = getBeanFactory().resolveEmbeddedValue(phase); if (StringUtils.hasText(phase)) { endpoint.setPhase(Integer.parseInt(phase)); endpoint.setRole(role.value()); endpoint.setBeanName(endpointBeanName); getBeanFactory().registerSingleton(endpointBeanName, endpoint); getBeanFactory().initializeBean(endpoint, endpointBeanName);
endpoints.add(endpoint); this.context.getBeanFactory().registerSingleton("bridge-" + i, endpoint); endpoint.setComponentName("bridge-" + i); endpoint.afterPropertiesSet(); endpoints.get(i).start();
/** * Stop the component and invoke callback. * @param callback the Runnable to invoke. */ protected void doStop(Runnable callback) { doStop(); callback.run(); }
@Test //INT-2605 public void checkSmartLifecycleConfig() { ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( "ChainParserSmartLifecycleAttributesTest.xml", this.getClass()); AbstractEndpoint chainEndpoint = ctx.getBean("chain", AbstractEndpoint.class); assertEquals(false, chainEndpoint.isAutoStartup()); assertEquals(256, chainEndpoint.getPhase()); MessageHandlerChain handlerChain = ctx.getBean("chain.handler", MessageHandlerChain.class); assertEquals(3000L, TestUtils.getPropertyValue(handlerChain, "messagingTemplate.sendTimeout")); assertEquals(false, TestUtils.getPropertyValue(handlerChain, "running")); //INT-3108 MessageHandler serviceActivator = ctx.getBean("chain$child.sa-within-chain.handler", MessageHandler.class); assertTrue(TestUtils.getPropertyValue(serviceActivator, "requiresReply", Boolean.class)); ctx.close(); }
"unsupported channel type: [" + channel.getClass() + "]"); this.endpoint.setAutoStartup(this.autoStartup); this.endpoint.setBeanName(this.beanName); this.endpoint.setBeanFactory(this.beanFactory); if (this.endpoint instanceof InitializingBean) { ((InitializingBean) this.endpoint).afterPropertiesSet();
doUnregister(objectName); if (bean instanceof AbstractEndpoint) { this.endpointNames.remove(((AbstractEndpoint) bean).getComponentName());
@Override public void afterSingletonsInstantiated() { Map<String, AbstractEndpoint> endpoints = this.beanFactory.getBeansOfType(AbstractEndpoint.class); endpoints.entrySet() .stream() .filter(entry -> match(entry.getKey())) .forEach(entry -> entry.getValue().setAutoStartup(false)); }
@Override public boolean isAutoStartup() { return (this.endpoint == null) || this.endpoint.isAutoStartup(); }
@Override public int getPhase() { return (this.endpoint != null) ? this.endpoint.getPhase() : 0; }
@Test public void methodInvokingTransformer() { this.input.send(new GenericMessage<String>("foo")); Message<?> reply = this.output.receive(0); assertEquals("FOO", reply.getPayload()); assertEquals(1, adviceCalled); this.direct.send(new GenericMessage<String>("foo")); reply = this.output.receive(0); assertEquals("FOO", reply.getPayload()); StackTraceElement[] st = (StackTraceElement[]) reply.getHeaders().get("callStack"); assertEquals("doSend", st[6].getMethodName()); // no MethodInvokerHelper this.directRef.send(new GenericMessage<String>("foo")); reply = this.output.receive(0); assertEquals("FOO", reply.getPayload()); st = (StackTraceElement[]) reply.getHeaders().get("callStack"); assertEquals("doSend", st[6].getMethodName()); // no MethodInvokerHelper assertTrue(this.testBean.isRunning()); this.pojoTransformer.stop(); assertFalse(this.testBean.isRunning()); this.pojoTransformer.start(); assertTrue(this.testBean.isRunning()); this.directRef.send(new GenericMessage<String>("bar")); assertNull(this.output.receive(0)); }