Examples of JpaPersistModule


Examples of com.google.inject.persist.jpa.JpaPersistModule

public class BaseModule extends AbstractModule {

  @Override
  protected void configure() {
    install(new JpaPersistModule("db-manager-postgres-matt"));
  }
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

@WebListener
public class GuiceDependencyInjector extends GuiceServletContextListener {

    @Override
    protected Injector getInjector() {
        return Guice.createInjector(new JerseyServlet(), new JpaPersistModule("myapp-db"));
    }
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

      bind(HeartBeatHandler.class).toInstance(handler);
      bind(AmbariMetaInfo.class).toInstance(ambariMetaInfo);
    }

    private void installDependencies() {
      install(new JpaPersistModule("ambari-javadb"));
      install(new FactoryModuleBuilder().implement(
          Cluster.class, ClusterImpl.class).build(ClusterFactory.class));
      install(new FactoryModuleBuilder().implement(
          Host.class, HostImpl.class).build(HostFactory.class));
      install(new FactoryModuleBuilder().implement(
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

    requestStaticInjection(ExecutionCommandWrapper.class);
  }

  private JpaPersistModule buildJpaPersistModule() {
    PersistenceType persistenceType = configuration.getPersistenceType();
    JpaPersistModule jpaPersistModule = new JpaPersistModule(Configuration.JDBC_UNIT_NAME);

    Properties properties = new Properties();

    // custom jdbc properties
    Map<String, String> custom = configuration.getDatabaseCustomProperties();
   
    if (0 != custom.size()) {
      for (Entry<String, String> entry : custom.entrySet()) {
        properties.setProperty("eclipselink.jdbc.property." + entry.getKey(),
           entry.getValue());
      }
    }   

    switch (persistenceType) {
      case IN_MEMORY:
        properties.put("javax.persistence.jdbc.url", Configuration.JDBC_IN_MEMORY_URL);
        properties.put("javax.persistence.jdbc.driver", Configuration.JDBC_IN_MEMROY_DRIVER);
        properties.put("eclipselink.ddl-generation", "drop-and-create-tables");
        properties.put("eclipselink.orm.throw.exceptions", "true");
        jpaPersistModule.properties(properties);
        return jpaPersistModule;
      case REMOTE:
        properties.put("javax.persistence.jdbc.url", configuration.getDatabaseUrl());
        properties.put("javax.persistence.jdbc.driver", configuration.getDatabaseDriver());
        break;
      case LOCAL:
        properties.put("javax.persistence.jdbc.url", configuration.getLocalDatabaseUrl());
        properties.put("javax.persistence.jdbc.driver", Configuration.JDBC_LOCAL_DRIVER);
        break;
    }

    properties.setProperty("javax.persistence.jdbc.user", configuration.getDatabaseUser());
    properties.setProperty("javax.persistence.jdbc.password", configuration.getDatabasePassword());

    switch (configuration.getJPATableGenerationStrategy()) {
      case CREATE:
        properties.setProperty("eclipselink.ddl-generation", "create-tables");
        break;
      case DROP_AND_CREATE:
        properties.setProperty("eclipselink.ddl-generation", "drop-and-create-tables");
        break;
      default:
        break;
    }
    properties.setProperty("eclipselink.ddl-generation.output-mode", "both");
    properties.setProperty("eclipselink.create-ddl-jdbc-file-name", "DDL-create.jdbc");
    properties.setProperty("eclipselink.drop-ddl-jdbc-file-name", "DDL-drop.jdbc");

    jpaPersistModule.properties(properties);

    return jpaPersistModule;
  }
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

    requestStaticInjection(ExecutionCommandWrapper.class);
  }

  private JpaPersistModule buildJpaPersistModule() {
    PersistenceType persistenceType = configuration.getPersistenceType();
    JpaPersistModule jpaPersistModule = new JpaPersistModule(Configuration.JDBC_UNIT_NAME);

    Properties properties = new Properties();

    // custom jdbc properties
    Map<String, String> custom = configuration.getDatabaseCustomProperties();
   
    if (0 != custom.size()) {
      for (Entry<String, String> entry : custom.entrySet()) {
        properties.setProperty("eclipselink.jdbc.property." + entry.getKey(),
           entry.getValue());
      }
    }   

    switch (persistenceType) {
      case IN_MEMORY:
        properties.put("javax.persistence.jdbc.url", Configuration.JDBC_IN_MEMORY_URL);
        properties.put("javax.persistence.jdbc.driver", Configuration.JDBC_IN_MEMROY_DRIVER);
        properties.put("eclipselink.ddl-generation", "drop-and-create-tables");
        properties.put("eclipselink.orm.throw.exceptions", "true");
        jpaPersistModule.properties(properties);
        return jpaPersistModule;
      case REMOTE:
        properties.put("javax.persistence.jdbc.url", configuration.getDatabaseUrl());
        properties.put("javax.persistence.jdbc.driver", configuration.getDatabaseDriver());
        break;
      case LOCAL:
        properties.put("javax.persistence.jdbc.url", configuration.getLocalDatabaseUrl());
        properties.put("javax.persistence.jdbc.driver", Configuration.JDBC_LOCAL_DRIVER);
        break;
    }

    properties.setProperty("javax.persistence.jdbc.user", configuration.getDatabaseUser());
    properties.setProperty("javax.persistence.jdbc.password", configuration.getDatabasePassword());

    switch (configuration.getJPATableGenerationStrategy()) {
      case CREATE:
        properties.setProperty("eclipselink.ddl-generation", "create-tables");
        break;
      case DROP_AND_CREATE:
        properties.setProperty("eclipselink.ddl-generation", "drop-and-create-tables");
        break;
      default:
        break;
    }
    properties.setProperty("eclipselink.ddl-generation.output-mode", "both");
    properties.setProperty("eclipselink.create-ddl-jdbc-file-name", "DDL-create.jdbc");
    properties.setProperty("eclipselink.drop-ddl-jdbc-file-name", "DDL-drop.jdbc");

    jpaPersistModule.properties(properties);

    return jpaPersistModule;
  }
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

    // ----- helper methods --------------------------------------------------

    // Create the JPA persistence module
    private JpaPersistModule buildJpaPersistModule() {
      PersistenceType  persistenceType  = getPersistenceType(configuration);
      JpaPersistModule jpaPersistModule = new JpaPersistModule(Configuration.JDBC_UNIT_NAME);
      Properties       properties       = new Properties();
      String           databaseDriver;
      String           databaseUrl;

      if (persistenceType == PersistenceType.LOCAL) {
        databaseDriver = configuration.getLocalDatabaseUrl();
        databaseUrl    = Configuration.JDBC_LOCAL_DRIVER;

      }
      else {
        if (persistenceType == PersistenceType.IN_MEMORY) {
          databaseDriver = Configuration.JDBC_IN_MEMROY_DRIVER;
          databaseUrl = Configuration.JDBC_IN_MEMORY_URL;
        }
        else {
          databaseDriver = configuration.getDatabaseDriver();
          databaseUrl    = configuration.getDatabaseUrl();
        }
      }

      if (databaseDriver != null && databaseUrl != null) {
        properties.setProperty("javax.persistence.jdbc.url",    databaseUrl);
        properties.setProperty("javax.persistence.jdbc.driver", databaseDriver);

        properties.setProperty("eclipselink.logging.level""INFO");
        properties.setProperty("eclipselink.logging.logger", "org.apache.ambari.scom.logging.JpaLogger");

        // custom jdbc properties
        Map<String, String> custom = configuration.getDatabaseCustomProperties();

        if (0 != custom.size()) {
          for (Map.Entry<String, String> entry : custom.entrySet()) {
            properties.setProperty("eclipselink.jdbc.property." + entry.getKey(),
                entry.getValue());
          }
        }

        if (persistenceType == PersistenceType.IN_MEMORY) {
          properties.setProperty("eclipselink.ddl-generation",       "drop-and-create-tables");
          properties.setProperty("eclipselink.orm.throw.exceptions", "true");
          jpaPersistModule.properties(properties);
        } else {
          properties.setProperty("javax.persistence.jdbc.user",   configuration.getDatabaseUser());
          properties.setProperty("javax.persistence.jdbc.password",
              configuration.getProperty(Configuration.SERVER_JDBC_USER_PASSWD_KEY));

          switch (configuration.getJPATableGenerationStrategy()) {
            case CREATE:
              properties.setProperty("eclipselink.ddl-generation", "create-tables");
              break;
            case DROP_AND_CREATE:
              properties.setProperty("eclipselink.ddl-generation", "drop-and-create-tables");
              break;
            default:
              break;
          }
          properties.setProperty("eclipselink.ddl-generation.output-mode", "both");
          properties.setProperty("eclipselink.create-ddl-jdbc-file-name""DDL-create.jdbc");
          properties.setProperty("eclipselink.drop-ddl-jdbc-file-name",    "DDL-drop.jdbc");

          jpaPersistModule.properties(properties);
        }
      }
      return jpaPersistModule;
    }
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

      bind(HeartBeatHandler.class).toInstance(handler);
      bind(AmbariMetaInfo.class).toInstance(ambariMetaInfo);
    }

