Ejemplo n.º 1
1
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean()
      throws ClassNotFoundException {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan(
        environment.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);

    Properties jpaProterties = new Properties();
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_DIALECT,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_FORMAT_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProterties.put(
        PROPERTY_NAME_HIBERNATE_SHOW_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));

    entityManagerFactoryBean.setJpaProperties(jpaProterties);

    return entityManagerFactoryBean;
  }
Ejemplo n.º 2
1
  @Bean
  LocalContainerEntityManagerFactoryBean entityManagerFactory(
      DataSource dataSource, Environment env) {

    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setDataSource(dataSource);
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan("es.udc.lbd.rie");

    Properties jpaProperties = new Properties();

    // Configures the used database dialect. This allows Hibernate to create SQL
    // that is optimized for the used database.
    jpaProperties.put("hibernate.dialect", env.getRequiredProperty("hibernate.dialect"));

    // Configures the naming strategy that is used when Hibernate creates
    // new database objects and schema elements
    jpaProperties.put(
        "hibernate.ejb.naming_strategy", env.getRequiredProperty("hibernate.ejb.naming_strategy"));

    // If the value of this property is true, Hibernate writes all SQL
    // statements to the console.
    jpaProperties.put("hibernate.show_sql", env.getRequiredProperty("hibernate.show_sql"));

    // If the value of this property is true, Hibernate will format the SQL
    // that is written to the console.
    jpaProperties.put("hibernate.format_sql", env.getRequiredProperty("hibernate.format_sql"));

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
  }
Ejemplo n.º 3
1
 @Bean(destroyMethod = "close")
 DataSource dataSource() {
   HikariConfig dataSourceConfig = new HikariConfig();
   dataSourceConfig.setJdbcUrl(env.getRequiredProperty("db.url"));
   dataSourceConfig.setDriverClassName(env.getRequiredProperty("db.driver"));
   dataSourceConfig.setUsername(env.getRequiredProperty("db.username"));
   dataSourceConfig.setPassword(env.getRequiredProperty("db.password"));
   return new HikariDataSource(dataSourceConfig);
 }
Ejemplo n.º 4
0
 private Properties hibProperties() {
   Properties properties = new Properties();
   properties.put(DIALECT, env.getRequiredProperty(DIALECT));
   properties.put(SHOW_SQL, env.getRequiredProperty(SHOW_SQL));
   properties.put(HBM2DDL_AUTO, env.getRequiredProperty(HBM2DDL_AUTO));
   return properties;
 }
