@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 } }
@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 } }
@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"); }
@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; }
@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; }
@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; }
@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)); } }
@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; }
/** * 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; }
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); }
@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; }
@Override @Bean(autowire = Autowire.BY_TYPE) public DatabaseBackedPagingProvider databaseBackedPagingProvider() { DatabaseBackedPagingProvider retVal = super.databaseBackedPagingProvider(); retVal.setDefaultPageSize(20); retVal.setMaximumPageSize(500); return retVal; }
@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"); }
@Bean(autowire=Autowire.BY_NAME) @ConditionalOnMissingBean(name="groovyPagesTemplateEngine") GroovyPagesTemplateEngine groovyPagesTemplateEngine() { GroovyPagesTemplateEngine templateEngine = new GroovyPagesTemplateEngine(); templateEngine.setReloadEnabled(gspReloadingEnabled); return templateEngine; }
@Bean(autowire = Autowire.BY_TYPE) ControllerLinkBuilderFactory foo() { return new ControllerLinkBuilderFactory(); }
/** * 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; }
@Bean(autowire = Autowire.BY_TYPE) public IServerInterceptor subscriptionSecurityInterceptor() { SubscriptionsRequireManualActivationInterceptorDstu3 retVal = new SubscriptionsRequireManualActivationInterceptorDstu3(); return retVal; }
@Bean(autowire = Autowire.BY_TYPE) public IServerInterceptor subscriptionSecurityInterceptor() { SubscriptionsRequireManualActivationInterceptorDstu2 retVal = new SubscriptionsRequireManualActivationInterceptorDstu2(); return retVal; }
@Bean(autowire = Autowire.BY_TYPE) public DatabaseBackedPagingProvider databaseBackedPagingProvider() { DatabaseBackedPagingProvider retVal = new DatabaseBackedPagingProvider(); return retVal; }
public void setAutowire(Autowire autowire) { this.autowire = autowire; }
public Autowire getAutowire() { return autowire; }
@Bean(autowire = Autowire.BY_TYPE) public IServerInterceptor responseHighlighterInterceptor() { return new ResponseHighlighterInterceptor(); }
@Bean(autowire = Autowire.BY_TYPE) public IServerInterceptor subscriptionSecurityInterceptor() { return new SubscriptionsRequireManualActivationInterceptorDstu3(); }
@Bean(autowire = Autowire.BY_NAME,name = "salesEventBus") public EventBus salesEventBus() { return new EventBus(); }
@Bean(autowire = Autowire.BY_NAME,name = "buysEventBus") public EventBus buysEventBus() { return new EventBus(); }
@Override public void prepareAction(IAction<?> action) { applicationContext.getAutowireCapableBeanFactory().autowireBeanProperties(action, Autowire.BY_TYPE.value(), true); }
@Bean(autowire = Autowire.BY_TYPE) public IServerInterceptor subscriptionSecurityInterceptor() { SubscriptionsRequireManualActivationInterceptorR4 retVal = new SubscriptionsRequireManualActivationInterceptorR4(); return retVal; }