org.springframework.beans.factory.InitializingBean Java Examples

The following examples show how to use org.springframework.beans.factory.InitializingBean. 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: HdfsTextItemWriterFactory.java    From spring-cloud-task-app-starters with Apache License 2.0 6 votes vote down vote up
public HdfsTextItemWriterFactory(Configuration configuration, JdbcHdfsTaskProperties props,
		String partitionSuffix ) throws Exception{
	List<FileNamingStrategy> strategies = new ArrayList<>();
	strategies.add(new StaticFileNamingStrategy(props.getFileName() + partitionSuffix));
	strategies.add(new RollingFileNamingStrategy());
	strategies.add(new StaticFileNamingStrategy(props.getFileExtension(), "."));
	ChainedFileNamingStrategy fileNamingStrategy = new ChainedFileNamingStrategy();
	fileNamingStrategy.setStrategies(strategies);
	RolloverStrategy rolloverStrategy = new SizeRolloverStrategy(props.getRollover());
	Path baseDirPath = new Path(props.getDirectory());
	setupConfiguration(configuration, props);
	OutputStreamWriter writer = new OutputStreamWriter(configuration, baseDirPath, null);
	writer.setInWritingSuffix(".tmp");
	writer.setFileNamingStrategy(fileNamingStrategy);
	writer.setRolloverStrategy(rolloverStrategy);
	hdfsTextItemWriter = new HdfsTextItemWriter();
	hdfsTextItemWriter.setLineAggregator(new org.springframework.batch.item.file.transform.PassThroughLineAggregator());
	hdfsTextItemWriter.setStoreWriter(writer);
	if (writer instanceof InitializingBean) {
		((InitializingBean) writer).afterPropertiesSet();
	}

}
 
Example #2
Source File: AdapterDelegate.java    From tddl5 with Apache License 2.0 6 votes vote down vote up
private TimestampPair createAdapter(String ip, int port, String user, String password) {
    CobarAdapter adapter = null;
    try {
        DataSource ds = dsFactory.createDataSource(ip, port, user, password);
        adapter = new CobarAdapter();
        adapter.setDataSource(ds);
        ((InitializingBean) adapter).afterPropertiesSet();
        return new TimestampPair(adapter);
    } catch (Exception exception) {
        logger.error("ip=" + ip + ", port=" + port, exception);
        try {
            adapter.destroy();
        } catch (Exception e) {
        }
        throw new RuntimeException(exception);
    }
}
 
Example #3
Source File: JmsListenerEndpointRegistry.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Create and start a new container using the specified factory.
 */
protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint,
		JmsListenerContainerFactory<?> factory) {

	MessageListenerContainer listenerContainer = factory.createListenerContainer(endpoint);

	if (listenerContainer instanceof InitializingBean) {
		try {
			((InitializingBean) listenerContainer).afterPropertiesSet();
		}
		catch (Exception ex) {
			throw new BeanInitializationException("Failed to initialize message listener container", ex);
		}
	}

	int containerPhase = listenerContainer.getPhase();
	if (containerPhase < Integer.MAX_VALUE) {  // a custom phase value
		if (this.phase < Integer.MAX_VALUE && this.phase != containerPhase) {
			throw new IllegalStateException("Encountered phase mismatch between container factory definitions: " +
					this.phase + " vs " + containerPhase);
		}
		this.phase = listenerContainer.getPhase();
	}

	return listenerContainer;
}
 
Example #4
Source File: StandaloneMockMvcBuilder.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
	if (handlerExceptionResolvers == null) {
		return;
	}
	for (HandlerExceptionResolver resolver : handlerExceptionResolvers) {
		if (resolver instanceof ApplicationContextAware) {
			((ApplicationContextAware) resolver).setApplicationContext(getApplicationContext());
		}
		if (resolver instanceof InitializingBean) {
			try {
				((InitializingBean) resolver).afterPropertiesSet();
			}
			catch (Exception ex) {
				throw new IllegalStateException("Failure from afterPropertiesSet", ex);
			}
		}
		exceptionResolvers.add(resolver);
	}
}
 
Example #5
Source File: JmsListenerEndpointRegistry.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Create and start a new container using the specified factory.
 */
protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint,
		JmsListenerContainerFactory<?> factory) {

	MessageListenerContainer listenerContainer = factory.createListenerContainer(endpoint);

	if (listenerContainer instanceof InitializingBean) {
		try {
			((InitializingBean) listenerContainer).afterPropertiesSet();
		}
		catch (Exception ex) {
			throw new BeanInitializationException("Failed to initialize message listener container", ex);
		}
	}

	int containerPhase = listenerContainer.getPhase();
	if (containerPhase < Integer.MAX_VALUE) {  // a custom phase value
		if (this.phase < Integer.MAX_VALUE && this.phase != containerPhase) {
			throw new IllegalStateException("Encountered phase mismatch between container factory definitions: " +
					this.phase + " vs " + containerPhase);
		}
		this.phase = listenerContainer.getPhase();
	}

	return listenerContainer;
}
 
