當前位置: 首頁>>代碼示例>>Java>>正文


Java AutowireCapableBeanFactory.autowireBean方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.config.AutowireCapableBeanFactory.autowireBean方法的典型用法代碼示例。如果您正苦於以下問題:Java AutowireCapableBeanFactory.autowireBean方法的具體用法?Java AutowireCapableBeanFactory.autowireBean怎麽用?Java AutowireCapableBeanFactory.autowireBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.config.AutowireCapableBeanFactory的用法示例。


在下文中一共展示了AutowireCapableBeanFactory.autowireBean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
public void init(ServletConfig config) throws ServletException {
    try {
        WebApplicationContext springContext = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
        final AutowireCapableBeanFactory beanFactory = springContext.getAutowireCapableBeanFactory();
        beanFactory.autowireBean(this);
    }
    catch (Exception e) {
        logger.error("Error initializing ShibbolethExtAuthnHandler", e);
    }
}
 
開發者ID:vrk-kpa,項目名稱:e-identification-tupas-idp-public,代碼行數:11,代碼來源:ShibbolethExtAuthnHandler.java

示例2: autowireAndInitialize

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的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

示例3: contextInitialized

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
    WebApplicationContext webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContextEvent.getServletContext());
    AutowireCapableBeanFactory autowireCapableBeanFactory=webApplicationContext.getAutowireCapableBeanFactory();
    autowireCapableBeanFactory.autowireBean(this);
    
    //Permitirmos varias "locations" en el parámetro separados por "\n"
    String[] rawLocations = (servletContextEvent.getServletContext().getInitParameter("databasemigration.location")+"").split("\\n");
    List<String> locations = new ArrayList<String>();
    for(String location : rawLocations) {
        if ((location!=null) && (location.trim().isEmpty()==false)) {
            locations.add(location);
        }
    }

    databaseMigration.migrate(locations);
}
 
開發者ID:ix3,項目名稱:ix3,代碼行數:18,代碼來源:DatabaseMigrateContextListener.java

示例4: init

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    String module = filterConfig.getInitParameter("module");
    CloudStackSpringContext context = (CloudStackSpringContext)filterConfig.getServletContext().getAttribute(CloudStackSpringContext.CLOUDSTACK_CONTEXT_SERVLET_KEY);

    if (context == null)
        return;

    ApplicationContext applicationContext = context.getApplicationContextForWeb(module);
    if (applicationContext != null) {
        AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory();
        if (factory != null) {
            factory.autowireBean(this);
            enabled = true;
        }
    }
}
 
開發者ID:apache,項目名稱:cloudstack,代碼行數:18,代碼來源:ModuleBasedFilter.java

示例5: createJobInstance

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
    final AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
    final Object job = super.createJobInstance(bundle);
    logger.debug("Created job {} for bundle {}", job, bundle);
    beanFactory.autowireBean(job);
    logger.debug("Autowired job per the application context");
    return job;
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:10,代碼來源:CasSpringBeanJobFactory.java

示例6: inject

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@PostLoad
@PostPersist
public void inject(Object object) {
    AutowireCapableBeanFactory beanFactory = get().getBeanFactory();
    if(beanFactory == null) {
        LOG.warn("Bean Factory not set! Depdendencies will not be injected into: '{}'", object);
        return;
    }
    LOG.debug("Injecting dependencies into entity: '{}'.", object);
    beanFactory.autowireBean(object);
}
 
開發者ID:CK35,項目名稱:example-ddd-with-spring-data-jpa,代碼行數:12,代碼來源:SpringEntityListener.java

示例7: init

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Override
public void init(final ServletConfig config) throws ServletException {

	super.init(config);
	springContext = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
	final AutowireCapableBeanFactory beanFactory = springContext.getAutowireCapableBeanFactory();
	beanFactory.autowireBean(this);
}
 
開發者ID:4lberto,項目名稱:simpleWebAppWithDelegatingFilterProxy,代碼行數:9,代碼來源:servlet1.java

