org.springframework.context.annotation.Profile Java Examples

The following examples show how to use org.springframework.context.annotation.Profile. 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: Spring-Security-Third-Edition   Author: PacktPublishing   File: CalendarApplication.java    License: MIT License 6 votes vote down vote up
@Profile("trace")
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
    return args -> {

        System.out.println("Let's inspect the beans provided by Spring Boot:\n");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }

        System.out.println("---");
    };
}
 
Example #2
Source Project: Spring-Security-Third-Edition   Author: PacktPublishing   File: CalendarApplication.java    License: MIT License 6 votes vote down vote up
@Profile("trace")
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
    return args -> {

        System.out.println("Let's inspect the beans provided by Spring Boot:\n");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }

        System.out.println("---");
    };
}
 
Example #3
Source Project: circus-train   Author: HotelsDotCom   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 #4
Source Project: circus-train   Author: HotelsDotCom   File: CommonBeans.java    License: Apache License 2.0 6 votes vote down vote up
@Profile({ Modules.REPLICATION })
@Bean
Supplier<CloseableMetaStoreClient> sourceMetaStoreClientSupplier(
    SourceCatalog sourceCatalog,
    @Value("#{sourceHiveConf}") HiveConf sourceHiveConf,
    ConditionalMetaStoreClientFactoryManager conditionalMetaStoreClientFactoryManager) {
  String metaStoreUris = sourceCatalog.getHiveMetastoreUris();
  if (metaStoreUris == null) {
    // Default to Thrift is not specified - optional attribute in SourceCatalog
    metaStoreUris = ThriftHiveMetaStoreClientFactory.ACCEPT_PREFIX;
  }
  MetaStoreClientFactory sourceMetaStoreClientFactory = conditionalMetaStoreClientFactoryManager
      .factoryForUri(metaStoreUris);
  return metaStoreClientSupplier(sourceHiveConf, sourceCatalog.getName(), sourceCatalog.getMetastoreTunnel(),
      sourceMetaStoreClientFactory);
}
 
Example #5
Source Project: spring-in-action-5-samples   Author: habuma   File: FileWriterIntegrationConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Profile("javaconfig")
@Bean
@Transformer(inputChannel="textInChannel",
             outputChannel="fileWriterChannel")
public GenericTransformer<String, String> upperCaseTransformer() {
  return text -> text.toUpperCase();
}
 
Example #6
Source Project: Spring-Security-Third-Edition   Author: PacktPublishing   File: CalendarApplication.java    License: MIT License 6 votes vote down vote up
@Profile("trace")
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
    return args -> {

        System.out.println("Let's inspect the beans provided by Spring Boot:\n");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }

        System.out.println("---");
    };
}
 
Example #7
Source Project: Spring-Security-Third-Edition   Author: PacktPublishing   File: CalendarApplication.java    License: MIT License 6 votes vote down vote up
@Profile("trace")
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
    return args -> {

        System.out.println("Let's inspect the beans provided by Spring Boot:\n");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }

        System.out.println("---");
    };
}
 
Example #8
Source Project: Spring-Security-Third-Edition   Author: PacktPublishing   File: CalendarApplication.java    License: MIT License 6 votes vote down vote up
@Profile("trace")
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
    return args -> {

        System.out.println("Let's inspect the beans provided by Spring Boot:\n");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }

        System.out.println("---");
    };
}
 
Example #9
Source Project: Spring-Security-Third-Edition   Author: PacktPublishing   File: CalendarApplication.java    License: MIT License 6 votes vote down vote up
@Profile("trace")
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
    return args -> {

        System.out.println("Let's inspect the beans provided by Spring Boot:\n");

        String[] beanNames = ctx.getBeanDefinitionNames();
        Arrays.sort(beanNames);
        for (String beanName : beanNames) {
            System.out.println(beanName);
        }

        System.out.println("---");
    };
}
 
Example #10
Source Project: spring-cloud-skipper   Author: spring-cloud   File: SkipperServerPlatformConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
@Profile("local")
public Platform localDeployers(LocalPlatformProperties localPlatformProperties) {
	List<Deployer> deployers = new ArrayList<>();
	Map<String, LocalDeployerProperties> localDeployerPropertiesMap = localPlatformProperties.getAccounts();
	if (localDeployerPropertiesMap.isEmpty()) {
		localDeployerPropertiesMap.put("default", new LocalDeployerProperties());
	}
	for (Map.Entry<String, LocalDeployerProperties> entry : localDeployerPropertiesMap
			.entrySet()) {
		LocalAppDeployer localAppDeployer = new LocalAppDeployer(entry.getValue());
		Deployer deployer = new Deployer(entry.getKey(), "local", localAppDeployer);
		deployer.setDescription(prettyPrintLocalDeployerProperties(entry.getValue()));
		deployers.add(deployer);
	}

	return new Platform("Local", deployers);
}
 