Example #6
Source File: StandaloneMockMvcBuilder.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
	if (handlerExceptionResolvers == null) {
		return;
	}
	for (HandlerExceptionResolver resolver : handlerExceptionResolvers) {
		if (resolver instanceof ApplicationContextAware) {
			ApplicationContext applicationContext  = getApplicationContext();
			if (applicationContext != null) {
				((ApplicationContextAware) resolver).setApplicationContext(applicationContext);
			}
		}
		if (resolver instanceof InitializingBean) {
			try {
				((InitializingBean) resolver).afterPropertiesSet();
			}
			catch (Exception ex) {
				throw new IllegalStateException("Failure from afterPropertiesSet", ex);
			}
		}
		exceptionResolvers.add(resolver);
	}
}
 
Example #7
Source File: Application.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Bean
InitializingBean usersAndGroupsInitializer(final IdentityService identityService) {

    return new InitializingBean() {
        @Override
        public void afterPropertiesSet() throws Exception {

            // install groups & users
            Group group = identityService.newGroup("user");
            group.setName("users");
            group.setType("security-role");
            identityService.saveGroup(group);

            User josh = identityService.newUser("jlong");
            josh.setFirstName("Josh");
            josh.setLastName("Long");
            josh.setPassword("password");
            identityService.saveUser(josh);

            identityService.createMembership("jlong", "user");
        }
    };
}
 
Example #8
Source File: ClientHttpCorrelationConfiguration.java    From request-correlation-spring-cloud-starter with Apache License 2.0 6 votes vote down vote up
@Bean
public InitializingBean clientsCorrelationInitializer(final RequestCorrelationProperties properties) {

    return new InitializingBean() {
        @Override
        public void afterPropertiesSet() throws Exception {

            if(clients != null) {
                for(InterceptingHttpAccessor client : clients) {
                    final List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(client.getInterceptors());
                    interceptors.add(new ClientHttpRequestCorrelationInterceptor(properties));
                    client.setInterceptors(interceptors);
                }
            }
        }
    };
}
 
Example #9
Source File: AppUI.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Object instance, ApplicationContext applicationContext) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to initialize UI Component - calling afterPropertiesSet for " +
                            instance.getClass(), e);
        }
    }
}
 
Example #10
Source File: WebAbstractDataGrid.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Renderer instance) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException("Unable to initialize Renderer - calling afterPropertiesSet for " +
                    instance.getClass(), e);
        }
    }
}
 
Example #11
Source File: DesktopComponentsFactory.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Component instance) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to initialize Component - calling afterPropertiesSet for " +
                            instance.getClass());
        }
    }
}
 
Example #12
Source File: StandaloneMockMvcBuilder.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
	if (handlerExceptionResolvers == null) {
		return;
	}
	for (HandlerExceptionResolver resolver : handlerExceptionResolvers) {
		if (resolver instanceof ApplicationContextAware) {
			ApplicationContext applicationContext = getApplicationContext();
			if (applicationContext != null) {
				((ApplicationContextAware) resolver).setApplicationContext(applicationContext);
			}
		}
		if (resolver instanceof InitializingBean) {
			try {
				((InitializingBean) resolver).afterPropertiesSet();
			}
			catch (Exception ex) {
				throw new IllegalStateException("Failure from afterPropertiesSet", ex);
			}
		}
		exceptionResolvers.add(resolver);
	}
}
 
Example #13
Source File: ActionsImpl.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void autowireContext(Action instance) {
    AutowireCapableBeanFactory autowireBeanFactory = applicationContext.getAutowireCapableBeanFactory();
    autowireBeanFactory.autowireBean(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }

    if (instance instanceof InitializingBean) {
        try {
            ((InitializingBean) instance).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to initialize UI Component - calling afterPropertiesSet for " +
                            instance.getClass(), e);
        }
    }
}
 
Example #14
Source File: TaskExecutorFactoryBean.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	BeanWrapper bw = new BeanWrapperImpl(ThreadPoolTaskExecutor.class);
	determinePoolSizeRange(bw);
	if (this.queueCapacity != null) {
		bw.setPropertyValue("queueCapacity", this.queueCapacity);
	}
	if (this.keepAliveSeconds != null) {
		bw.setPropertyValue("keepAliveSeconds", this.keepAliveSeconds);
	}
	if (this.rejectedExecutionHandler != null) {
		bw.setPropertyValue("rejectedExecutionHandler", this.rejectedExecutionHandler);
	}
	if (this.beanName != null) {
		bw.setPropertyValue("threadNamePrefix", this.beanName + "-");
	}
	this.target = (TaskExecutor) bw.getWrappedInstance();
	if (this.target instanceof InitializingBean) {
		((InitializingBean) this.target).afterPropertiesSet();
	}
}
 
