@Override public void afterPropertiesSet() throws Exception { for (ViewResolver viewResolver : this.viewResolvers) { if (viewResolver instanceof InitializingBean) { ((InitializingBean) viewResolver).afterPropertiesSet(); } } }
@Override public void afterPropertiesSet() throws Exception { for (ViewResolver viewResolver : this.viewResolvers) { if (viewResolver instanceof InitializingBean) { ((InitializingBean) viewResolver).afterPropertiesSet(); } } }
@Override public Validator mvcValidator() { Validator mvcValidator = (validator != null) ? validator : super.mvcValidator(); if (mvcValidator instanceof InitializingBean) { try { ((InitializingBean) mvcValidator).afterPropertiesSet(); } catch (Exception ex) { throw new BeanInitializationException("Failed to initialize Validator", ex); } } return mvcValidator; }
@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); } } }
try { AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> { ((InitializingBean) bean).afterPropertiesSet(); return null; }, getAccessControlContext()); ((InitializingBean) bean).afterPropertiesSet();
/** * 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; }
@Before public final void createFactory() throws Exception { factory = createRequestFactory(); if (factory instanceof InitializingBean) { ((InitializingBean) factory).afterPropertiesSet(); } }
try { AccessController.doPrivileged((PrivilegedExceptionAction<Object>) () -> { ((InitializingBean) bean).afterPropertiesSet(); return null; }, getAccessControlContext()); ((InitializingBean) bean).afterPropertiesSet();
@Before public final void createFactory() throws Exception { this.factory = createRequestFactory(); if (this.factory instanceof InitializingBean) { ((InitializingBean) this.factory).afterPropertiesSet(); } }
((InitializingBean) am).afterPropertiesSet();
/** * Build a flow and inject it into the parent builder. The parent builder is then returned so it can be enhanced * before building an actual job. Normally called explicitly via {@link #end()}. * * @see org.springframework.batch.core.job.builder.FlowBuilder#build() */ @Override public FlowJobBuilder build() { Flow flow = flow(); if(flow instanceof InitializingBean) { try { ((InitializingBean) flow).afterPropertiesSet(); } catch (Exception e) { throw new FlowBuilderException(e); } } parent.flow(flow); return parent; }
@Before public void onSetUp()throws Exception{ itemReader = createItemReader(); getAsInitializingBean(itemReader).afterPropertiesSet(); executionContext = new ExecutionContext(); }
public Object run() throws Exception { ((InitializingBean) bean).afterPropertiesSet(); return null; } }, getAccessControlContext());
@Override protected T createInstance() { T instance = get(); if (instance instanceof InitializingBean) { try { ((InitializingBean) instance).afterPropertiesSet(); } catch (Exception e) { throw new IllegalStateException("Cannot initialize bean: " + instance, e); } } return instance; }
/** * Not thread safe. Only a single thread may add filters at a time. * <p> * Add the new filters to this CompositeFileListFilter while maintaining the existing filters. * * @param filtersToAdd a list of filters to add * @return this CompositeFileListFilter instance with the added filters */ public CompositeFileListFilter<F> addFilters(Collection<? extends FileListFilter<F>> filtersToAdd) { for (FileListFilter<F> elf : filtersToAdd) { if (elf instanceof DiscardAwareFileListFilter) { ((DiscardAwareFileListFilter<F>) elf).addDiscardCallback(this.discardCallback); } if (elf instanceof InitializingBean) { try { ((InitializingBean) elf).afterPropertiesSet(); } catch (Exception e) { throw new IllegalStateException(e); } } } this.fileFilters.addAll(filtersToAdd); return this; }
@Transactional @Test public void testNormalProcessing() throws Exception { getAsInitializingBean(itemReader).afterPropertiesSet(); getAsItemStream(itemReader).open(executionContext); Foo foo1 = itemReader.read(); assertEquals(1, foo1.getValue()); Foo foo2 = itemReader.read(); assertEquals(2, foo2.getValue()); Foo foo3 = itemReader.read(); assertEquals(3, foo3.getValue()); Foo foo4 = itemReader.read(); assertEquals(4, foo4.getValue()); Foo foo5 = itemReader.read(); assertEquals(5, foo5.getValue()); assertNull(itemReader.read()); }
@Test @Transactional @DirtiesContext public void testNormalProcessing() throws Exception { getAsInitializingBean(reader).afterPropertiesSet(); getAsItemStream(reader).open(executionContext); Foo foo1 = reader.read(); assertEquals(1, foo1.getValue()); Foo foo2 = reader.read(); assertEquals(2, foo2.getValue()); Foo foo3 = reader.read(); assertEquals(3, foo3.getValue()); Foo foo4 = reader.read(); assertEquals(4, foo4.getValue()); Foo foo5 = reader.read(); assertEquals(5, foo5.getValue()); assertNull(reader.read()); }
/** * Create and start a new {@link MessageListenerContainer} using the specified factory. * @param endpoint the endpoint to create a {@link MessageListenerContainer}. * @param factory the {@link KafkaListenerContainerFactory} to use. * @return the {@link MessageListenerContainer}. */ protected MessageListenerContainer createListenerContainer(KafkaListenerEndpoint endpoint, KafkaListenerContainerFactory<?> 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 (listenerContainer.isAutoStartup() && containerPhase != AbstractMessageListenerContainer.DEFAULT_PHASE) { // a custom phase value if (this.phase != AbstractMessageListenerContainer.DEFAULT_PHASE && this.phase != containerPhase) { throw new IllegalStateException("Encountered phase mismatch between container " + "factory definitions: " + this.phase + " vs " + containerPhase); } this.phase = listenerContainer.getPhase(); } return listenerContainer; }
private void init() { cookieEnabled = defaultIfNull(cookieEnabled, COOKIE_ENABLED_DEFAULT); urlEncodeEnabled = defaultIfNull(urlEncodeEnabled, URL_ENCODE_ENABLED_DEFAULT); if (generator == null) { generator = new UUIDGenerator(); if (generator instanceof InitializingBean) { try { ((InitializingBean) generator).afterPropertiesSet(); } catch (Exception e) { throw toRuntimeException(e); } } } cookie.init(); urlEncode.init(); }
private void init() { cookieEnabled = defaultIfNull(cookieEnabled, COOKIE_ENABLED_DEFAULT); urlEncodeEnabled = defaultIfNull(urlEncodeEnabled, URL_ENCODE_ENABLED_DEFAULT); if (generator == null) { generator = new UUIDGenerator(); if (generator instanceof InitializingBean) { try { ((InitializingBean) generator).afterPropertiesSet(); } catch (Exception e) { throw toRuntimeException(e); } } } cookie.init(); urlEncode.init(); }