Java Code Examples for org.springframework.beans.factory.annotation.Autowired
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
/** * BeanDefinitionRegistryPostProcessor's method second run: check which spring bean that need injected from Jdon. */ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { for ( String beanName : registry.getBeanDefinitionNames()) { BeanDefinition beanDefinition=registry.getBeanDefinition(beanName); String beanClassName=beanDefinition.getBeanClassName(); try { Class beanClass=Class.forName(beanClassName); for ( final Field field : ClassUtil.getAllDecaredFields(beanClass)) { if (field.isAnnotationPresent(Autowired.class)) { Object o=findBeanClassInJdon(field.getType()); if (o != null) { neededJdonComponents.put(field.getName(),o); } } } } catch ( ClassNotFoundException ex) { ex.printStackTrace(); } } }
Example 2
From project OpenTripPlanner, under directory /opentripplanner-analyst/src/main/java/org/opentripplanner/analyst/core/.
Source file: GeometryIndex.java

@Autowired public void setGraphService(GraphService graphService){ Graph graph=graphService.getGraph(); if (graph == null) return; pedestrianIndex=new STRtree(); index=new STRtree(); for ( StreetVertex vertex : IterableLibrary.filter(graph.getVertices(),StreetVertex.class)) { for ( StreetEdge e : IterableLibrary.filter(vertex.getOutgoing(),StreetEdge.class)) { Geometry geom=e.getGeometry(); if (e.getPermission().allows(StreetTraversalPermission.PEDESTRIAN)) { pedestrianIndex.insert(geom.getEnvelopeInternal(),e); } index.insert(geom.getEnvelopeInternal(),e); } } pedestrianIndex.build(); index.build(); LOG.debug("spatial index size: {}",pedestrianIndex.size()); }
Example 3
From project spring-framework-samples, under directory /task-config/src/main/java/task/.
Source file: EnableScheduledTasks.java

@Autowired(required=false) void setupScheduledTaskRegistrar(Collection<ScheduledConfigurationCustomizer> listeners){ if (listeners != null && !listeners.isEmpty()) { ScheduledConfigurationCustomizerComposite delegate=new ScheduledConfigurationCustomizerComposite(); delegate.registerListeners(listeners); registrar=new ScheduledTaskRegistrar(); Object scheduler=getScheduler(); if (scheduler != null) { registrar.setScheduler(scheduler); } try { delegate.configureTasks(registrar); } catch ( Exception e) { throw new BeanDefinitionStoreException("Could not customize task scheduler",e); } } }
Example 4
From project sched-assist, under directory /sched-assist-portlet/src/main/java/org/jasig/schedassist/portlet/webflow/.
Source file: FlowHelper.java

/** * @param availableWebBaseUrl the availableWebBaseUrl to set */ @Autowired public void setAvailableWebBaseUrl(String availableWebBaseUrl){ Validate.notEmpty(availableWebBaseUrl,"availableWebBaseUrl property must not be empty"); this.availableWebBaseUrl=availableWebBaseUrl; if (!this.availableWebBaseUrl.endsWith("/")) { this.availableWebBaseUrl+="/"; } this.advisorUrl=this.availableWebBaseUrl + "public/advisors.html"; this.profileSearchUrl=this.availableWebBaseUrl + "public/index.html"; }
Example 5
From project addressbook-sample-mongodb, under directory /web-ui/src/main/java/nl/enovation/addressbook/cqrs/webui/init/.
Source file: DBInit.java

@Autowired public DBInit(CommandBus commandBus,@Qualifier("mongoTemplate") CFMongoTemplate systemMongo,MongoEventStore eventStore,CFMongoTemplate mongoTemplate,MongoTemplate systemAxonSagaMongo){ this.commandBus=commandBus; systemAxonMongo=systemMongo; this.eventStore=eventStore; this.mongoTemplate=mongoTemplate; this.systemAxonSagaMongo=systemAxonSagaMongo; }
Example 6
From project constretto-core, under directory /constretto-spring/src/test/java/org/constretto/spring/assembly/.
Source file: AssemblyWithConcreteClassesTest.java

@Test public void injectionUsingConstrettoWithEnvironmentSetAndUsinginterface(){ class MyConsumer { @Autowired CommonInterface commonInterface; } setProperty(ASSEMBLY_KEY,"stub"); ApplicationContext ctx=loadContextAndInjectWithConstretto(); MyConsumer consumer=new MyConsumer(); ctx.getAutowireCapableBeanFactory().autowireBean(consumer); Assert.assertEquals(consumer.commonInterface.getClass(),CommonInterfaceStub.class); }
Example 7
From project gxa, under directory /atlas-web/src/main/java/uk/ac/ebi/gxa/service/experiment/.
Source file: ExperimentDataService.java

