Java Code Examples for org.springframework.beans.factory.InitializingBean

The following are top voted examples for showing how to use org.springframework.beans.factory.InitializingBean. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: lams   File: TaskExecutorFactoryBean.java   View source code 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 2
Project: klask-io   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 3
Project: spring-boot-oauth2-demo   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 4
Project: spring-boot-oauth2-demo   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 5
Project: blogAggr   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 6
Project: spring4-understanding   File: TaskExecutorFactoryBean.java   View source code 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 7
Project: spring4-understanding   File: StandaloneMockMvcBuilder.java   View source code 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 8
Project: spring4-understanding   File: JmsListenerEndpointRegistry.java   View source code 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 9
Project: my-spring-cache-redis   File: TaskExecutorFactoryBean.java   View source code 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 10
Project: javacode-demo   File: Specs.java   View source code 6 votes vote down vote up
public static <T> T parseTag(Class<T> clazz, Spec spec) {
    T object = Reflect.on(clazz).create().get();

    if (object instanceof SpecAppliable)
        ((SpecAppliable) object).applySpec(spec);

    if (object instanceof InitializingBean) {
        try {
            ((InitializingBean) object).afterPropertiesSet();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    return object;
}
 
Example 11
Project: netty-http-3.x   File: BeanUtils.java   View source code 6 votes vote down vote up
public static <T> T createBean(Class<T> clazz, Settings settings, ApplicationContext applicationContext) throws Exception {
	if (clazz == null || clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
		return null;
	}

	T bean = clazz.newInstance();

	if (bean instanceof SettingsAware) {
		((SettingsAware) bean).setSettings(settings);
	}

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

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

	return bean;
}
 
Example 12
Project: flowable-engine   File: SecurityAutoConfigurationTest.java   View source code 6 votes vote down vote up
@Bean
InitializingBean init(
        final IdentityService identityService) {
    return new InitializingBean() {
        @Override
        public void afterPropertiesSet() throws Exception {

            // install groups & users
            Group userGroup = group("user");
            Group adminGroup = group("admin");

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

            User josh = user("jlong", "Josh", "Long");
            identityService.createMembership(josh.getId(), userGroup.getId());
        }
    };
}
 
Example 13
Project: FinanceAnalytics   File: FindViewAmbiguities.java   View source code 6 votes vote down vote up
@Override
protected FunctionExclusionGroups createFunctionExclusionGroups() {
  // TODO: The exclusion groups could be exposed over the network (sending the function identifier) and cached
  final String exclusionGroups = getCommandLine().getOptionValue(EXCLUSION_GROUPS_OPTION);
  if (exclusionGroups != null) {
    try {
      final Class<?> exclusionGroupsClass = ClassUtils.loadClass(exclusionGroups);
      Object groupsObject = exclusionGroupsClass.newInstance();
      if (groupsObject instanceof InitializingBean) {
        ((InitializingBean) groupsObject).afterPropertiesSet();
      }
      if (groupsObject instanceof FactoryBean) {
        groupsObject = ((FactoryBean<?>) groupsObject).getObject();
      }
      if (groupsObject instanceof FunctionExclusionGroups) {
        return (FunctionExclusionGroups) groupsObject;
      }
      throw new IllegalArgumentException("Couldn't set exclusion groups to " + exclusionGroups + " (got " + groupsObject + ")");
    } catch (Exception e) {
      throw new OpenGammaRuntimeException("Error loading exclusion groups", e);
    }
  }
  return null;
}
 
Example 14
Project: FinanceAnalytics   File: StandardFunctionConfiguration.java   View source code 6 votes vote down vote up
protected <T> Map<String, T> getCurrencyInfo(final Function<CurrencyInfo, T> filter) {
  final Map<String, T> result = new HashMap<String, T>();
  for (final Map.Entry<String, CurrencyInfo> e : getPerCurrencyInfo().entrySet()) {
    final T entry = filter.apply(e.getValue());
    if (entry instanceof InitializingBean) {
      try {
        ((InitializingBean) entry).afterPropertiesSet();
      } catch (final Exception ex) {
        s_logger.debug("Skipping {}", e.getKey());
        s_logger.trace("Caught exception", e);
        continue;
      }
    }
    if (entry != null) {
      result.put(e.getKey(), entry);
    }
  }
  return result;
}
 
Example 15
Project: FinanceAnalytics   File: StandardFunctionConfiguration.java   View source code 6 votes vote down vote up
protected <T> Map<Pair<String, String>, T> getCurrencyPairInfo(final Function<CurrencyPairInfo, T> filter) {
  final Map<Pair<String, String>, T> result = new HashMap<Pair<String, String>, T>();
  for (final Map.Entry<Pair<String, String>, CurrencyPairInfo> e : getPerCurrencyPairInfo().entrySet()) {
    final T entry = filter.apply(e.getValue());
    if (entry instanceof InitializingBean) {
      try {
        ((InitializingBean) entry).afterPropertiesSet();
      } catch (final Exception ex) {
        s_logger.debug("Skipping {}", e.getKey());
        s_logger.trace("Caught exception", e);
        continue;
      }
    }
    if (entry != null) {
      result.put(e.getKey(), entry);
    }
  }
  return result;
}
 
Example 16
Project: request-correlation-spring-cloud-starter   File: ClientHttpCorrelationConfiguration.java   View source code 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 17
Project: tddl5   File: AdapterDelegate.java   View source code 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 18
Project: eHMP   File: CPESessionContextIntegrationFilter.java   View source code 6 votes vote down vote up
private void autowireAndInitialize(ServletRequest req, Map<String, Object> contexts) {
    ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(req.getServletContext());
    AutowireCapableBeanFactory autowirer = appContext.getAutowireCapableBeanFactory();
    for (Map.Entry<String,Object> entry : contexts.entrySet()) {
        Object context = entry.getValue();
        autowirer.autowireBean(context);
        try {
            if (context instanceof InitializingBean) {
                ((InitializingBean) context).afterPropertiesSet();
            }
        } catch (Exception e) {
            logger.warn("Invocation of init method failed of context: " + entry.getKey(), e);
        }

    }
}
 
Example 19
Project: elasticSearchKata   File: ElasticSettingApp.java   View source code 6 votes vote down vote up
@Bean
InitializingBean populateData(final UserService userService) {
    return () -> {
        userService.deleteAll();
        userService.persist(User.builder().login("malysz").name("adam").salary(new BigDecimal(306)).build());
        log.info(" {}", userService.persist(User.builder().login("borowiec").name("przodownik").salary(new BigDecimal(100)).build()));
        log.info(" {}", userService.persist(User.builder().login("borowiec").name("aga").salary(new BigDecimal(10)).build()));
        log.info(" {}", userService.persist(User.builder().login("borowiec").name("kalina").salary(new BigDecimal(30)).build()));
        log.info(" {}", userService.persist(User.builder().login("tyson").name("iron mike").salary(new BigDecimal(3234)).build()));
        log.info(" {}", userService.persist(User.builder().login("rossi").name("the doctor").salary(new BigDecimal(2000)).build()));

        log.info(" {}", userService.persist(new User("kazimierczak", "juz", new BigDecimal(100))));
        log.info(" {}", userService.persist(new User("aleksandrowicz", "dawid", new BigDecimal(10))));
        log.info(" {}", userService.persist(new User("barszcz", "mariusz", new BigDecimal(30))));
        log.info(" {}", userService.persist(new User("bogadanski", "pawel", new BigDecimal(3000))));
        log.info(" {}", userService.persist(new User("chudzikowska", "sylwia", new BigDecimal(2000))));

        log.info(" {}", userService.persist(new User("swietojanski", "przemyslaw", new BigDecimal(100))));
        log.info(" {}", userService.persist(new User("zurek", "marcin", new BigDecimal(10))));
        log.info(" {}", userService.persist(new User("grabowski", "michal", new BigDecimal(30))));
        log.info(" {}", userService.persist(new User("gilewski", "piotr", new BigDecimal(3000))));
        log.info(" {}", userService.persist(new User("ostroski", "krzych", new BigDecimal(2000))));
    };
}
 
Example 20
Project: class-guard   File: TaskExecutorFactoryBean.java   View source code 6 votes vote down vote up
public void afterPropertiesSet() throws Exception {
	Class<?> executorClass = (shouldUseBackport() ?
			ClassUtils.forName("org.springframework.scheduling.backportconcurrent.ThreadPoolTaskExecutor", getClass().getClassLoader()) :
			ThreadPoolTaskExecutor.class);
	BeanWrapper bw = new BeanWrapperImpl(executorClass);
	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 21
Project: cobar   File: AdapterDelegate.java   View source code 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 22
Project: spring-rich-client   File: DefaultViewDescriptor.java   View source code 6 votes vote down vote up
protected View createView() {
    Assert.state(viewClass != null, "View class to instantiate is not set");
    Object o = BeanUtils.instantiateClass(viewClass);
    Assert.isTrue((o instanceof View), "View class '" + viewClass
            + "' was instantiated, but instance is not a View!");
    View view = (View) o;
    view.setDescriptor(this);
    if (viewProperties != null) {
        BeanWrapper wrapper = new BeanWrapperImpl(view);
        wrapper.setPropertyValues(viewProperties);
    }

    if (view instanceof InitializingBean) {
        try {
            ((InitializingBean) view).afterPropertiesSet();
        } catch (Exception e) {
            throw new BeanInitializationException("Problem running on " + view, e);
        }
    }
    return view;
}
 
Example 23
Project: spring-rich-client   File: EditorDescriptor.java   View source code 6 votes vote down vote up
private Editor createEditor(){
	Object o = BeanUtils.instantiateClass(editorClass);
	Assert.isTrue((o instanceof Editor), "Editor class '"+
		editorClass + "' was instantiated but is not an Editor");
	Editor editor = (Editor)o;
	editor.setDescriptor(this);
	ApplicationEventMulticaster multicaster = getApplicationEventMulticaster();
	if(editor instanceof ApplicationListener &&  multicaster != null){
		multicaster.addApplicationListener((ApplicationListener)editor);
	}
	if(editorProperties != null){
		BeanWrapper wrapper = new BeanWrapperImpl(editor);
		wrapper.setPropertyValues(editorProperties);
	}
	if(editor instanceof InitializingBean){
		 try {
			 ((InitializingBean)editor).afterPropertiesSet();
         }
         catch (Exception e) {
             throw new BeanInitializationException("Problem running on " + editor, e);
         }
	}
	return editor;
}
 
Example 24
Project: spring-richclient   File: DefaultViewDescriptor.java   View source code 6 votes vote down vote up
protected View createView() {
    Assert.state(viewClass != null, "View class to instantiate is not set");
    Object o = BeanUtils.instantiateClass(viewClass);
    Assert.isTrue((o instanceof View), "View class '" + viewClass
            + "' was instantiated, but instance is not a View!");
    View view = (View) o;
    view.setDescriptor(this);
    if (viewProperties != null) {
        BeanWrapper wrapper = new BeanWrapperImpl(view);
        wrapper.setPropertyValues(viewProperties);
    }

    if (view instanceof InitializingBean) {
        try {
            ((InitializingBean) view).afterPropertiesSet();
        } catch (Exception e) {
            throw new BeanInitializationException("Problem running on " + view, e);
        }
    }
    return view;
}
 
Example 25
Project: spring-richclient   File: EditorDescriptor.java   View source code 6 votes vote down vote up
private Editor createEditor(){
	Object o = BeanUtils.instantiateClass(editorClass);
	Assert.isTrue((o instanceof Editor), "Editor class '"+
		editorClass + "' was instantiated but is not an Editor");
	Editor editor = (Editor)o;
	editor.setDescriptor(this);
	ApplicationEventMulticaster multicaster = getApplicationEventMulticaster();
	if(editor instanceof ApplicationListener &&  multicaster != null){
		multicaster.addApplicationListener((ApplicationListener)editor);
	}
	if(editorProperties != null){
		BeanWrapper wrapper = new BeanWrapperImpl(editor);
		wrapper.setPropertyValues(editorProperties);
	}
	if(editor instanceof InitializingBean){
		 try {
			 ((InitializingBean)editor).afterPropertiesSet();
         }
         catch (Exception e) {
             throw new BeanInitializationException("Problem running on " + editor, e);
         }
	}
	return editor;
}
 
Example 26
Project: amv-access-api-poc   File: DemoConfig.java   View source code 5 votes vote down vote up
@Bean
public InitializingBean demo(DemoService demoService) {
    return new InitializingBean() {
        @Override
        @Transactional
        public void afterPropertiesSet() throws Exception {
            if (demoProperties.isEnabled()) {
                demoService.createDemoDataFromProperties(demoProperties);
            }
        }
    };
}
 
Example 27
Project: amv-access-api-poc   File: CertificateIssuerConfig.java   View source code 5 votes vote down vote up
@Bean
public InitializingBean issuerInitializer(IssuerRepository issuerRepository) {
    return new InitializingBean() {
        @Override
        @Transactional
        public void afterPropertiesSet() throws Exception {
            initializeIssuerFromPropertiesIfNecessary(issuerRepository, issuer());
        }
    };
}
 
Example 28
Project: buenojo   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 29
Project: sentry   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 30
Project: gemini.blueprint   File: NonOSGiLoaderProxyTest.java   View source code 5 votes vote down vote up
public void testProxy() throws Exception {
	// publish service
	bundleContext.registerService(new String[] { DataSource.class.getName(), Comparator.class.getName(),
		InitializingBean.class.getName(), Constants.class.getName() }, new Service(), new Hashtable());

	ConfigurableApplicationContext ctx = getNestedContext();
	assertNotNull(ctx);
	Object proxy = ctx.getBean("service");
	assertNotNull(proxy);
	assertTrue(proxy instanceof DataSource);
	assertTrue(proxy instanceof Comparator);
	assertTrue(proxy instanceof Constants);
	assertTrue(proxy instanceof InitializingBean);
	ctx.close();
}
 
Example 31
Project: lams   File: AbstractAutowireCapableBeanFactory.java   View source code 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 32
Project: shoucang   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 33
Project: springdean   File: SpringbootEurekaClientApplication.java   View source code 5 votes vote down vote up
@Bean
public InitializingBean seedDatabase(TrackingRepository repository) {
	System.out.println("initial DB");
	return () -> {
		repository.save(new Tracking("EMS123456777", "Packing", 1L));
		repository.save(new Tracking("KEERY9999", "Packing", 2L));
	};
}
 
Example 34
Project: springdean   File: SpringbootDataJpaApplication.java   View source code 5 votes vote down vote up
@Bean
public InitializingBean seedDatabase(ProductRepository repository) {
    return () -> {
        repository.save(new Product("Intel i7", "CPU", "https://i.ytimg.com/vi/mmHY8Kj4vCk/maxresdefault.jpg", "i7 7700k", 7000));
        repository.save(new Product("AMD Raizen 1700X", "CPU", "http://cdn.wccftech.com/wp-content/uploads/2017/02/AMD-Ryzen-CPU.png", "AMD 1700X", 3500));
        repository.save(new Product("Galax HOF GTX1080", "GPU", "https://www.custompcreview.com/wp-content/uploads/2016/05/29140448720l.jpg", "GTX 1080", 2350));
        repository.save(new Product("Raiden Plasma", "RAM", "https://i.ytimg.com/vi/SApyTXm_jQE/maxresdefault.jpg", "DDR4 32GB", 8872));
    };
}
 
Example 35
Project: transandalus-backend   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 36
Project: ugc-bot-redux   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 37
Project: BCDS   File: ExceptionHandlingAsyncTaskExecutor.java   View source code 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
Example 38
Project: spring4-understanding   File: ViewResolverComposite.java   View source code 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 39
Project: spring4-understanding   File: AbstractAsyncHttpRequestFactoryTestCase.java   View source code 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 40
Project: spring4-understanding   File: AbstractHttpRequestFactoryTestCase.java   View source code 5 votes vote down vote up
@Before
public final void createFactory() throws Exception {
	factory = createRequestFactory();
	if (factory instanceof InitializingBean) {
		((InitializingBean) factory).afterPropertiesSet();
	}
}