Example #15
Source File: ActivitiSpringSecurityApplication.java    From tutorials with MIT License 5 votes vote down vote up
@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)));
        }
    };
}
 
Example #16
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 #17
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 #18
Source File: SecurityAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean
InitializingBean init(
        final IdmIdentityService identityService) {
    return new InitializingBean() {

        @Override
        public void afterPropertiesSet() throws Exception {
            // We have to use different names than from the CommandLineRunner. The reason is that during
            // testing we are using an in memory database that is not linked to the application context
            // but it lives in the JVM

            // install groups & users
            Group userGroup = group("user2");
            Group adminGroup = group("admin2");
            Privilege userPrivilege = privilege("userPrivilege2");
            Privilege adminPrivilege = privilege("adminPrivilege2");
            identityService.addGroupPrivilegeMapping(userPrivilege.getId(), userGroup.getId());

            User joram = user("jbarrez2", "Joram", "Barrez");
            identityService.createMembership(joram.getId(), userGroup.getId());
            identityService.createMembership(joram.getId(), adminGroup.getId());
            identityService.addUserPrivilegeMapping(adminPrivilege.getId(), joram.getId());

            User josh = user("jlong2", "Josh", "Long");
            identityService.createMembership(josh.getId(), userGroup.getId());
        }
    };
}
 
Example #19
Source File: TestRestTemplateFactory.java    From spring-cloud-vault with Apache License 2.0 5 votes vote down vote up
private static void initializeClientHttpRequestFactory(
		SslConfiguration sslConfiguration) throws Exception {

	if (factoryCache.get() != null) {
		return;
	}

	final ClientHttpRequestFactory clientHttpRequestFactory = ClientHttpRequestFactoryFactory
			.create(new ClientOptions(), sslConfiguration);

	if (factoryCache.compareAndSet(null, clientHttpRequestFactory)) {

		if (clientHttpRequestFactory instanceof InitializingBean) {
			((InitializingBean) clientHttpRequestFactory).afterPropertiesSet();
		}

		if (clientHttpRequestFactory instanceof DisposableBean) {

			Runtime.getRuntime().addShutdownHook(
					new Thread("ClientHttpRequestFactory Shutdown Hook") {

						@Override
						public void run() {
							try {
								((DisposableBean) clientHttpRequestFactory).destroy();
							}
							catch (Exception e) {
								e.printStackTrace();
							}
						}
					});
		}
	}
}
 
Example #20
Source File: RegistryRepository.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
private void processNew(RegistryService service, String name) {
    if (service instanceof AbstractV2RegistryService) {
        ((AbstractV2RegistryService) service).setEventConsumer(this::dispatchEvent);
    }
    if (service instanceof InitializingBean) {
        try {
            ((InitializingBean) service).afterPropertiesSet();
        } catch (Exception e) {
            log.error("Can not init repository: \"{}\"", name, e);
        }
    }
}
 
Example #21
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 #22
Source File: AbstractRemoteEventTest.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
    final BusJacksonAutoConfiguration autoConfiguration = new BusJacksonAutoConfiguration();
    this.jacksonMessageConverter = autoConfiguration.busJsonConverter(null);
    ReflectionTestUtils.setField(jacksonMessageConverter, "packagesToScan",
            new String[] { "org.eclipse.hawkbit.repository.event.remote",
                    ClassUtils.getPackageName(RemoteApplicationEvent.class) });
    ((InitializingBean) jacksonMessageConverter).afterPropertiesSet();

}
 
Example #23
Source File: ClientHttpRequestFactoryFactoryIntegrationTests.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
@Test
void nettyClientShouldWork() throws Exception {

	ClientHttpRequestFactory factory = Netty.usingNetty(new ClientOptions(), Settings.createSslConfiguration());
	((InitializingBean) factory).afterPropertiesSet();
	RestTemplate template = new RestTemplate(factory);

	String response = request(template);

	assertThat(factory).isInstanceOf(Netty4ClientHttpRequestFactory.class);
	assertThat(response).isNotNull().contains("initialized");

	((DisposableBean) factory).destroy();
}
 
Example #24
Source File: AbstractVaultConfiguration.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {

	if (this.clientHttpRequestFactory instanceof InitializingBean) {
		((InitializingBean) this.clientHttpRequestFactory).afterPropertiesSet();
	}
}
 
