Java Code Examples for org.springframework.beans.factory.annotation.Value

The following examples show how to use org.springframework.beans.factory.annotation.Value. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: circus-train   Source File: CommonBeans.java    License: Apache License 2.0 6 votes vote down vote up
@Profile({ Modules.REPLICATION })
@Bean
Supplier<CloseableMetaStoreClient> replicaMetaStoreClientSupplier(
    ReplicaCatalog replicaCatalog,
    @Value("#{replicaHiveConf}") HiveConf replicaHiveConf,
    ConditionalMetaStoreClientFactoryManager conditionalMetaStoreClientFactoryManager) {
  String metaStoreUris = replicaCatalog.getHiveMetastoreUris();
  if (metaStoreUris == null) {
    // Default to Thrift is not specified - optional attribute in ReplicaCatalog
    metaStoreUris = ThriftHiveMetaStoreClientFactory.ACCEPT_PREFIX;
  }
  MetaStoreClientFactory replicaMetaStoreClientFactory = conditionalMetaStoreClientFactoryManager
      .factoryForUri(metaStoreUris);
  return metaStoreClientSupplier(replicaHiveConf, replicaCatalog.getName(), replicaCatalog.getMetastoreTunnel(),
      replicaMetaStoreClientFactory);
}
 
Example 2
Source Project: graphouse   Source File: ServerConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean(initMethod = "startServer")
public GraphouseWebServer server(
    @Value("${graphouse.metric-data.max-metrics-per-query}") int maxMetricsPerQuery,
    @Value("${graphouse.http.response-buffer-size-bytes}") int responseBufferSizeBytes) {

    final MetricSearchServlet metricSearchServlet = new MetricSearchServlet(
        metricSearch, statisticsService
    );

    MonitoringServlet monitoringServlet = new MonitoringServlet(monitoring, ping);

    MetricDataServiceServlet metricDataServiceServlet = new MetricDataServiceServlet(
        metricDataService, maxMetricsPerQuery, responseBufferSizeBytes
    );

    return new GraphouseWebServer(metricSearchServlet, monitoringServlet, metricDataServiceServlet);
}
 
Example 3
String handleInInterface(
@CookieValue("cookie") int cookieV,
@PathVariable("pathvar") String pathvarV,
@RequestHeader("header") String headerV,
@RequestHeader(defaultValue = "#{systemProperties.systemHeader}") String systemHeader,
@RequestHeader Map<String, Object> headerMap,
@RequestParam("dateParam") Date dateParam,
@RequestParam Map<String, Object> paramMap,
String paramByConvention,
@Value("#{request.contextPath}") String value,
@ModelAttribute("modelAttr") @Valid TestBean modelAttr,
Errors errors,
TestBean modelAttrByConvention,
Color customArg,
HttpServletRequest request,
HttpServletResponse response,
@SessionAttribute TestBean sessionAttribute,
@RequestAttribute TestBean requestAttribute,
User user,
@ModelAttribute OtherUser otherUser,
Model model,
UriComponentsBuilder builder);
 
Example 4
@Bean
public JmsMessageSender responseMessageSender(@Value("${jms-sender.ring-buffer-size}")int ringBufferSize) throws JMSException {

  DisruptorJmsMessageSender disruptorJmsMessageSender = DisruptorJmsMessageSenderFactory.create(
      responseSession(),
      responseMessageProducer(),
      new ArtemisMessageDtoDupMessageDetectStrategy(),
      ringBufferSize
  );

  Disruptor disruptor = disruptorJmsMessageSender.getDisruptor();

  BeanRegisterUtils.registerSingleton(
      applicationContext,
      "responseMessageSenderLifeCycleContainer",
      new DisruptorLifeCycleContainer("responseMessageSender", disruptor, Ordered.LOWEST_PRECEDENCE)
  );

  return disruptorJmsMessageSender;

}
 
Example 5
/***
 * Action to edit or create a teacher category
 * 
 * @param model
 * @param category the category to edit. If null it will create a new one
 * @param form the category information, {@link TeacherCategory#setCode(String)} must be unique.
 * @return
 */
@RequestMapping(method = POST, value = "categories/{category}")
public String createOrEdit(Model model, @Value("null") @PathVariable TeacherCategory category,
        @ModelAttribute CategoryBean form) {
    try {
        if (category != null) {
            service.editCategory(category, form);
        } else {
            service.createCategory(form);
        }
    } catch (Exception e) {
        model.addAttribute("error", e.getLocalizedMessage());
        model.addAttribute("form", form);
        return view("categories/create");
    }

    return "redirect:/teacher/authorizations/categories";
}
 
