use of org.springframework.beans.factory.InitializingBean in project tutorials by eugenp.
the class ActivitiSpringSecurityApplication method processEngineInitializer.
@Bean
InitializingBean processEngineInitializer() {
return new InitializingBean() {
public void afterPropertiesSet() throws Exception {
processEngineConfiguration.setUserEntityManager(new SpringSecurityUserManager(processEngineConfiguration, new MybatisUserDataManager(processEngineConfiguration), userManager));
processEngineConfiguration.setGroupEntityManager(new SpringSecurityGroupManager(processEngineConfiguration, new MybatisGroupDataManager(processEngineConfiguration)));
}
};
}
use of org.springframework.beans.factory.InitializingBean in project spring-cloud-stream by spring-cloud.
the class AbstractMessageChannelBinder method doBindConsumer.
/**
* Binds an inbound channel to a given destination. The implementation delegates to
* {@link ProvisioningProvider#provisionConsumerDestination(String, String, ConsumerProperties)}
* and
* {@link #createConsumerEndpoint(ConsumerDestination, String, ConsumerProperties)}
* for handling middleware-specific logic. If the returned consumer endpoint is an
* {@link InitializingBean} then {@link InitializingBean#afterPropertiesSet()} will be
* called on it. Similarly, if the returned consumer endpoint is a {@link Lifecycle},
* then {@link Lifecycle#start()} will be called on it.
* @param name the name of the destination
* @param group the consumer group
* @param inputChannel the channel to be bound
* @param properties the {@link ConsumerProperties} of the binding
* @return the Binding for the channel
* @throws BinderException on internal errors during binding
*/
@Override
public final Binding<MessageChannel> doBindConsumer(String name, String group, MessageChannel inputChannel, final C properties) throws BinderException {
MessageProducer consumerEndpoint = null;
try {
ConsumerDestination destination = this.provisioningProvider.provisionConsumerDestination(name, group, properties);
if (HeaderMode.embeddedHeaders.equals(properties.getHeaderMode())) {
enhanceMessageChannel(inputChannel);
}
consumerEndpoint = createConsumerEndpoint(destination, group, properties);
consumerEndpoint.setOutputChannel(inputChannel);
this.consumerCustomizer.configure(consumerEndpoint, name, group);
if (consumerEndpoint instanceof InitializingBean) {
((InitializingBean) consumerEndpoint).afterPropertiesSet();
}
if (properties.isAutoStartup() && consumerEndpoint instanceof Lifecycle) {
((Lifecycle) consumerEndpoint).start();
}
Binding<MessageChannel> binding = new DefaultBinding<MessageChannel>(name, group, inputChannel, consumerEndpoint instanceof Lifecycle ? (Lifecycle) consumerEndpoint : null) {
@Override
public Map<String, Object> getExtendedInfo() {
return doGetExtendedInfo(destination, properties);
}
@Override
public boolean isInput() {
return true;
}
@Override
protected void afterUnbind() {
try {
if (getEndpoint() instanceof DisposableBean) {
((DisposableBean) getEndpoint()).destroy();
}
} catch (Exception e) {
AbstractMessageChannelBinder.this.logger.error("Exception thrown while unbinding " + toString(), e);
}
afterUnbindConsumer(destination, this.group, properties);
destroyErrorInfrastructure(destination, this.group, properties);
}
};
doPublishEvent(new BindingCreatedEvent(binding));
return binding;
} catch (Exception e) {
if (consumerEndpoint instanceof Lifecycle) {
((Lifecycle) consumerEndpoint).stop();
}
if (e instanceof BinderException) {
throw (BinderException) e;
} else if (e instanceof ProvisioningException) {
throw (ProvisioningException) e;
} else {
throw new BinderException("Exception thrown while starting consumer: ", e);
}
}
}
Aggregations