Example #25
Source File: SpringBootJournalApplication.java    From pro-spring-boot with Apache License 2.0 5 votes vote down vote up
@Bean
InitializingBean saveData(JournalRepository repo){
	return () -> {
		repo.save(new Journal("Get to know Spring Boot","Today I will learn Spring Boot","01/01/2016"));
		repo.save(new Journal("Simple Spring Boot Project","I will do my first Spring Boot Project","01/02/2016"));
		repo.save(new Journal("Spring Boot Reading","Read more about Spring Boot","02/01/2016"));
		repo.save(new Journal("Spring Boot in the Cloud","Spring Boot using Cloud Foundry","03/01/2016"));
	};
}
 
Example #26
Source File: AbstractAsyncHttpRequestFactoryTestCase.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public final void createFactory() throws Exception {
	this.factory = createRequestFactory();
	if (this.factory instanceof InitializingBean) {
		((InitializingBean) this.factory).afterPropertiesSet();
	}
}
 
Example #27
Source File: ProtocolPluginManagerImpl.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
@Override
public ProtocolProvider create(String type, ApplicationContext parentContext) {
    logger.debug("Looking for an protocol provider for [{}]", type);
    Protocol protocol = protocols.get(type);
    if (protocol != null) {
        try {
            ProtocolProvider protocolProvider = createInstance(protocol.protocolProvider());
            Plugin plugin = protocolPlugins.get(protocol);

            AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
            context.setParent(parentContext);
            context.setClassLoader(pluginClassLoaderFactory.getOrCreateClassLoader(plugin));
            context.setEnvironment((ConfigurableEnvironment) parentContext.getEnvironment());

            PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
            configurer.setIgnoreUnresolvablePlaceholders(true);
            configurer.setEnvironment(parentContext.getEnvironment());
            context.addBeanFactoryPostProcessor(configurer);

            context.register(protocol.configuration());
            context.registerBeanDefinition(plugin.clazz(), BeanDefinitionBuilder.rootBeanDefinition(plugin.clazz()).getBeanDefinition());
            context.refresh();

            context.getAutowireCapableBeanFactory().autowireBean(protocolProvider);

            if (protocolProvider instanceof InitializingBean) {
                ((InitializingBean) protocolProvider).afterPropertiesSet();
            }
            return protocolProvider;
        } catch (Exception ex) {
            logger.error("An unexpected error occurs while loading protocol", ex);
            return null;
        }
    } else {
        logger.error("No protocol provider is registered for type {}", type);
        throw new IllegalStateException("No protocol provider is registered for type " + type);
    }
}
 
Example #28
Source File: AbstractAutowireCapableBeanFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Give a bean a chance to react now all its properties are set,
 * and a chance to know about its owning bean factory (this object).
 * This means checking whether the bean implements InitializingBean or defines
 * a custom init method, and invoking the necessary callback(s) if it does.
 * @param beanName the bean name in the factory (for debugging purposes)
 * @param bean the new bean instance we may need to initialize
 * @param mbd the merged bean definition that the bean was created with
 * (can also be {@code null}, if given an existing bean instance)
 * @throws Throwable if thrown by init methods or by the invocation process
 * @see #invokeCustomInitMethod
 */
protected void invokeInitMethods(String beanName, final Object bean, RootBeanDefinition mbd)
		throws Throwable {

	boolean isInitializingBean = (bean instanceof InitializingBean);
	if (isInitializingBean && (mbd == null || !mbd.isExternallyManagedInitMethod("afterPropertiesSet"))) {
		if (logger.isDebugEnabled()) {
			logger.debug("Invoking afterPropertiesSet() on bean with name '" + beanName + "'");
		}
		if (System.getSecurityManager() != null) {
			try {
				AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
					@Override
					public Object run() throws Exception {
						((InitializingBean) bean).afterPropertiesSet();
						return null;
					}
				}, getAccessControlContext());
			}
			catch (PrivilegedActionException pae) {
				throw pae.getException();
			}
		}
		else {
			((InitializingBean) bean).afterPropertiesSet();
		}
	}

	if (mbd != null) {
		String initMethodName = mbd.getInitMethodName();
		if (initMethodName != null && !(isInitializingBean && "afterPropertiesSet".equals(initMethodName)) &&
				!mbd.isExternallyManagedInitMethod(initMethodName)) {
			invokeCustomInitMethod(beanName, bean, mbd);
		}
	}
}
 
Example #29
Source File: ViewResolverComposite.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	for (ViewResolver viewResolver : this.viewResolvers) {
		if (viewResolver instanceof InitializingBean) {
			((InitializingBean) viewResolver).afterPropertiesSet();
		}
	}
}
 
Example #30
Source File: AbstractHttpRequestFactoryTestCase.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public final void createFactory() throws Exception {
	factory = createRequestFactory();
	if (factory instanceof InitializingBean) {
		((InitializingBean) factory).afterPropertiesSet();
	}
}