Java 类org.springframework.beans.factory.annotation.Autowire 实例源码
项目:spring4-understanding
文件:AbstractPropertyAccessorTests.java
@Test
public void setEnumProperty() {
EnumTester target = new EnumTester();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.setPropertyValue("autowire", "BY_NAME");
assertEquals(Autowire.BY_NAME, target.getAutowire());
accessor.setPropertyValue("autowire", " BY_TYPE ");
assertEquals(Autowire.BY_TYPE, target.getAutowire());
try {
accessor.setPropertyValue("autowire", "NHERITED");
fail("Should have thrown TypeMismatchException");
}
catch (TypeMismatchException ex) {
// expected
}
}
项目:class-guard
文件:BeanWrapperTests.java
@Test
public void testEnumByFieldName() {
EnumTester et = new EnumTester();
BeanWrapper bw = new BeanWrapperImpl(et);
bw.setPropertyValue("autowire", "BY_NAME");
assertEquals(Autowire.BY_NAME, et.getAutowire());
bw.setPropertyValue("autowire", " BY_TYPE ");
assertEquals(Autowire.BY_TYPE, et.getAutowire());
try {
bw.setPropertyValue("autowire", "NHERITED");
fail("Should have thrown TypeMismatchException");
}
catch (TypeMismatchException ex) {
// expected
}
}
项目:searchanalytics-bigdata
文件:AppConfiguration.java
@Bean(autowire = Autowire.BY_NAME, name = "setupIndexMasterActor")
// @Scope("prototype")
@DependsOn(value = { "actorSystem" })
public ActorRef setupIndexMasterActor() {
final ActorSystem system = applicationContext
.getBean(ActorSystem.class);
final SetupIndexService setupIndexService = applicationContext
.getBean(SetupIndexService.class);
final SampleDataGeneratorService sampleDataGeneratorService = applicationContext
.getBean(SampleDataGeneratorService.class);
final IndexProductDataService indexProductData = applicationContext
.getBean(IndexProductDataService.class);
return system.actorOf(
Props.create(SetupIndexMasterActor.class, setupIndexService,
sampleDataGeneratorService, indexProductData)
.withDispatcher("setupIndexMasterActorDispatch"),
"setupIndexMasterActor");
}
项目:upns
文件:GroupRepositoryConfig.java
@Bean(autowire = Autowire.BY_TYPE, name = "ctu.upns.groupRepository")
public GroupRepository instance() {
if (repository != null) {
return repository;
}
switch (type) {
case "memory":
repository = new MemGroupRepository();
case "mongo":
repository = new MongoGroupRepository();
}
Validate.notNull(repository, "invalid repository type:[%s]", type);
return repository;
}
项目:upns
文件:DeviceRepositoryConfig.java
@Bean(autowire = Autowire.BY_TYPE, name = "ctu.upns.deviceRepository")
public DeviceRepository instance() {
if (repository != null) {
return repository;
}
switch (type) {
case "memory":
repository = new MemDeviceRepository();
case "mongo":
repository = new MongoDeviceRepository();
}
Validate.notNull(repository, "invalid repository type:[%s]", type);
return repository;
}
项目:upns
文件:MessageRepositoryConfig.java
@Bean(autowire = Autowire.BY_TYPE, name = "ctu.upns.messageRepository")
public MessageRepository instance() {
if (repository != null) {
return repository;
}
switch (type) {
case "memory":
repository = new MemMessageRepository();
case "mongo":
repository = new MongoMessageRepository();
}
Validate.notNull(repository, "invalid repository type:[%s]", type);
return repository;
}
项目:upns
文件:SubscriberManagerConfig.java
@Bean(autowire = Autowire.BY_TYPE, name = "ctu.upns.subscriberManager")
public SubscriberManager instance() {
if (subscriberManager != null) {
return subscriberManager;
}
switch (service_type) {
case "memory":
subscriberManager = new MemSubscriberManager();
return subscriberManager;
case "mongo":
return null;
default:
throw new IllegalArgumentException(String.format("invalid service type", service_type));
}
}
项目:phoenix.webui.framework
文件:MailConfig.java
@Bean(autowire = Autowire.BY_TYPE)
public MailSender mailBean()
{
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(mailHost);
mailSender.setUsername(mailUserName);
mailSender.setPassword(mailPassword);
setUpMailPro(mailSender);
return mailSender;
}
项目:artifactory
文件:DbConfigFactory.java
/**
* create a query builder instance per db type
*
* @return query builder instance
*/
@Bean(name = "queryBuilder", autowire = Autowire.BY_TYPE)
public IQueryBuilder createSqlBuilder() throws SQLException {
JdbcHelper jdbcHelper = beanFactory.getBean(JdbcHelper.class);
StorageProperties storageProperties = beanFactory.getBean(StorageProperties.class);
String productName = storageProperties.getDbType().toString();
Connection connection = jdbcHelper.getDataSource().getConnection();
connection.close();
IQueryBuilder queryBuilder;
switch (productName) {
case "oracle":
queryBuilder = new OracleQueryBuilder();
break;
case "mssql":
queryBuilder = new SqlServerQueryBuilder();
break;
case "derby":
queryBuilder = new DerbyQueryBuilder();
break;
case "postgresql":
queryBuilder = new PostgresqlQueryBuilder();
break;
case "mysql":
queryBuilder = new MysqlQueryBuilder();
break;
default:
queryBuilder = new DerbyQueryBuilder();
break;
}
return queryBuilder;
}
项目:artifactory
文件:DbTestConfigFactory.java
/**
* create a query builder instance per db type
*
* @return query builder instance
*/
@Bean(name = "queryBuilder", autowire = Autowire.BY_TYPE)
public IQueryBuilder createSqlBuilder() throws SQLException {
JdbcHelper jdbcHelper = beanFactory.getBean(JdbcHelper.class);
StorageProperties storageProperties = beanFactory.getBean(StorageProperties.class);
String productName = storageProperties.getDbType().toString();
Connection connection = jdbcHelper.getDataSource().getConnection();
connection.close();
IQueryBuilder queryBuilder;
switch (productName) {
case "oracle":
queryBuilder = new OracleQueryBuilder();
break;
case "mssql":
queryBuilder = new SqlServerQueryBuilder();
break;
case "derby":
queryBuilder = new DerbyQueryBuilder();
break;
case "postgresql":
queryBuilder = new PostgresqlQueryBuilder();
break;
case "mysql":
queryBuilder = new MysqlQueryBuilder();
break;
default:
queryBuilder = new DerbyQueryBuilder();
break;
}
return queryBuilder;
}
项目:spring-scaffy
文件:ProductFactory.java
private void registerProduct(
ProductLine productLineAnnotation,
BeanDefinition runtimeBean,
BeanDefinition productLineBean) throws NotFoundException,
CannotCompileException, InstantiationException, IllegalAccessException, ClassNotFoundException {
Annotation targetAnnotation = getTargetAnnotation(runtimeBean, productLineAnnotation.runtimeAnnotationClass());
Class<?> productClass = productLineAnnotation.productClass();
logger.info(
"Weaving " + targetAnnotation.annotationType().getName() +
", on Product Type " + productClass.getName() +
", using Product Factory Line: " + productLineBean.getBeanClassName()
);
ProductFactoryLine productLine = (ProductFactoryLine) Class.forName(productLineBean.getBeanClassName()).newInstance();
Class<?> annotatedProductClass = weave(
productClass.getName(),
runtimeBean.getBeanClassName(),
productLine.createWeavelets(targetAnnotation)
);
Class<?> runtimeBeanClass = Class.forName(runtimeBean.getBeanClassName());
RootBeanDefinition productBean = new RootBeanDefinition(annotatedProductClass, Autowire.BY_TYPE.value(), true);
RootBeanDefinition runtimeBeanDef = new RootBeanDefinition(runtimeBeanClass, Autowire.BY_TYPE.value(), true);
productLine.beforeRegistration(targetAnnotation, productBean, runtimeBeanDef);
registry.registerBeanDefinition(annotatedProductClass.getName(), productBean);
if(productLineAnnotation.registerRuntimeBean())
registry.registerBeanDefinition(runtimeBeanClass.getName(), runtimeBeanDef);
}
项目:mcs
文件:MatchmakerCloudSearchConfiguration.java
@Bean(name = "jsonObjectMapper", autowire = Autowire.BY_NAME)
public ObjectMapper jsonObjectMapper() {
ObjectMapper bean = new ObjectMapper(new JsonFactory());
bean.disableDefaultTyping();
bean.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
bean.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
bean.disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS);
bean.setSerializationInclusion(JsonInclude.Include.NON_NULL);
bean.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
//bean.registerSubtypes(LookupResult.class);
return bean;
}
项目:hapi-fhir
文件:TestR4Config.java
@Override
@Bean(autowire = Autowire.BY_TYPE)
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
DatabaseBackedPagingProvider retVal = super.databaseBackedPagingProvider();
retVal.setDefaultPageSize(20);
retVal.setMaximumPageSize(500);
return retVal;
}
项目:hapi-fhir
文件:TestDstu3Config.java
@Override
@Bean(autowire = Autowire.BY_TYPE)
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
DatabaseBackedPagingProvider retVal = super.databaseBackedPagingProvider();
retVal.setDefaultPageSize(20);
retVal.setMaximumPageSize(500);
return retVal;
}
项目:elasticsearch-akka
文件:AppConfiguration.java
@Bean(autowire = Autowire.BY_NAME, name = "setupIndexMasterActor")
// @Scope("prototype")
@DependsOn(value = { "actorSystem" })
public ActorRef setupIndexMasterActor()
{
final ActorSystem system = applicationContext.getBean(ActorSystem.class);
final SetupIndexService setupIndexService = applicationContext.getBean(SetupIndexService.class);
final SampleDataGeneratorService sampleDataGeneratorService = applicationContext.getBean(SampleDataGeneratorService.class);
final IndexProductDataService indexProductData = applicationContext.getBean(IndexProductDataService.class);
return system.actorOf(Props.create(SetupIndexMasterActor.class, setupIndexService, sampleDataGeneratorService, indexProductData)
.withDispatcher("setupIndexMasterActorDispatch"), "setupIndexMasterActor");
}
项目:grails-boot
文件:GspAutoConfiguration.java
@Bean(autowire=Autowire.BY_NAME)
@ConditionalOnMissingBean(name="groovyPagesTemplateEngine")
GroovyPagesTemplateEngine groovyPagesTemplateEngine() {
GroovyPagesTemplateEngine templateEngine = new GroovyPagesTemplateEngine();
templateEngine.setReloadEnabled(gspReloadingEnabled);
return templateEngine;
}
项目:sos
文件:RestCatalogApplication.java
@Bean(autowire = Autowire.BY_TYPE)
ControllerLinkBuilderFactory foo() {
return new ControllerLinkBuilderFactory();
}
项目:DHIS2-fhir-lab-app
文件:FhirServerConfigDstu3.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:DHIS2-fhir-lab-app
文件:FhirServerConfigDstu3.java
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor subscriptionSecurityInterceptor() {
SubscriptionsRequireManualActivationInterceptorDstu3 retVal = new SubscriptionsRequireManualActivationInterceptorDstu3();
return retVal;
}
项目:DHIS2-fhir-lab-app
文件:FhirServerConfig.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:DHIS2-fhir-lab-app
文件:FhirServerConfig.java
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor subscriptionSecurityInterceptor() {
SubscriptionsRequireManualActivationInterceptorDstu2 retVal = new SubscriptionsRequireManualActivationInterceptorDstu2();
return retVal;
}
项目:careconnect-reference-implementation
文件:HAPIRestfulConfig.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:careconnect-reference-implementation
文件:HAPIRestfulConfig.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:careconnect-reference-implementation
文件:Config.java
@Bean(autowire = Autowire.BY_TYPE)
public DatabaseBackedPagingProvider databaseBackedPagingProvider() {
DatabaseBackedPagingProvider retVal = new DatabaseBackedPagingProvider();
return retVal;
}
项目:careconnect-reference-implementation
文件:HAPIRestfulConfig.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:spring4-understanding
文件:AbstractPropertyAccessorTests.java
public void setAutowire(Autowire autowire) {
this.autowire = autowire;
}
项目:spring4-understanding
文件:AbstractPropertyAccessorTests.java
public Autowire getAutowire() {
return autowire;
}
项目:isc-hapi-fhir-jpaserver
文件:FhirServerConfig.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:isc-hapi-fhir-jpaserver
文件:FhirServerConfig.java
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor subscriptionSecurityInterceptor() {
SubscriptionsRequireManualActivationInterceptorDstu3 retVal = new SubscriptionsRequireManualActivationInterceptorDstu3();
return retVal;
}
项目:cqf-ruler
文件:FhirServerConfigDstu3.java
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
return new ResponseHighlighterInterceptor();
}
项目:cqf-ruler
文件:FhirServerConfigDstu3.java
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor subscriptionSecurityInterceptor() {
return new SubscriptionsRequireManualActivationInterceptorDstu3();
}
项目:testeverything
文件:MultipleEventBusConfig.java
@Bean(autowire = Autowire.BY_NAME,name = "salesEventBus")
public EventBus salesEventBus() {
return new EventBus();
}
项目:testeverything
文件:MultipleEventBusConfig.java
@Bean(autowire = Autowire.BY_NAME,name = "buysEventBus")
public EventBus buysEventBus() {
return new EventBus();
}
项目:owsi-core-parent
文件:SpringActionFactory.java
@Override
public void prepareAction(IAction<?> action) {
applicationContext.getAutowireCapableBeanFactory().autowireBeanProperties(action, Autowire.BY_TYPE.value(), true);
}
项目:fhirstarters
文件:FhirServerConfigDstu3.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:fhirstarters
文件:FhirServerConfigDstu3.java
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor subscriptionSecurityInterceptor() {
SubscriptionsRequireManualActivationInterceptorDstu3 retVal = new SubscriptionsRequireManualActivationInterceptorDstu3();
return retVal;
}
项目:hapi-fhir
文件:FhirServerConfigDstu3.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:hapi-fhir
文件:FhirServerConfigDstu3.java
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor subscriptionSecurityInterceptor() {
SubscriptionsRequireManualActivationInterceptorDstu3 retVal = new SubscriptionsRequireManualActivationInterceptorDstu3();
return retVal;
}
项目:hapi-fhir
文件:FhirServerConfigR4.java
/**
* This interceptor adds some pretty syntax highlighting in responses when a browser is detected
*/
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor responseHighlighterInterceptor() {
ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor();
return retVal;
}
项目:hapi-fhir
文件:FhirServerConfigR4.java
@Bean(autowire = Autowire.BY_TYPE)
public IServerInterceptor subscriptionSecurityInterceptor() {
SubscriptionsRequireManualActivationInterceptorR4 retVal = new SubscriptionsRequireManualActivationInterceptorR4();
return retVal;
}