@Autowired public ExperimentDataService(ExperimentSolrDAO experimentSolrDAO,AtlasDAO atlasDAO,AtlasDataDAO atlasDataDAO,GeneSolrDAO geneSolrDAO,AtlasExperimentAnalyticsViewService expAnalyticsService){ this.experimentSolrDAO=experimentSolrDAO; this.atlasDAO=atlasDAO; this.atlasDataDAO=atlasDataDAO; this.geneSolrDAO=geneSolrDAO; this.expAnalyticsService=expAnalyticsService; }
Example 8
From project heritrix3, under directory /modules/src/main/java/org/archive/modules/deciderules/surt/.
Source file: SurtPrefixedDecideRule.java

@Autowired public void setSeeds(SeedModule seeds){ this.seeds=seeds; if (seeds != null) { seeds.addSeedListener(this); } }
Example 9
From project rave, under directory /rave-components/rave-core/src/main/java/org/apache/rave/portal/security/impl/.
Source file: RavePermissionEvaluator.java

/** * Constructor which will take in a component-scanned list of all ModelPermissionEvaluator classes found by Spring component scanner. The constructor builds the internal Map by using the Model type (Model Class) as the key, thus ensuring only one ModelPermissionEvaluator class exists for each Model object. The constructor first sorts the injected list of ModelPermissionEvaluator objects by the loadOrder field to allow overrides of the default ModelPermissionEvaluators. * @param modelPermissionEvaluatorList autowired injected list of all ModelPermissionEvaluator classes foundby the component scanner */ @Autowired public RavePermissionEvaluator(List<ModelPermissionEvaluator<?>> modelPermissionEvaluatorList){ Collections.sort(modelPermissionEvaluatorList,new Comparator<ModelPermissionEvaluator>(){ @Override public int compare( ModelPermissionEvaluator o1, ModelPermissionEvaluator o2){ return new Integer(o1.getLoadOrder()).compareTo(new Integer(o2.getLoadOrder())); } } ); modelPermissionEvaluatorMap=new HashMap<Class,ModelPermissionEvaluator<?>>(); for ( ModelPermissionEvaluator<?> mpe : modelPermissionEvaluatorList) { modelPermissionEvaluatorMap.put(mpe.getType(),mpe); } }
Example 10
From project repose, under directory /project-set/core/core-lib/src/main/java/com/rackspace/papi/service/context/impl/.
Source file: ContainerServiceContext.java

@Autowired public ContainerServiceContext(@Qualifier("containerConfigurationService") ContainerConfigurationService containerConfigurationService,@Qualifier("servicePorts") ServicePorts servicePorts,@Qualifier("serviceRegistry") ServiceRegistry registry,@Qualifier("configurationManager") ConfigurationService configurationManager){ this.containerConfigurationService=containerConfigurationService; this.configurationListener=new ContainerConfigurationListener(); this.servicePorts=servicePorts; this.configurationManager=configurationManager; this.registry=registry; }
Example 11
From project spring-batch-admin, under directory /spring-batch-admin-manager/src/test/java/org/springframework/batch/admin/service/.
Source file: JdbcSearchableStepExecutionDaoTests.java

@Autowired public void setDataSource(DataSource dataSource) throws Exception { dao=new JdbcSearchableStepExecutionDao(); dao.setDataSource(dataSource); dao.afterPropertiesSet(); jobExecutionDao=new JdbcSearchableJobExecutionDao(); jobExecutionDao.setDataSource(dataSource); jobExecutionDao.afterPropertiesSet(); }
Example 12
From project spring-data-neo4j, under directory /spring-data-neo4j-examples/cineasts-rest/src/main/java/org/neo4j/cineasts/controller/.
Source file: MovieController.java

@Autowired public MovieController(CineastsRepository cineastsRepository,DatabasePopulator populator,CineastsUserDetailsService userDetailsService,Neo4jTemplate template){ this.cineastsRepository=cineastsRepository; this.populator=populator; this.userDetailsService=userDetailsService; this.template=template; }
Example 13
From project spring-framework-issues, under directory /SPR-7943/src/main/java/org/springframework/samples/mvc/data/custom/.
Source file: CustomArgumentController.java