Example #11
Source Project: airsonic   Author: airsonic   File: DatabaseConfiguration.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Bean
@Profile("legacy")
public DataSource legacyDataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
    dataSource.setUrl(SettingsService.getDefaultJDBCUrl());
    dataSource.setUsername(SettingsService.getDefaultJDBCUsername());
    dataSource.setPassword(SettingsService.getDefaultJDBCPassword());
    return dataSource;
}
 
Example #12
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #13
Source Project: spring-boot-data-geode   Author: spring-projects   File: SpringBootApacheGeodeLocatorApplication.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Profile("locator-configurer")
LocatorConfigurer clusterLocatorConfigurer(
	@Value("${spring.data.gemfire.locators:localhost[10334]}") String locators) {

	return (beanName, bean) -> bean.getGemFireProperties()
		.setProperty(GemFireProperties.LOCATORS.toString(), locators);
}
 
Example #14
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #15
Source Project: code   Author: lastwhispers   File: MainConfigofProfile.java    License: Apache License 2.0 5 votes vote down vote up
@Profile("test")
@Bean("testDataSource")
public DataSource dataSourceTest(@Value("${db.password}") String pwd) throws PropertyVetoException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setUser(user);
    dataSource.setPassword(pwd);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test");
    return dataSource;
}
 
Example #16
Source Project: code   Author: lastwhispers   File: MainConfigofProfile.java    License: Apache License 2.0 5 votes vote down vote up
@Profile("dev")
@Bean("devDataSource")
public DataSource dataSourceDev(@Value("${db.password}") String pwd) throws PropertyVetoException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setUser(user);
    dataSource.setPassword(pwd);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/dev");
    return dataSource;
}
 
Example #17
Source Project: code   Author: lastwhispers   File: MainConfigofProfile.java    License: Apache License 2.0 5 votes vote down vote up
@Profile("prod")
@Bean("prodDataSource")
public DataSource dataSourceProd(@Value("${db.password}") String pwd) throws PropertyVetoException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setUser(user);
    dataSource.setPassword(pwd);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/prod");
    return dataSource;
}
 
Example #18
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #19
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #20
Source Project: java-microservices-examples   Author: oktadeveloper   File: DatabaseConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Open the TCP port for the H2 database, so it is available remotely.
 *
 * @return the H2 database TCP server.
 * @throws SQLException if the server failed to start.
 */
@Bean(initMethod = "start", destroyMethod = "stop")
@Profile(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
public Object h2TCPServer() throws SQLException {
    String port = getValidPortForH2();
    log.debug("H2 database is available on port {}", port);
    return H2ConfigurationHelper.createServer(port);
}
 
Example #21
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #22
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #23
Source Project: library   Author: ddd-by-examples   File: CatalogueConfiguration.java    License: MIT License 5 votes vote down vote up
@Profile("local")
@Bean
CommandLineRunner init(Catalogue catalogue) {
    return args -> {
        catalogue.addBook("Joshua Bloch", "Effective Java", "0321125215").get();
        catalogue.addBookInstance("0321125215", BookType.Restricted).get();
    };
}
 
Example #24
Source Project: kafka-with-springboot   Author: ayortanli   File: Application.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Profile("!test")
public CommandLineRunner batchMessageConsumerRunner() {
    return args -> {
        //Just comment out the examples to run
        //simpleKafkaMessagingExample.execute();
        //multiPartitionMessagingExample.execute();
        //batchMessageConsumingExample.execute();
        //kafkaStreamExample.execute();
    };
}
 
Example #25
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #26
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #27
Source Project: spring-reactive-sample   Author: hantsy   File: Application.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Profile("default")
@Bean
public HttpServer nettyHttpServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create().host("localhost").port(this.port);
    return httpServer.handle(adapter);
}
 
Example #28
Source Project: okta-jhipster-microservices-oauth-example   Author: oktadeveloper   File: DatabaseConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Open the TCP port for the H2 database, so it is available remotely.
 *
 * @return the H2 database TCP server
 * @throws SQLException if the server failed to start
 */
@Bean(initMethod = "start", destroyMethod = "stop")
@Profile(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
public Object h2TCPServer() throws SQLException {
    log.debug("Starting H2 database");
    return H2ConfigurationHelper.createServer();
}
 
Example #29
Source Project: circus-train   Author: HotelsDotCom   File: CircusTrain.java    License: Apache License 2.0 5 votes vote down vote up
@Profile({ Modules.REPLICATION })
@Bean
PartitionTransformation partitionTransformation(List<PartitionTransformation> transformations) {
  if (transformations == null) {
    transformations = Collections.emptyList();
  }
  return new CompositePartitionTransformation(transformations);
}
 
Example #30
Source Project: inception   Author: inception-project   File: InceptionSecurity.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(name = "authenticationProvider")
@Profile("auto-mode-preauth")
public PreAuthenticatedAuthenticationProvider externalAuthenticationProvider()
{
    PreAuthenticatedAuthenticationProvider authProvider = 
            new PreAuthenticatedAuthenticationProvider();
    authProvider.setPreAuthenticatedUserDetailsService(
            new UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken>(
                    userDetailsService()));
    return authProvider;
}