Example 6
@Autowired
public LightminClientProperties(final ManagementServerProperties managementServerProperties,
                                final ServerProperties serverProperties,
                                @Value("${spring.batch.lightmin.application-name:null}") final String name,
                                @Value("${endpoints.health.id:health}") final String healthEndpointId,
                                final WebEndpointProperties webEndpointProperties,
                                final Environment environment) {
    if (name == null || "null".equals(name)) {
        this.name = environment.getProperty("spring.application.name", "spring-boot-application");
    } else {
        this.name = name;
    }
    this.healthEndpointId = healthEndpointId;
    this.managementServerProperties = managementServerProperties;
    this.serverProperties = serverProperties;
    this.webEndpointProperties = webEndpointProperties;
}
 
Example 7
@Test
void valueParameterFromDefaultValueForPropertyPlaceholder(
		@Value("${bogus:false}") Boolean defaultValue) {
	assertNotNull(defaultValue,
			"Default value should have been injected via @Value by Spring");
	assertEquals(false, defaultValue, "default value");
}
 
Example 8
Source Project: blog-tutorials   Source File: WebClientConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public WebClient todoWebClient(@Value("${todo_url}") String todoUrl, @Autowired WebClient.Builder webClientBuilder) {
  return webClientBuilder
    .clone()
    .baseUrl(todoUrl)
    .defaultHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
    .build();
}
 
Example 9
Source Project: kogito-runtimes   Source File: SpringRestJobsService.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public SpringRestJobsService(
        @Value("${kogito.jobs-service.url}") String jobServiceUrl,
        @Value("${kogito.service.url}") String callbackEndpoint,
        @Autowired(required=false) RestTemplate restTemplate) {
    super(jobServiceUrl, callbackEndpoint);
    this.restTemplate = restTemplate;
}
 
Example 10
Source Project: pivotal-bank-demo   Source File: TracingConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/** Configuration for how to buffer spans into messages for Zipkin */
@Bean
Reporter<Span> reporter(
    Sender sender,
    @Value("${zipkin.self-tracing.message-timeout:1}") int messageTimeout,
    CollectorMetrics metrics) {
  return AsyncReporter.builder(sender)
      .messageTimeout(messageTimeout, TimeUnit.SECONDS)
      .metrics(new ReporterMetricsAdapter(metrics.forTransport("local")))
      .build();
}
 
Example 11
Source Project: orders   Source File: PrometheusAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(name = "prometheusMetricsServletRegistrationBean")
ServletRegistrationBean prometheusMetricsServletRegistrationBean(@Value("${prometheus.metrics" +
        ".path:/metrics}") String metricsPath) {
    DefaultExports.initialize();
    return new ServletRegistrationBean(new MetricsServlet(), metricsPath);
}
 
Example 12
Source Project: nakadi   Source File: ZookeeperSettings.java    License: MIT License 5 votes vote down vote up
@Autowired
public ZookeeperSettings(@Value("${nakadi.zookeeper.sessionTimeoutMs}") final int zkSessionTimeoutMs,
                         @Value("${nakadi.zookeeper.connectionTimeoutMs}")final int zkConnectionTimeoutMs,
                         @Value("${nakadi.zookeeper.maxInFlightRequests}") final int maxInFlightRequests) {
    this.zkSessionTimeoutMs = zkSessionTimeoutMs;
    this.zkConnectionTimeoutMs = zkConnectionTimeoutMs;
    this.maxInFlightRequests = maxInFlightRequests;
}
 
Example 13
Source Project: AppStash   Source File: CartRepositoryImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public CartRepositoryImpl(@Value("${redis.cart.microservice.url}") String baseUrl,
                          RestTemplate restTemplate) {
    this.restTemplate = restTemplate;

    CREATE_TEMPLATE = new UriTemplate(baseUrl + CREATE);
    GET_TEMPLATE = new UriTemplate(baseUrl + GET);
    ADD_TEMPLATE = new UriTemplate(baseUrl + ADD);
    REMOVE_TEMPLATE = new UriTemplate(baseUrl + REMOVE);
    CLEAR_TEMPLATE = new UriTemplate(baseUrl + CLEAR);
}
 
Example 14
Source Project: micro-server   Source File: ApplicationRegisterImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public ApplicationRegisterImpl(@Value("${host.address:#{null}}") String customHostname,
    @Value("${target.endpoint:#{null}}") String targetEndpoint,
    @Qualifier("propertyFactory") Properties props) {

    this.customHostname = customHostname;
    this.targetEndpoint = targetEndpoint;
    this.props = props;
}
 
Example 15
Source Project: data-highway   Source File: TowtruckApp.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
Supplier<String> keySupplier(Clock clock, @Value("${s3.keyPrefix}") String keyPrefix) {
  return () -> {
    long millis = clock.millis();
    String date = ISODateTimeFormat.date().withZoneUTC().print(millis);
    String time = ISODateTimeFormat.basicDateTimeNoMillis().withZoneUTC().print(millis);
    return String.format("%s/%s/%s.json.gz", keyPrefix, date, time);
  };
}
 
