Java Code Examples for org.springframework.context.annotation.Profile

The following examples show how to use org.springframework.context.annotation.Profile. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@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
@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   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 4
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> 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
@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 6
@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
@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
@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
@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 10
@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 11
@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 12
@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 13
@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 14
Source Project: code   Source 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 15
Source Project: code   Source 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 16
Source Project: code   Source 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 17
@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 18
@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
/**
 * 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 20
@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 21
@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: library   Source 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 23
Source Project: kafka-with-springboot   Source 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 24
@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 25
@Profile("javaconfig")
@Bean
@Transformer(inputChannel="textInChannel",
             outputChannel="fileWriterChannel")
public GenericTransformer<String, String> upperCaseTransformer() {
  return text -> text.toUpperCase();
}
 
Example 26
@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
@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
/**
 * 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   Source 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   Source 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;
}