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

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Gemini-Blueprint, under directory /integration-tests/tests/src/test/java/org/eclipse/gemini/blueprint/iandt/nonosgicl/.

Source file: NonOSGiLoaderProxyTest.java

  15 
vote

public void testProxy() throws Exception {
  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 2

From project spring-advanced-marhshallers-and-service-exporters, under directory /obm/src/test/java/org/springframework/remoting/messagepack/.

Source file: DefaultEchoService.java

  15 
vote

public DefaultEchoService(){
  if (executor instanceof InitializingBean) {
    try {
      ((InitializingBean)executor).afterPropertiesSet();
    }
 catch (    Exception e) {
      log.error(e);
      throw new RuntimeException(e);
    }
  }
}
 

Example 3

From project spring-js, under directory /src/main/java/org/springframework/scheduling/config/.

Source file: TaskExecutorFactoryBean.java

  15 
vote

public void afterPropertiesSet() throws Exception {
  Class<?> executorClass=(shouldUseBackport() ? getClass().getClassLoader().loadClass("org.springframework.scheduling.backportconcurrent.ThreadPoolTaskExecutor") : 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 4

From project spring-test-mvc, under directory /src/main/java/org/springframework/test/web/server/setup/.

Source file: StandaloneMockMvcBuilder.java

  15 
vote

@Override public Validator mvcValidator(){
  Validator mvcValidator=(validator != null) ? validator : super.mvcValidator();
  if (mvcValidator instanceof InitializingBean) {
    try {
      ((InitializingBean)mvcValidator).afterPropertiesSet();
    }
 catch (    Exception e) {
      throw new BeanInitializationException("Failed to initialize Validator",e);
    }
  }
  return mvcValidator;
}
 

Example 5

From project Valkyrie-RCP, under directory /valkyrie-rcp-core/src/main/java/org/valkyriercp/application/support/.

Source file: DefaultViewDescriptor.java

  15 
vote

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;
}