Java Code Examples for org.springframework.beans.factory.InitializingBean#afterPropertiesSet()

The following examples show how to use org.springframework.beans.factory.InitializingBean#afterPropertiesSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExceptionHandlingAsyncTaskExecutor.java    From gpmr with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 2
Source File: ExceptionHandlingAsyncTaskExecutor.java    From expper with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 3
Source File: MQHierachy.java    From Thunder with Apache License 2.0 5 votes vote down vote up
public void afterPropertiesSet() throws Exception {
    if (connectionFactory instanceof InitializingBean) {
        InitializingBean initializingBean = (InitializingBean) connectionFactory;
        initializingBean.afterPropertiesSet();
    }
    mqTemplate.afterPropertiesSet();
}
 
Example 4
Source File: MQConnectionHierachy.java    From Thunder with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("incomplete-switch")
@Override
public void initialize() throws Exception {
    super.initialize();

    String initialConnectionFactoryClass = mqPropertyEntity.getMQEntity().getInitialConnectionFactoryClass();
    String url = mqPropertyEntity.getString(ThunderConstant.MQ_URL_ATTRIBUTE_NAME);
    String userName = mqPropertyEntity.getString(ThunderConstant.MQ_USER_NAME_ATTRIBUTE_NAME);
    String password = mqPropertyEntity.getString(ThunderConstant.MQ_PASSWORD_ATTRIBUTE_NAME);

    ConnectionFactory targetConnectionFactory = ClassUtil.createInstance(initialConnectionFactoryClass);

    switch (protocolType) {
        case ACTIVE_MQ:
            ClassUtil.invoke(targetConnectionFactory, "setBrokerURL", new Class<?>[] { String.class }, new Object[] { url });
            ClassUtil.invoke(targetConnectionFactory, "setUserName", new Class<?>[] { String.class }, new Object[] { userName });
            ClassUtil.invoke(targetConnectionFactory, "setPassword", new Class<?>[] { String.class }, new Object[] { password });
            break;
        case TIBCO:
            ClassUtil.invoke(targetConnectionFactory, "setServerUrl", new Class<?>[] { String.class }, new Object[] { url });
            ClassUtil.invoke(targetConnectionFactory, "setUserName", new Class<?>[] { String.class }, new Object[] { userName });
            ClassUtil.invoke(targetConnectionFactory, "setUserPassword", new Class<?>[] { String.class }, new Object[] { password });
            break;
    }

    if (targetConnectionFactory instanceof InitializingBean) {
        InitializingBean initializingBean = (InitializingBean) targetConnectionFactory;
        initializingBean.afterPropertiesSet();
    }

    setTargetConnectionFactory(targetConnectionFactory);

    afterPropertiesSet();
}
 
Example 5
Source File: ExceptionHandlingAsyncTaskExecutor.java    From ServiceCutter with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 6
Source File: ExceptionHandlingAsyncTaskExecutor.java    From angularjs-springboot-bookstore with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 7
Source File: ExceptionHandlingAsyncTaskExecutor.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 8
Source File: ExceptionHandlingAsyncTaskExecutor.java    From OpenIoE with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 9
Source File: AsyncExceptionHandlingAsyncTaskExecutor.java    From cola-cloud with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 10
Source File: ExceptionHandlingAsyncTaskExecutor.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 11
Source File: _ExceptionHandlingAsyncTaskExecutor.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 12
Source File: ExceptionHandlingAsyncTaskExecutor.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 13
Source File: ExceptionHandlingAsyncTaskExecutor.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 14
Source File: ExceptionHandlingAsyncTaskExecutor.java    From klask-io with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 15
Source File: ExceptionHandlingAsyncTaskExecutor.java    From albedo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	if (this.executor instanceof InitializingBean) {
		InitializingBean bean = (InitializingBean) this.executor;
		bean.afterPropertiesSet();
	}

}
 
Example 16
Source File: ExceptionHandlingAsyncTaskExecutor.java    From paascloud-master with Apache License 2.0 5 votes vote down vote up
/**
 * After properties set.
 *
 * @throws Exception the exception
 */
@Override
public void afterPropertiesSet() throws Exception {
	if (executor instanceof InitializingBean) {
		InitializingBean bean = (InitializingBean) executor;
		bean.afterPropertiesSet();
	}
}
 
Example 17
Source File: FunctionBindingTestUtils.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
public static void bind(ConfigurableApplicationContext applicationContext, Object function) {
	try {
		Object targetFunction = function;
		if (function instanceof FunctionRegistration) {
			targetFunction = ((FunctionRegistration) function).getTarget();
		}
		String functionName = targetFunction instanceof Function ? "function" : (targetFunction instanceof Consumer ? "consumer" : "supplier");

		System.setProperty("spring.cloud.function.definition", functionName);
		applicationContext.getBeanFactory().registerSingleton(functionName, function);

		Object actualFunction =  ((FunctionInvocationWrapper) applicationContext
				.getBean(FunctionCatalog.class).lookup(functionName)).getTarget();

		InitializingBean functionBindingRegistrar = applicationContext.getBean("functionBindingRegistrar", InitializingBean.class);
		functionBindingRegistrar.afterPropertiesSet();

		BindableProxyFactory bindingProxy = applicationContext.getBean("&" + functionName + "_binding", BindableProxyFactory.class);
		bindingProxy.afterPropertiesSet();

		InitializingBean functionBinder = applicationContext.getBean("functionInitializer", InitializingBean.class);
		functionBinder.afterPropertiesSet();

		BindingServiceProperties bindingProperties = applicationContext.getBean(BindingServiceProperties.class);
		String inputBindingName = functionName + "-in-0";
		String outputBindingName = functionName + "-out-0";
		Map<String, BindingProperties> bindings = bindingProperties.getBindings();
		BindingProperties inputProperties = bindings.get(inputBindingName);
		BindingProperties outputProperties = bindings.get(outputBindingName);
		ConsumerProperties consumerProperties = inputProperties.getConsumer();
		ProducerProperties producerProperties = outputProperties.getProducer();

		TestChannelBinder binder = applicationContext.getBean(TestChannelBinder.class);
		if (actualFunction instanceof Supplier || actualFunction instanceof Function) {
			Binding<MessageChannel> bindProducer = binder.bindProducer(outputProperties.getDestination(),
					applicationContext.getBean(outputBindingName, MessageChannel.class),
					producerProperties == null ? new ProducerProperties() : producerProperties);
			bindProducer.start();
		}
		if (actualFunction instanceof Consumer || actualFunction instanceof Function) {
			Binding<MessageChannel> bindConsumer = binder.bindConsumer(inputProperties.getDestination(), null,
					applicationContext.getBean(inputBindingName, MessageChannel.class),
					consumerProperties == null ? new ConsumerProperties() : consumerProperties);
			bindConsumer.start();
		}
	}
	catch (Exception e) {
		throw new IllegalStateException("Failed to bind function", e);
	}
	finally {
		System.clearProperty("spring.cloud.function.definition");
	}
}