@Autowired public CustomArgumentController(RequestMappingHandlerAdapter controllerInvoker){ WebArgumentResolver argResolver=new WebArgumentResolver(){ public Object resolveArgument( MethodParameter param, NativeWebRequest request) throws Exception { RequestAttribute attr=param.getParameterAnnotation(RequestAttribute.class); if (attr != null) { return request.getAttribute(attr.value(),WebRequest.SCOPE_REQUEST); } else { return WebArgumentResolver.UNRESOLVED; } } } ; List<HandlerMethodArgumentResolver> resolvers=new ArrayList<HandlerMethodArgumentResolver>(); resolvers.add(new ServletWebArgumentResolverAdapter(argResolver)); controllerInvoker.setCustomArgumentResolvers(resolvers); }
Example 14
From project spring-js, under directory /src/test/java/org/springframework/context/expression/.
Source file: ApplicationContextExpressionTests.java

@Autowired public ConstructorValueTestBean(@Value("XXX#{tb0.name}YYY#{mySpecialAttr}ZZZ") String name,@Value("#{mySpecialAttr}") int age,@Qualifier("original") TestBean tb,@Value("${code} #{systemProperties.country}") String country){ this.name=name; this.age=age; this.country=country; this.tb=tb; }
Example 15
From project spring-security-samples-securemail, under directory /src/main/java/org/springframework/security/samples/mail/.
Source file: JdbcMailUserService.java

@Autowired public JdbcMailUserService(JdbcTemplate jdbcTemplate){ if (jdbcTemplate == null) { throw new IllegalArgumentException("jdbcTemplate cannot be null"); } this.jdbcTemplate=jdbcTemplate; }
Example 16
From project tesb-rt-se, under directory /sam/sam-agent/src/main/java/org/talend/esb/sam/agent/collector/.
Source file: EventCollector.java

/** * Sets the handlers. * @param newHandlers the new handlers */ @Autowired(required=false) public void setHandlers(List<EventHandler> newHandlers){ this.handlers.clear(); for ( EventHandler eventHandler : newHandlers) { this.handlers.add(eventHandler); } }
Example 17
From project usergrid-stack, under directory /services/src/main/java/org/usergrid/security/tokens/cassandra/.
Source file: TokenServiceImpl.java

@Autowired public void setProperties(Properties properties){ this.properties=properties; if (properties != null) { maxPersistenceTokenAge=getExpirationProperty("persistence",maxPersistenceTokenAge); setExpirationFromProperties("access"); setExpirationFromProperties("refresh"); setExpirationFromProperties("email"); setExpirationFromProperties("offline"); tokenSecretSalt=properties.getProperty(PROPERTIES_AUTH_TOKEN_SECRET_SALT,TOKEN_SECRET_SALT); } }
Example 18
From project wayback, under directory /wayback-access-control/oracle/src/main/java/org/archive/accesscontrol/oracle/.
Source file: RulesController.java

@Autowired public RulesController(HibernateRuleDao ruleDao,AutoFormatView view){ this.ruleDao=ruleDao; this.view=view; String[] methods={"GET","PUT","DELETE","POST"}; this.setSupportedMethods(methods); }
Example 19
From project Whoops-Architecture, under directory /packages-before/src/main/java/de/olivergierke/whoops/service/account/.
Source file: AccountServiceImpl.java

/** * Creates a new {@link AccountServiceImpl}. * @param repository must not be {@literal null}. */ @Autowired public AccountServiceImpl(AccountRepository accountRepository,CustomerRepository customerRepository){ Assert.notNull(accountRepository); Assert.notNull(customerRepository); this.accountRepository=accountRepository; this.customerRepository=customerRepository; }
Example 20
From project Axon-trader, under directory /web-ui/src/main/java/org/axonframework/samples/trader/webui/companies/.
Source file: CompanyController.java

@SuppressWarnings("SpringJavaAutowiringInspection") @Autowired public CompanyController(CompanyQueryRepository companyRepository,CommandBus commandBus,UserQueryRepository userRepository,OrderBookQueryRepository orderBookRepository,TradeExecutedQueryRepository tradeExecutedRepository,PortfolioQueryRepository portfolioQueryRepository){ this.companyRepository=companyRepository; this.commandBus=commandBus; this.userRepository=userRepository; this.orderBookRepository=orderBookRepository; this.tradeExecutedRepository=tradeExecutedRepository; this.portfolioQueryRepository=portfolioQueryRepository; }
Example 21
From project Carolina-Digital-Repository, under directory /access/src/main/java/edu/unc/lib/dl/ui/util/.
Source file: AccessControlSettings.java