    private void installDependencies() {
      install(new JpaPersistModule("ambari-javadb"));
      install(new FactoryModuleBuilder().implement(
          Cluster.class, ClusterImpl.class).build(ClusterFactory.class));
      install(new FactoryModuleBuilder().implement(
          Host.class, HostImpl.class).build(HostFactory.class));
      install(new FactoryModuleBuilder().implement(
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

            }

            // Now - it may be the case the neither connection.url, connection.username nor
            // connection.password is set. But this may be okay e.g. when using JDNI to
            // configure your datasources...
            install(new JpaPersistModule(persistenceUnitName).properties(jpaProperties));
           
           
            UnitOfWorkInterceptor unitOfWorkInterceptor = new UnitOfWorkInterceptor();
       
            requestInjection(unitOfWorkInterceptor);
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

        bind(CandlepinSingletonScope.class).toInstance(singletonScope);

        bind(BeanValidationEventListener.class).toProvider(ValidationListenerProvider.class);
        bind(MessageInterpolator.class).to(CandlepinMessageInterpolator.class);

        install(new JpaPersistModule("testing"));
        bind(JPAInitializer.class).asEagerSingleton();

        bind(X509ExtensionUtil.class);

        // allowing folks to override the config in unit tests.
View Full Code Here

Examples of com.google.inject.persist.jpa.JpaPersistModule

    public class TestModule extends AbstractModule {

        @Override
        protected void configure() {
            bind(Configuration.class).toInstance(config);
            install(new JpaPersistModule("testing"));
            bind(I18n.class).toProvider(I18nProvider.class);
            bind(JPAInitializer.class).asEagerSingleton();
            bind(JobFactory.class).to(GuiceJobFactory.class);
            bind(JobListener.class).to(PinsetterJobListener.class);
            bind(PrincipalProvider.class).to(TestPrincipalProvider.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.