Ejemplo n.º 5
0
  @Bean
  public BoneCPDataSource dataSource() {

    BoneCPDataSource dataSource = new BoneCPDataSource();

    dataSource.setDriverClass(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
    dataSource.setJdbcUrl(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
    dataSource.setUsername(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
    dataSource.setPassword(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));

    // https://github.com/wwadge/bonecp/blob/master/bonecp/src/main/resources/bonecp-default-config.xml
    dataSource.setConnectionTestStatement("SELECT 1 FROM DUAL");
    dataSource.setMinConnectionsPerPartition(0);
    dataSource.setMaxConnectionsPerPartition(10);
    dataSource.setMaxConnectionAge(0, TimeUnit.SECONDS);
    dataSource.setConnectionTimeout(5, TimeUnit.SECONDS);
    dataSource.setIdleMaxAge(60, TimeUnit.MINUTES);
    dataSource.setAcquireIncrement(1);
    dataSource.setPartitionCount(1);
    dataSource.setIdleConnectionTestPeriod(240, TimeUnit.MINUTES);
    dataSource.setStatementsCacheSize(500);
    dataSource.setCloseConnectionWatch(false);
    dataSource.setAcquireRetryDelay(7000, TimeUnit.MILLISECONDS);
    dataSource.setAcquireRetryAttempts(5);
    dataSource.setQueryExecuteTimeLimit(1, TimeUnit.MILLISECONDS);
    dataSource.setLazyInit(false);
    dataSource.setLogStatementsEnabled(true);

    return dataSource;
  }
 private Properties hibernateProperties() {
   Properties properties = new Properties();
   properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
   properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
   properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
   return properties;
 }
Ejemplo n.º 7
0
  @Bean
  public EntityManagerFactory entityManagerFactory() {

    Properties jpaProterties = new Properties();
    jpaProterties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
    jpaProterties.put(
        "hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
    jpaProterties.put(
        "hibernate.ejb.naming_strategy",
        environment.getRequiredProperty("hibernate.ejb.naming_strategy"));
    jpaProterties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
    jpaProterties.put(
        "hibernate.generate_statistics",
        environment.getRequiredProperty("hibernate.generate_statistics"));

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false);

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("br.com.uol.cubus.support.domain");
    factory.setDataSource(dataSource());
    factory.setJpaProperties(jpaProterties);
    factory.afterPropertiesSet();

    return factory.getObject();
  }
  @Bean
  public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
        new LocalContainerEntityManagerFactoryBean();

    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    entityManagerFactoryBean.setPackagesToScan(PROPERTY_PACKAGES_TO_SCAN);

    Properties jpaProperties = new Properties();

    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_DIALECT,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_FORMAT_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));
    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY));
    jpaProperties.put(
        PROPERTY_NAME_HIBERNATE_SHOW_SQL,
        environment.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));

    entityManagerFactoryBean.setJpaProperties(jpaProperties);

    return entityManagerFactoryBean;
  }
  @Bean(name = "entityManagerFactory")
  public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    LocalContainerEntityManagerFactoryBean factoryBean =
        new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(dataSource());
    factoryBean.setPersistenceUnitName("a1ecommerceEntityManager");
    factoryBean.setPackagesToScan(new String[] {"com.a1electronics.ecommerce.dbo"});
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    factoryBean.setJpaVendorAdapter(vendorAdapter);
    Properties jpaProperties = new Properties();

    // Configures the used database dialect. This allows Hibernate to create
    // SQL
    // that is optimized for the used database.
    jpaProperties.put("hibernate.dialect", env.getRequiredProperty("hibernate.dialect"));

    // If the value of this property is true, Hibernate writes all SQL
    // statements to the console.
    jpaProperties.put("hibernate.show_sql", env.getRequiredProperty("hibernate.show_sql"));

    // If the value of this property is true, Hibernate will format the SQL
    // that is written to the console.
    jpaProperties.put("hibernate.format_sql", env.getRequiredProperty("hibernate.format_sql"));
    // jpaProperties.put("hibernate.hbm2ddl.auto",env.getRequiredProperty("hibernate.hbm2ddl.auto"));
    // To fix the followinf issue
    // HHH000424: Disabling contextual LOB creation as createClob() method threw error :
    // java.lang.reflect.InvocationTargetException
    jpaProperties.put("hibernate.temp.use_jdbc_metadata_defaults", false);

    factoryBean.setJpaProperties(jpaProperties);
    factoryBean.afterPropertiesSet();
    factoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
    //		factoryBean.setPersistenceUnitName(env.getRequiredProperty("persistence.unitName"));
    return factoryBean;
  }
 @Before
 public void setup() {
   when(env.getRequiredProperty("nflow.rest.allow.origin")).thenReturn(HOST);
   when(env.getRequiredProperty("nflow.rest.allow.headers")).thenReturn(HEADERS);
   when(env.getRequiredProperty("nflow.rest.cors.enabled", Boolean.class)).thenReturn(TRUE);
   filter = new CorsHeaderContainerResponseFilter(env);
   when(responseContext.getHeaders()).thenReturn(headerMap);
 }
Ejemplo n.º 11
0
 @Override
 public DeploymentSettings deploymentSettings() {
   DeploymentSettings settings = super.deploymentSettings();
   settings.setDeploymentContext(env.getProperty("site.deploymentContext"), servletContext);
   settings.setHTTPPort(env.getRequiredProperty("site.httpPort", int.class));
   settings.setHTTPSPort(env.getRequiredProperty("site.httpsPort", int.class));
   return settings;
 }
