• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InitializingBean类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.beans.factory.InitializingBean的典型用法代码示例。如果您正苦于以下问题:Java InitializingBean类的具体用法?Java InitializingBean怎么用?Java InitializingBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InitializingBean类属于org.springframework.beans.factory包,在下文中一共展示了InitializingBean类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: afterPropertiesSet

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@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();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:TaskExecutorFactoryBean.java


示例2: afterPropertiesSet

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    if (executor instanceof InitializingBean) {
        InitializingBean bean = (InitializingBean) executor;
        bean.afterPropertiesSet();
    }
}
 
开发者ID:klask-io,项目名称:klask-io,代码行数:8,代码来源:ExceptionHandlingAsyncTaskExecutor.java


示例3: configureHandlerExceptionResolvers

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:StandaloneMockMvcBuilder.java


示例4: createListenerContainer

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:JmsListenerEndpointRegistry.java


示例5: parseTag

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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;
}
 
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:17,代码来源:Specs.java


示例6: createBean

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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;
}
 
开发者ID:iceize,项目名称:netty-http-3.x,代码行数:22,代码来源:BeanUtils.java


示例7: init

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@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());
        }
    };
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:21,代码来源:SecurityAutoConfigurationTest.java


示例8: createFunctionExclusionGroups

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@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;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:25,代码来源:FindViewAmbiguities.java


示例9: getCurrencyInfo

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:StandardFunctionConfiguration.java


示例10: getCurrencyPairInfo

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:StandardFunctionConfiguration.java


示例11: clientsCorrelationInitializer

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@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);
                }
            }
        }
    };
}
 
开发者ID:jmnarloch,项目名称:request-correlation-spring-cloud-starter,代码行数:18,代码来源:ClientHttpCorrelationConfiguration.java


示例12: createAdapter

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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);
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:18,代码来源:AdapterDelegate.java


示例13: autowireAndInitialize

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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);
        }

    }
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:17,代码来源:CPESessionContextIntegrationFilter.java


示例14: populateData

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@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))));
    };
}
 
开发者ID:przodownikR1,项目名称:elasticSearchKata,代码行数:25,代码来源:ElasticSettingApp.java


示例15: afterPropertiesSet

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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();
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:TaskExecutorFactoryBean.java


示例16: createView

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:22,代码来源:DefaultViewDescriptor.java


示例17: createEditor

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:25,代码来源:EditorDescriptor.java


示例18: demo

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Bean
public InitializingBean demo(DemoService demoService) {
    return new InitializingBean() {
        @Override
        @Transactional
        public void afterPropertiesSet() throws Exception {
            if (demoProperties.isEnabled()) {
                demoService.createDemoDataFromProperties(demoProperties);
            }
        }
    };
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:13,代码来源:DemoConfig.java


示例19: issuerInitializer

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
@Bean
public InitializingBean issuerInitializer(IssuerRepository issuerRepository) {
    return new InitializingBean() {
        @Override
        @Transactional
        public void afterPropertiesSet() throws Exception {
            initializeIssuerFromPropertiesIfNecessary(issuerRepository, issuer());
        }
    };
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:11,代码来源:CertificateIssuerConfig.java


示例20: testProxy

import org.springframework.beans.factory.InitializingBean; //导入依赖的package包/类
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();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:16,代码来源:NonOSGiLoaderProxyTest.java



注:本文中的org.springframework.beans.factory.InitializingBean类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GrantedAuthority类代码示例发布时间:2022-05-20
下一篇:
Java VelocityTracker类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap