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

The following examples show how to use org.springframework.beans.factory.annotation.Value. 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 File: LightminClientProperties.java    From spring-batch-lightmin with Apache License 2.0 6 votes vote down vote up
@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 #2
Source File: JmsServerConfiguration.java    From artemis-disruptor-miaosha with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: CommonBeans.java    From circus-train with 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 #4
Source File: ServerConfig.java    From graphouse with 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 #5
Source File: RequestMappingHandlerAdapterIntegrationTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
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 #6
Source File: AuthorizationController.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
/***
 * 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 #7
Source File: KeyValueV2Refresh.java    From vault-crd with Apache License 2.0 5 votes vote down vote up
public KeyValueV2Refresh(@Value("${kubernetes.crd.name}") String crdName,
                         KubernetesService kubernetesService,
                         TypedSecretGeneratorFactory typedSecretGeneratorFactory) {
    this.crdName = crdName;
    this.kubernetesService = kubernetesService;
    this.typedSecretGeneratorFactory = typedSecretGeneratorFactory;
}
 
Example #8
Source File: ReverseProxyIdolSecurityCustomizer.java    From find with MIT License 5 votes vote down vote up
@Autowired
public ReverseProxyIdolSecurityCustomizer(
        final UserService userService,
        final GrantedAuthoritiesMapper grantedAuthoritiesMapper,
        @Value("${find.reverse-proxy.pre-authenticated-roles}") final String preAuthenticatedRoles,
        @Value("${find.reverse-proxy.pre-authenticated-username}") final String preAuthenticatedUsername
) {

    this.userService = userService;
    this.grantedAuthoritiesMapper = grantedAuthoritiesMapper;
    this.preAuthenticatedRoles = preAuthenticatedRoles;
    this.preAuthenticatedUsername = preAuthenticatedUsername;
}
 
Example #9
Source File: ActivityServiceImpl.java    From retro-game with GNU Affero General Public License v3.0 5 votes vote down vote up
public ActivityServiceImpl(UserRepository userRepository,
                           @Value("${retro-game.short-inactive-number-of-days}") int numberOfDaysForShortInactive,
                           @Value("${retro-game.long-inactive-number-of-days}") int numberOfDaysForLongInactive) {
  this.userRepository = userRepository;
  this.numberOfDaysForShortInactive = numberOfDaysForShortInactive;
  this.numberOfDaysForLongInactive = numberOfDaysForLongInactive;
}
 
Example #10
Source File: CredentialValidator.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
public CredentialValidator(@Value("${environment.enabledplatforms}") Set<String> enabledPlatforms,
        CredentialDefinitionService credentialDefinitionService,
        List<ProviderCredentialValidator> providerCredentialValidators,
        EntitlementService entitlementService) {
    this.enabledPlatforms = enabledPlatforms;
    this.credentialDefinitionService = credentialDefinitionService;
    providerCredentialValidators.forEach(validator -> providerValidators.put(validator.supportedProvider(), validator));
    this.entitlementService = entitlementService;
}
 
Example #11
Source File: RabbitMQConfiguration.java    From Spring-5.0-By-Example with MIT License 5 votes vote down vote up
public RabbitMQConfiguration(@Value("${amqp.payments.queue.request}") String paymentRequestQueue,
                             @Value("${amqp.payments.queue.response}")String paymentResponseQueue,
                             @Value("${amqp.payments.exchange.payment}")String paymentExchange,
                             @Value("${amqp.payments.key.request}")String paymentRequestKey,
                             @Value("${amqp.payments.key.response}")String paymentResponseKey){
  this.paymentRequestQueue = paymentRequestQueue;
  this.paymentResponseQueue = paymentResponseQueue;
  this.paymentExchange = paymentExchange;
  this.paymentRequestKey = paymentRequestKey;
  this.paymentResponseKey = paymentResponseKey;
}
 
Example #12
Source File: LoggingConfiguration.java    From tutorials with 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 #13
Source File: MailFeedbackSender.java    From data-prep with 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 #14
Source File: S3FileManagerImpl.java    From entrada with 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 #15
Source File: DiscoveryNodeController.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
@Autowired
public DiscoveryNodeController(NodeStorage storage,
                               @Value("${dm.agent.notifier.secret:}") String nodeSecret,
                               @Value("${dm.agent.start}") String startString) {
    this.storage = storage;
    this.startString = startString;
    this.nodeSecret = Strings.emptyToNull(nodeSecret);
}
 
Example #16
Source File: ImageProcessingService.java    From tensorboot with 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 #17
Source File: ExpiredTokenCleanUpJob.java    From cerberus with Apache License 2.0 5 votes vote down vote up
@Autowired
public ExpiredTokenCleanUpJob(
    AuthTokenService authTokenService,
    @Value("${cerberus.jobs.expiredTokenCleanUpJob.maxNumberOfTokensToDeletePerJobRun}")
        int maxNumberOfTokensToDeletePerJobRun,
    @Value("${cerberus.jobs.expiredTokenCleanUpJob.numberOfTokensToDeletePerBatch}")
        int numberOfTokensToDeletePerBatch,
    @Value("${cerberus.jobs.expiredTokenCleanUpJob.batchPauseTimeInMillis}")
        int batchPauseTimeInMillis) {

  this.authTokenService = authTokenService;
  this.maxNumberOfTokensToDeletePerJobRun = maxNumberOfTokensToDeletePerJobRun;
  this.numberOfTokensToDeletePerBatch = numberOfTokensToDeletePerBatch;
  this.batchPauseTimeInMillis = batchPauseTimeInMillis;
}
 
Example #18
Source File: Impl.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Value(value = "${service_description.name}")
public void setSelfMicroserviceName(String selfMicroserviceName) {
  // self: perf-1/perf-a
  // next: perf-2/perf-b
  char last = selfMicroserviceName.charAt(selfMicroserviceName.length() - 1);
  String nextMicroserviceName =
      selfMicroserviceName.substring(0, selfMicroserviceName.length() - 1) + (char) (last + 1);
  intf = Invoker.createProxy(nextMicroserviceName,
      "impl",
      Intf.class);
}
 
Example #19
Source File: PaymentRequesterService.java    From Spring-5.0-By-Example with MIT License 5 votes vote down vote up
public PaymentRequesterService(@Value("${amqp.payments.exchange.payment}") String paymentExchange,
    @Value("${amqp.payments.key.request}") String requestPaymentKey,
    AsyncRabbitTemplate asyncRabbitTemplate) {
  this.paymentExchange = paymentExchange;
  this.requestPaymentKey = requestPaymentKey;
  this.asyncRabbitTemplate = asyncRabbitTemplate;
}
 
Example #20
Source File: KafkaGateway.java    From integration-patterns with MIT License 5 votes vote down vote up
@Inject
public KafkaGateway(final KafkaTemplate<String, String> kafkaTemplate, final ObjectMapper objectMapper,
    @Value("${eventing.topic.product}") final String topic) {
    this.kafkaTemplate = kafkaTemplate;
    this.objectMapper = objectMapper;
    this.topic = topic;
}
 
Example #21
Source File: SecuritySettings.java    From nakadi with MIT License 5 votes vote down vote up
@Autowired
public SecuritySettings(@Value("${nakadi.oauth2.tokenInfoUrl}") final String tokenInfoUrl,
                        @Value("${nakadi.oauth2.localTokenInfoUrl}") final String localTokenInfoUrl,
                        @Value("${nakadi.oauth2.clientId}") final String clientId,
                        @Value("${nakadi.oauth2.mode:BASIC}") final AuthMode authMode,
                        @Value("${nakadi.oauth2.adminClientId}") final String adminClientId) {
    this.tokenInfoUrl = tokenInfoUrl;
    this.localTokenInfoUrl = localTokenInfoUrl;
    this.clientId = clientId;
    this.authMode = authMode;
    this.adminClientId = adminClientId;
}
 
Example #22
Source File: ExecutorMetadata.java    From liteflow with 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;
    }
}
 
Example #23
Source File: ItemReaderWriterConfig.java    From batchers with 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 #24
Source File: LoggingConfiguration.java    From cubeai with 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 #25
Source File: Saml20AutoConfiguration.java    From MaxKey with 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 File: LoggingConfiguration.java    From tutorials with 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 #27
Source File: PluginsConfig.java    From nakadi with 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 #28
Source File: ZipkinQueryApiV2.java    From pivotal-bank-demo with 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 #29
Source File: WebController.java    From spring-cloud-gcp with 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 #30
Source File: SpringJUnitJupiterAutowiredConstructorInjectionTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Autowired
SpringJUnitJupiterAutowiredConstructorInjectionTests(ApplicationContext applicationContext, Person dilbert, Dog dog,
		@Value("${enigma}") Integer enigma) {

	this.applicationContext = applicationContext;
	this.dilbert = dilbert;
	this.dog = dog;
	this.enigma = enigma;
}