本文整理匯總了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);
}
}
示例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);
}
}
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}