Ejemplo n.º 12
0
 @Bean
 public DataSource dataSource() {
   DriverManagerDataSource dataSource = new DriverManagerDataSource();
   dataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
   dataSource.setUrl(environment.getRequiredProperty("jdbc.databaseurl"));
   dataSource.setUsername(environment.getRequiredProperty("jdbc.username"));
   dataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
   return dataSource;
 }
 /*  @Bean
     public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
         return new PersistenceExceptionTranslationPostProcessor();
     }
 */
 @Bean(name = "dataSource")
 public BasicDataSource dataSource() {
   BasicDataSource basicDataSource = new BasicDataSource();
   basicDataSource.setDriverClassName(environment.getRequiredProperty("database.class.name"));
   basicDataSource.setUrl(environment.getRequiredProperty("database.url"));
   basicDataSource.setUsername(environment.getRequiredProperty("database.username"));
   /*basicDataSource.setPassword("root");*/
   return basicDataSource;
 }
Ejemplo n.º 14
0
  private Properties getHibernateProperties() {
    Properties properties = new Properties();
    properties.put(PROP_HIBERNATE_DIALECT, env.getRequiredProperty(PROP_HIBERNATE_DIALECT));
    properties.put(PROP_HIBERNATE_SHOW_SQL, env.getRequiredProperty(PROP_HIBERNATE_SHOW_SQL));
    properties.put(
        PROP_HIBERNATE_HBM2DDL_AUTO, env.getRequiredProperty(PROP_HIBERNATE_HBM2DDL_AUTO));

    return properties;
  }
Ejemplo n.º 15
0
 @Bean
 public DataSource dataSource() {
   DriverManagerDataSource dataSource = new DriverManagerDataSource();
   dataSource.setDriverClassName(environment.getRequiredProperty(JAVAX_JDBC + "driver"));
   dataSource.setUrl(environment.getRequiredProperty(JAVAX_JDBC + "url"));
   dataSource.setUsername(environment.getRequiredProperty(JAVAX_JDBC + "user"));
   dataSource.setPassword(environment.getRequiredProperty(JAVAX_JDBC + "password"));
   return dataSource;
 }
Ejemplo n.º 16
0
 @Bean
 public DataSource dataSource() {
   DriverManagerDataSource dataSource = new DriverManagerDataSource();
   dataSource.setDriverClassName(env.getRequiredProperty("db.driver"));
   dataSource.setUrl(env.getRequiredProperty("db.url"));
   dataSource.setUsername(env.getRequiredProperty("db.username"));
   dataSource.setPassword(env.getRequiredProperty("db.password"));
   return dataSource;
 }
Ejemplo n.º 17
0
  @Bean
  public GitHubClient gitHubClient() {

    GitHubClient client = new GitHubClient();
    client.setCredentials(
        env.getRequiredProperty(USUARIO_GIT), env.getRequiredProperty(PASSWORD_GIT));
    client.setOAuth2Token(TOKEN_GIT);
    return client;
  }
Ejemplo n.º 18
0
  @Bean
  public MilestoneService milestoneService() {

    MilestoneService milestoneService = new MilestoneService();
    milestoneService
        .getClient()
        .setCredentials(
            env.getRequiredProperty(USUARIO_GIT), env.getRequiredProperty(PASSWORD_GIT));
    return milestoneService;
  }
Ejemplo n.º 19
0
  @Bean
  public WatcherService watcherService() {

    WatcherService watcherService = new WatcherService();
    watcherService
        .getClient()
        .setCredentials(
            env.getRequiredProperty(USUARIO_GIT), env.getRequiredProperty(PASSWORD_GIT));
    return watcherService;
  }
Ejemplo n.º 20
0
  @Bean
  public UserService userService() {

    UserService userService = new UserService();
    userService
        .getClient()
        .setCredentials(
            env.getRequiredProperty(USUARIO_GIT), env.getRequiredProperty(PASSWORD_GIT));
    return userService;
  }
 private Properties getMailProperties() {
   Properties properties = new Properties();
   properties.setProperty(
       PROPERTY_TRANSPORT_PROTOCOL, env.getRequiredProperty(PROPERTY_TRANSPORT_PROTOCOL));
   properties.setProperty(PROPERTY_SMTP_AUTH, env.getRequiredProperty(PROPERTY_SMTP_AUTH));
   properties.setProperty(
       PROPERTY_SMTP_STARTTLS_ENABLE, env.getRequiredProperty(PROPERTY_SMTP_STARTTLS_ENABLE));
   properties.setProperty(PROPERTY_DEBUG, env.getRequiredProperty(PROPERTY_DEBUG));
   return properties;
 }
 public ArticleCollectionTaskConfiguration articleCollectionTaskConfiguration() {
   return new ArticleCollectionTaskConfiguration(
       env.getRequiredProperty("mediaProviders.historyLocation")
           + File.separator
           + mediaProvider.getMediaProviderId(),
       Arrays.asList(
           env.getRequiredProperty(
                   "mediaProviders." + mediaProvider.getMediaProviderId() + ".seeds")
               .split(" ")));
 }