示例8: importBatch

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
private void importBatch(List<Long> entityIds) throws PropertyValueException {
	preload(entityIds, getMigrationInformation());
	
	try {
		MapSqlParameterSource entityIdsParameterSource = new MapSqlParameterSource();
		entityIdsParameterSource.addValue(getMigrationInformation().getParameterIds(), entityIds);
		AutowireCapableBeanFactory autowire = applicationContext.getAutowireCapableBeanFactory();
		
		AbstractResultRowMapper<? extends Map<Owning, Owned>> rowMapper = getMigrationInformation().newRowMapper(entityIds.size(), DEFAULT_VALUES_PER_KEY);
		
		autowire.autowireBean(rowMapper);
		autowire.initializeBean(rowMapper, rowMapper.getClass().getSimpleName());
		prepareRowMapper(rowMapper, entityIds);
		getNamedParameterJdbcTemplate().query(getMigrationInformation().getSqlRequest(), entityIdsParameterSource, rowMapper);
		
		for (Map.Entry<Owning, Owned> entry : rowMapper.getResults().entrySet()) {
			Owning entity = entry.getKey();
			getMigrationInformation().addToAssociation(entity, entry.getValue());
			if (getEntityService() != null) {
				getEntityService().update(entity);
			} else {
				entityManagerUtils.getEntityManager().persist(entity);
			}
		}
		
	} catch (RuntimeException | ServiceException | SecurityServiceException e) {
		getLogger().error("Error during the persistence of {} items. {} cancelled creations.",
				getMigrationInformation().getAssociationName(), entityIds.size(), e);
		ProcessorMonitorContext.get().getDoneItems().addAndGet(-1 * entityIds.size());
	}
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:32,代碼來源:AbstractBatchAssociationMigrationService.java

示例9: init

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
/**
 * Initialization of the servlet. <br>
 * 
 * @throws ServletException
 *             if an error occurs
 */
public void init() throws ServletException
{
	super.init();
	WebApplicationContext ctx = WebApplicationContextUtils
			.getWebApplicationContext(getServletContext());
	AutowireCapableBeanFactory factory = ctx.getAutowireCapableBeanFactory();
	factory.autowireBean(this);
}
 
開發者ID:ChenAt,項目名稱:Translation,代碼行數:15,代碼來源:BaseServlet.java

示例10: init

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
public void init() throws ServletException
	{
//		tempPathFile = new File("/home/kaiduan/temp");
		tempPathFile = new File(PropertiesUtils.getProperty("uploadFileBasePath") + "temp/");
		if (!tempPathFile.exists())
		{
			tempPathFile.mkdirs();
		}
		WebApplicationContext ctx = WebApplicationContextUtils
				.getWebApplicationContext(getServletContext());
		AutowireCapableBeanFactory factory = ctx.getAutowireCapableBeanFactory();
		factory.autowireBean(this);
	}
 
開發者ID:ChenAt,項目名稱:Translation,代碼行數:14,代碼來源:UploadFileServlet.java

示例11: autowireBean

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
/**
 * 將該對象中的帶有Autowired annotation的屬性自動注入
 */
public static void autowireBean(Object obj) {
    if (_context != null) {
        AutowireCapableBeanFactory factory = _context.getAutowireCapableBeanFactory();
        factory.autowireBean(obj);
    }
}
 
開發者ID:sofn,項目名稱:app-engine,代碼行數:10,代碼來源:ApplicationContextHolder.java

示例12: setUp

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
@Before
public void setUp()
{
    ThreadDelegatedScope.SCOPE.changeScope(null);

    final ApplicationContext context =
            new AnnotationConfigApplicationContext(ThreadDelegatedScopeConfiguration.class,
                    ScopedObject.ScopedObjectConfiguration.class);
    final AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory();

    factory.autowireBean(this);
    Assert.assertNotNull(filter);
    Assert.assertNotNull(this.context);
}
 
開發者ID:opentable,項目名稱:otj-scopes,代碼行數:15,代碼來源:TestThreadDelegatingScopeFilter.java

示例13: getAdminUserDAO

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
private AdminUserDAO getAdminUserDAO( )
{
    AdminUserDAO adminUserDAO = new AdminUserDAO( );
    ApplicationContext context = SpringContextService.getContext( );
    AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory( );
    beanFactory.autowireBean( adminUserDAO );
    return adminUserDAO;
}
 
開發者ID:lutece-platform,項目名稱:lutece-core,代碼行數:9,代碼來源:AdminMenuJspBeanTest.java

示例14: getLuteceDefaultAdminAuthentication

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
private LuteceDefaultAdminAuthentication getLuteceDefaultAdminAuthentication( )
{
    LuteceDefaultAdminAuthentication adminAuth = new LuteceDefaultAdminAuthentication( );
    LuteceDefaultAdminUserDAO dao = new LuteceDefaultAdminUserDAO( );
    AutowireCapableBeanFactory beanFactory = SpringContextService.getContext( ).getAutowireCapableBeanFactory( );
    beanFactory.autowireBean( dao );
    adminAuth.setDao( dao );
    beanFactory.autowireBean( adminAuth );
    return adminAuth;
}
 
開發者ID:lutece-platform,項目名稱:lutece-core,代碼行數:11,代碼來源:LuteceDefaultAdminAuthenticationTest.java

示例15: getLuteceDefaultAdminUserDAO

import org.springframework.beans.factory.config.AutowireCapableBeanFactory; //導入方法依賴的package包/類
private LuteceDefaultAdminUserDAO getLuteceDefaultAdminUserDAO( )
{
    LuteceDefaultAdminUserDAO dao = new LuteceDefaultAdminUserDAO( );
    AutowireCapableBeanFactory beanFactory = SpringContextService.getContext( ).getAutowireCapableBeanFactory( );
    beanFactory.autowireBean( dao );
    return dao;
}
 
開發者ID:lutece-platform,項目名稱:lutece-core,代碼行數:8,代碼來源:LuteceDefaultAdminUserDAOTest.java


注:本文中的org.springframework.beans.factory.config.AutowireCapableBeanFactory.autowireBean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。