Search in sources :

Example 16 with Autowired

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());
            }
        }
    }
}
Also used : Inject(javax.inject.Inject) Field(java.lang.reflect.Field) Autowired(org.springframework.beans.factory.annotation.Autowired) Resource(javax.annotation.Resource)

Example 17 with Autowired

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"));
    }
}
Also used : File(java.io.File) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 18 with Autowired

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();
}
Also used : TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 19 with Autowired

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);
}
Also used : ConcurrentDirectoryScanner(org.apereo.portal.utils.ConcurrentDirectoryScanner) Autowired(org.springframework.beans.factory.annotation.Autowired)

Example 20 with Autowired

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;
            }
        }
    });
}
Also used : SelfPopulatingCache(net.sf.ehcache.constructs.blocking.SelfPopulatingCache) CacheEntryFactory(net.sf.ehcache.constructs.blocking.CacheEntryFactory) Element(org.w3c.dom.Element) AuthorizationException(org.apereo.portal.AuthorizationException) Autowired(org.springframework.beans.factory.annotation.Autowired)

Aggregations

Autowired (org.springframework.beans.factory.annotation.Autowired)38 Bean (org.springframework.context.annotation.Bean)23 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)9 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)5 JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)3 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)3 V3ProxyValidateController (org.apereo.cas.web.v3.V3ProxyValidateController)2 V3ServiceValidateController (org.apereo.cas.web.v3.V3ServiceValidateController)2 Logger (org.slf4j.Logger)2 Qualifier (org.springframework.beans.factory.annotation.Qualifier)2 File (java.io.File)1 Constructor (java.lang.reflect.Constructor)1 Executable (java.lang.reflect.Executable)1 Field (java.lang.reflect.Field)1 Parameter (java.lang.reflect.Parameter)1 Properties (java.util.Properties)1 Resource (javax.annotation.Resource)1 Inject (javax.inject.Inject)1 PersistenceConfiguration (net.sf.ehcache.config.PersistenceConfiguration)1 CacheEntryFactory (net.sf.ehcache.constructs.blocking.CacheEntryFactory)1