Ejemplo n.º 23
0
  @Bean
  public DataSource restDataSource() {
    final BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(env.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
    dataSource.setUrl(env.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
    dataSource.setUsername(env.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
    dataSource.setPassword(env.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));

    return dataSource;
  }
 @Bean
 public JavaMailSender javaMailService() {
   JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
   javaMailSender.setHost(env.getRequiredProperty(PROPERTY_HOST));
   javaMailSender.setPort(parsePortProperty(env.getRequiredProperty(PROPERTY_PORT)));
   javaMailSender.setUsername(env.getRequiredProperty(PROPERTY_USERNAME));
   javaMailSender.setPassword(env.getRequiredProperty(PROPERTY_PASSWORD));
   javaMailSender.setJavaMailProperties(getMailProperties());
   javaMailSender.setDefaultEncoding(WebMvcConfiguration.DEFAULT_CHAR_ENCODING);
   return javaMailSender;
 }
Ejemplo n.º 25
0
  @Bean
  public IssueService issueService() {

    IssueService issueService = new IssueService();
    issueService
        .getClient()
        .setCredentials(
            env.getRequiredProperty(USUARIO_GIT), env.getRequiredProperty(PASSWORD_GIT));
    issueService.getClient().setOAuth2Token(TOKEN_GIT);
    return issueService;
  }
Ejemplo n.º 26
0
 @Bean(name = "geoServiceConfig")
 public GeoServiceConfig getGeoServiceConfig() {
   GeoServiceConfig geoServiceConfig = new GeoServiceConfig();
   String userServiceUrl = environment.getRequiredProperty(Constants.USER_SERVICE_URL);
   String validateUserUrl = environment.getRequiredProperty(Constants.USER_VALIDATE_URL);
   logger.info("### USER_SERVICE_URL : {} ###" + userServiceUrl);
   logger.info("### USER_VALIDATE_URL : {} ###" + validateUserUrl);
   geoServiceConfig.setUserServiceUrl(userServiceUrl);
   geoServiceConfig.setValidateUrl(validateUserUrl);
   return geoServiceConfig;
 }
 private Properties hibernateProperties() {
   Properties properties = new Properties();
   properties.put(
       PROPERTY_NAME_HIBERNATE_HBM2DDL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL));
   properties.put(
       PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
   properties.put(
       PROPERTY_NAME_HIBERNATE_SHOW_SQL,
       env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
   return properties;
 }
  @Bean
  public DataSource dataSource() {
    BoneCPDataSource dataSource = new BoneCPDataSource();

    dataSource.setDriverClass(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
    dataSource.setJdbcUrl(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
    dataSource.setUsername(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
    dataSource.setPassword(environment.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));

    return dataSource;
  }
Ejemplo n.º 29
0
  @Bean
  public DataSource dataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();

    dataSource.setDriverClassName(env.getRequiredProperty(PROP_DATABASE_DRIVER));
    dataSource.setUrl(env.getRequiredProperty(PROP_DATABASE_URL));
    dataSource.setUsername(env.getRequiredProperty(PROP_DATABASE_USERNAME));
    dataSource.setPassword(env.getRequiredProperty(PROP_DATABASE_PASSWORD));

    return dataSource;
  }
Ejemplo n.º 30
0
  @Bean
  public RepositoryService repositoryService() {

    RepositoryService repositoryService = new RepositoryService();
    repositoryService
        .getClient()
        .setCredentials(
            env.getRequiredProperty(USUARIO_GIT), env.getRequiredProperty(PASSWORD_GIT));
    repositoryService.getClient().setOAuth2Token(TOKEN_GIT);
    return repositoryService;
  }