下面列出了org.springframework.beans.factory.InitializingBean#afterPropertiesSet ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
/**
* After properties set.
*
* @throws Exception the exception
*/
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (this.executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) this.executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
/** {@inheritDoc} */
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@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();
}
public void afterPropertiesSet() throws Exception {
if (connectionFactory instanceof InitializingBean) {
InitializingBean initializingBean = (InitializingBean) connectionFactory;
initializingBean.afterPropertiesSet();
}
mqTemplate.afterPropertiesSet();
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
@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");
}
}