Example 16
Source Project: nakadi   Source File: TimelineCleanupJob.java    License: MIT License 5 votes vote down vote up
@Autowired
public TimelineCleanupJob(final EventTypeCache eventTypeCache,
                          final TimelineDbRepository timelineDbRepository,
                          final TimelineService timelineService,
                          final FeatureToggleService featureToggleService,
                          final JobWrapperFactory jobWrapperFactory,
                          @Value("${nakadi.jobs.timelineCleanup.runPeriodMs}") final int periodMs,
                          @Value("${nakadi.jobs.timelineCleanup.deletionDelayMs}") final long deletionDelayMs) {
    this.eventTypeCache = eventTypeCache;
    this.timelineDbRepository = timelineDbRepository;
    this.timelineService = timelineService;
    this.jobWrapper = jobWrapperFactory.createExclusiveJobWrapper(JOB_NAME, periodMs);
    this.featureToggleService = featureToggleService;
    this.deletionDelayMs = deletionDelayMs;
}
 
Example 17
Source Project: prebid-server-java   Source File: WebConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
AuctionHandler auctionHandler(
        ApplicationSettings applicationSettings,
        BidderCatalog bidderCatalog,
        PreBidRequestContextFactory preBidRequestContextFactory,
        CacheService cacheService,
        Metrics metrics,
        HttpAdapterConnector httpAdapterConnector,
        Clock clock,
        TcfDefinerService tcfDefinerService,
        PrivacyExtractor privacyExtractor,
        JacksonMapper mapper,
        @Value("${gdpr.host-vendor-id:#{null}}") Integer hostVendorId,
        @Value("${geolocation.enabled}") boolean useGeoLocation) {

    return new AuctionHandler(
            applicationSettings,
            bidderCatalog,
            preBidRequestContextFactory,
            cacheService,
            metrics,
            httpAdapterConnector,
            clock,
            tcfDefinerService,
            privacyExtractor,
            mapper,
            hostVendorId,
            useGeoLocation);
}
 
Example 18
Source Project: Spring-5.0-By-Example   Source File: TokenService.java    License: MIT License 5 votes vote down vote up
public TokenService(WebClient webClient,
    @Value("${auth.service}") String authService,
    @Value("${auth.path}") String authServiceApiPath,
    DiscoveryService discoveryService) {
  this.webClient = webClient;
  this.authService = authService;
  this.authServiceApiPath = authServiceApiPath;
  this.discoveryService = discoveryService;
}
 
Example 19
@Autowired
SpringJUnitJupiterAutowiredConstructorInjectionTests(ApplicationContext applicationContext, Person dilbert, Dog dog,
		@Value("${enigma}") Integer enigma) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
}
 
Example 20
Source Project: spring-cloud-gcp   Source File: WebController.java    License: Apache License 2.0 5 votes vote down vote up
@Value("${application.ocr-bucket}")
public void setOcrBucket(String ocrBucket) {
	try {
		this.storage.get(ocrBucket, BucketGetOption.fields());
	}
	catch (Exception e) {
		throw new IllegalArgumentException(
				"The bucket " + ocrBucket + " does not exist. "
						+ "Please specify a valid Google Storage bucket name "
						+ "in the resources/application.properties file. "
						+ "You can create a new bucket at: https://console.cloud.google.com/storage");
	}

	this.ocrBucket = ocrBucket;
}
 
Example 21
Source Project: pivotal-bank-demo   Source File: ZipkinQueryApiV2.java    License: Apache License 2.0 5 votes vote down vote up
ZipkinQueryApiV2(
    StorageComponent storage,
    @Value("${zipkin.storage.type:mem}") String storageType,
    @Value("${zipkin.query.lookback:86400000}") long defaultLookback, // 1 day in millis
    @Value("${zipkin.query.names-max-age:300}") int namesMaxAge // 5 minutes
    ) {
  this.storage = storage;
  this.storageType = storageType;
  this.defaultLookback = defaultLookback;
  this.namesMaxAge = namesMaxAge;
}
 
Example 22
Source Project: data-prep   Source File: MailFeedbackSender.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public void setPassword(@Value("${mail.smtp.password}") String password) {
    try {
        this.password = AESEncryption.decrypt(password);
    } catch (Exception exc) {
        LOGGER.debug("Unable to parse given password used to send feedback mails {}", password, exc);
    }
}
 
