use of org.springframework.beans.factory.annotation.Autowired in project opennms by OpenNMS.
the class BeanUtils method assertAutowiring.
/**
* Check that all fields that are marked with @Autowired are not null.
* This will identify classes that have been loaded by Spring but have
* not been autowired via {@code <context:annotation-config />}.
*/
public static <T> void assertAutowiring(T instance) {
for (Field field : instance.getClass().getDeclaredFields()) {
Autowired autowired = field.getAnnotation(Autowired.class);
Inject inject = field.getAnnotation(Inject.class);
Resource resource = field.getAnnotation(Resource.class);
if ((autowired != null && autowired.required()) || (inject != null) || (resource != null)) {
try {
field.setAccessible(true);
notNull(field.get(instance), "@Autowired/@Inject/@Resource field " + field.getName() + " cannot be null");
LOG.debug("{} is not null", field.getName());
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Illegal access to @Autowired/@Resource field " + field.getName());
}
}
}
}
use of org.springframework.beans.factory.annotation.Autowired in project perun by CESNET.
the class ExecutorEngineWorkerImpl method setPropertiesBean.
@Autowired
public void setPropertiesBean(Properties propertiesBean) {
this.propertiesBean = propertiesBean;
if (propertiesBean != null) {
// here we can be sure, that properties bean is present
genDirectory = new File(propertiesBean.getProperty("engine.genscript.path"));
sendDirectory = new File(propertiesBean.getProperty("engine.sendscript.path"));
}
}
use of org.springframework.beans.factory.annotation.Autowired in project uPortal by Jasig.
the class JpaClusterLockDao method setPlatformTransactionManager.
@Autowired
public void setPlatformTransactionManager(@Qualifier(BasePortalJpaDao.PERSISTENCE_UNIT_NAME) PlatformTransactionManager platformTransactionManager) {
this.newTransactionTemplate = new TransactionTemplate(platformTransactionManager);
this.newTransactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
this.newTransactionTemplate.afterPropertiesSet();
}
use of org.springframework.beans.factory.annotation.Autowired in project uPortal by Jasig.
the class JaxbPortalDataHandlerService method setImportExportThreadPool.
@Autowired
public void setImportExportThreadPool(@Qualifier("importExportThreadPool") ExecutorService importExportThreadPool) {
this.importExportThreadPool = importExportThreadPool;
this.directoryScanner = new ConcurrentDirectoryScanner(this.importExportThreadPool);
}
use of org.springframework.beans.factory.annotation.Autowired in project uPortal by Jasig.
the class FragmentActivator method setUserViews.
@Autowired
public void setUserViews(@Qualifier("org.apereo.portal.layout.dlm.FragmentActivator.userViews") Ehcache userViews) {
this.userViews = new SelfPopulatingCache(userViews, new CacheEntryFactory() {
@Override
public Object createEntry(Object key) throws Exception {
final UserViewKey userViewKey = (UserViewKey) key;
//Check if there was an exception the last time a load attempt was made and re-throw
final net.sf.ehcache.Element exceptionElement = userViewErrors.get(userViewKey);
if (exceptionElement != null) {
throw (Exception) exceptionElement.getObjectValue();
}
try {
return activateFragment(userViewKey);
} catch (Exception e) {
userViewErrors.put(new net.sf.ehcache.Element(userViewKey, e));
throw e;
}
}
});
}
Aggregations