@Autowired(required=true) public void setProperties(Properties properties){ this.adminDatastreams=this.getUnmodifiableDatastreamSetFromProperty("access.datastream.admin",new HashSet<Datastream>(),properties,","); this.surrogateDatastreams=this.getUnmodifiableDatastreamSetFromProperty("access.datastream.surrogate",new HashSet<Datastream>(),properties,","); this.fileDatastreams=this.getUnmodifiableDatastreamSetFromProperty("access.datastream.file",new HashSet<Datastream>(),properties,","); this.recordDatastreams=this.getUnmodifiableDatastreamSetFromProperty("access.datastream.record",new HashSet<Datastream>(),properties,","); this.setAdminGroup(properties.getProperty("access.group.admin","")); this.setPublicGroup(properties.getProperty("access.group.public","")); }
Example 22
From project faces, under directory /Proyectos/primefaces-spring-security-hibernate/src/main/java/accounts/web/.
Source file: AccountController.java

@Autowired public AccountController(AccountManager accountManager){ this.accountManager=accountManager; Flash flash=FacesContext.getCurrentInstance().getExternalContext().getFlash(); flash.setKeepMessages(true); String id=(String)flash.get("id"); if (id != null) { account=this.accountManager.getAccount(new Long(id)); this.setId(id); } }
Example 23
From project lorsource, under directory /src/main/java/ru/org/linux/comment/.
Source file: CommentDaoImpl.java

@Autowired public void setDataSource(DataSource dataSource){ jdbcTemplate=new JdbcTemplate(dataSource); insertMsgbase=new SimpleJdbcInsert(dataSource); insertMsgbase.setTableName("msgbase"); insertMsgbase.usingColumns("id","message","bbcode"); }
Example 24
From project maven-deployit-plugin, under directory /spring-petclinic/src/main/java/org/springframework/samples/petclinic/jdbc/.
Source file: SimpleJdbcClinic.java

@Autowired public void init(DataSource dataSource){ this.simpleJdbcTemplate=new SimpleJdbcTemplate(dataSource); this.insertOwner=new SimpleJdbcInsert(dataSource).withTableName("owners").usingGeneratedKeyColumns("id"); this.insertPet=new SimpleJdbcInsert(dataSource).withTableName("pets").usingGeneratedKeyColumns("id"); this.insertVisit=new SimpleJdbcInsert(dataSource).withTableName("visits").usingGeneratedKeyColumns("id"); }
Example 25
From project OpenConext-teams, under directory /coin-teams-war/src/test/java/nl/surfnet/coin/teams/control/.
Source file: AbstractControllerTest.java

private void doAutoWireRemainingResources(Object target,Field[] fields) throws IllegalAccessException { for ( Field field : fields) { ReflectionUtils.makeAccessible(field); if (field.getAnnotation(Autowired.class) != null && field.get(target) == null) { field.set(target,mock(field.getType(),new DoesNothing())); } } }
Example 26
From project spring-data-jdbc-ext, under directory /spring-data-oracle-test/src/test/java/org/springframework/data/jdbc/test/adt/.
Source file: ClassicAdvancedDataTypesDao.java

@Autowired public void init(DataSource dataSource){ this.addSqlActorProc=new AddSqlActorProc(dataSource); this.getSqlActorProc=new GetSqlActorProc(dataSource); this.addActorProc=new AddActorProc(dataSource); this.getActorProc=new GetActorProc(dataSource); this.getActorNamesProc=new GetActorNamesProc(dataSource); this.deleteActorsProc=new DeleteActorsProc(dataSource); this.readActorsProc=new ReadActorsProc(dataSource); this.getActorArrayProc=new GetActorArrayProc(dataSource); this.saveActorArrayProc=new SaveActorArrayProc(dataSource); }
Example 27
From project spring-data-mongodb, under directory /spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapreduce/.
Source file: GroupByTests.java

@Autowired @SuppressWarnings("unchecked") public void setMongo(Mongo mongo) throws Exception { MongoMappingContext mappingContext=new MongoMappingContext(); mappingContext.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(XObject.class))); mappingContext.initialize(); MappingMongoConverter mappingConverter=new MappingMongoConverter(factory,mappingContext); mappingConverter.afterPropertiesSet(); this.mongoTemplate=new MongoTemplate(factory,mappingConverter); mongoTemplate.setApplicationContext(applicationContext); }