Example 23
Source Project: nakadi   Source File: PluginsConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public AuthorizationService authorizationService(@Value("${nakadi.plugins.authz.factory}") final String factoryName,
                                                 final SystemProperties systemProperties,
                                                 final DefaultResourceLoader loader) {
    try {
        LOGGER.info("Initialize per-resource authorization service factory: " + factoryName);
        final Class<AuthorizationServiceFactory> factoryClass =
                (Class<AuthorizationServiceFactory>) loader.getClassLoader().loadClass(factoryName);
        final AuthorizationServiceFactory factory = factoryClass.newInstance();
        return factory.init(systemProperties);
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        throw new BeanCreationException("Can't create AuthorizationService " + factoryName, e);
    }
}
 
Example 24
Source Project: tutorials   Source File: LoggingConfiguration.java    License: MIT License 5 votes vote down vote up
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort,
     @Value("${info.project.version:}") String version, JHipsterProperties jHipsterProperties) {
    this.appName = appName;
    this.serverPort = serverPort;
    this.version = version;
    this.jHipsterProperties = jHipsterProperties;
    if (jHipsterProperties.getLogging().getLogstash().isEnabled()) {
        addLogstashAppender(context);
        addContextListener(context);
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        setMetricsMarkerLogbackFilter(context);
    }
}
 
Example 25
Source Project: MaxKey   Source File: Saml20AutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * OpenHTTPPostSimpleSignDecoder.
 * @return openHTTPPostSimpleSignDecoder
 */
@Bean(name = "openHTTPPostSimpleSignDecoder")
public OpenHTTPPostSimpleSignDecoder openHTTPPostSimpleSignDecoder(BasicParserPool samlParserPool,
        @Value("${config.saml.v20.idp.receiver.endpoint}") String receiverEndpoint) {
    OpenHTTPPostSimpleSignDecoder decoder = new OpenHTTPPostSimpleSignDecoder(samlParserPool);
    decoder.setReceiverEndpoint(receiverEndpoint);
    return decoder;
}
 
Example 26
Source Project: cubeai   Source File: LoggingConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort,
     ConsulRegistration consulRegistration, @Value("${info.project.version}") String version, JHipsterProperties jHipsterProperties) {
    this.appName = appName;
    this.serverPort = serverPort;
    this.consulRegistration = consulRegistration;
    this.version = version;
    this.jHipsterProperties = jHipsterProperties;
    if (jHipsterProperties.getLogging().getLogstash().isEnabled()) {
        addLogstashAppender(context);
        addContextListener(context);
    }
    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        setMetricsMarkerLogbackFilter(context);
    }
}
 
Example 27
Source Project: batchers   Source File: ItemReaderWriterConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "")
@StepScope
public JpaPagingItemReader<Employee> taxCalculatorItemReaderSlave(@Value("#{stepExecution}") StepExecution stepExecution) {
    JpaPagingItemReader<Employee> employeeItemReader = new JpaPagingItemReader<>();
    employeeItemReader.setEntityManagerFactory(persistenceConfig.entityManagerFactory());
    employeeItemReader.setQueryString(TaxCalculation.GET_UNPROCESSED_EMPLOYEES_BY_YEAR_AND_MONTH_QUERY_SLAVE);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("year", stepExecution.getJobParameters().getLong("year").intValue());
    parameters.put("month", stepExecution.getJobParameters().getLong("month").intValue());
    parameters.put("jobExecutionId", stepExecution.getJobExecutionId());
    parameters.put("minId", stepExecution.getExecutionContext().getLong("minValue"));
    parameters.put("maxId", stepExecution.getExecutionContext().getLong("maxValue"));
    employeeItemReader.setParameterValues(parameters);
    return employeeItemReader;
}
 
Example 28
Source Project: entrada   Source File: S3FileManagerImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
public S3FileManagerImpl(AmazonS3 amazonS3, @Value("${aws.upload.parallelism}") int parallelism,
    @Value("${aws.upload.multipart.mb.size:5}") int multipartSize) {
  this.amazonS3 = amazonS3;

  this.transferManager = TransferManagerBuilder
      .standard()
      .withS3Client(amazonS3)
      .withMultipartUploadThreshold(multipartSize * 1024L * 1024L)
      .withExecutorFactory(() -> Executors.newFixedThreadPool(parallelism))
      .build();
}
 
Example 29
Source Project: tensorboot   Source File: ImageProcessingService.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public ImageProcessingService(MobilenetV2Classifier classifier,
                              @Value("${tensorboot.maxExecutorsCount}") int maxExecutorsCount,
                              @Value("${tensorboot.previewSize}") int previewSize
) {
    this.classifier = new PooledClassifier<>(classifier, maxExecutorsCount);
    this.previewSize = previewSize;
}
 
Example 30
Source Project: liteflow   Source File: ExecutorMetadata.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置executor运行的空间
 * @param workspace
 */
@Value("${lite.flow.executor.workspace}")
public void setExecutorWorkspace(String workspace){
    if(EXECUTOR_WORKSPACE == null){
        EXECUTOR_WORKSPACE = workspace;
    }
}