com.google.inject.persist.PersistService Java Examples

The following examples show how to use com.google.inject.persist.PersistService. 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: Client.java    From J-Kinopoisk2IMDB with Apache License 2.0 7 votes vote down vote up
public Client(@NonNull Path filePath, @NonNull Config config, boolean cleanRun, @NonNull List<?> listeners) {
    this.filePath = checkFile(filePath);
    this.cleanRun = cleanRun;
    this.config = config;

    Injector injector = Guice.createInjector(
            Stage.PRODUCTION,
            new ConfigurationModule(ConfigValidator.checkValid(config.withFallback(ConfigFactory.load()))),
            new JpaRepositoryModule(),
            new ServiceModule()
    );

    persistService = injector.getInstance(PersistService.class);
    persistService.start();

    handlerType = injector.getInstance(MovieHandler.Type.class);
    handlerChain = injector.getInstance(MovieHandler.class);
    importProgressService = injector.getInstance(ImportProgressService.class);

    eventBus = new EventBus();
    listeners.forEach(eventBus::register);
}
 
Example #2
Source File: OrientModule.java    From guice-persist-orient with MIT License 6 votes vote down vote up
@Override
protected void configurePersistence() {
    poolsMultibinder = Multibinder.newSetBinder(binder(), PoolManager.class);

    final OrientDBFactory info = new OrientDBFactory(
            uri, user, password, autoCreateLocalDb, config, serverUser, serverPassword, remoteType);
    bind(OrientDBFactory.class).toInstance(info);
    bind(TxConfig.class).annotatedWith(Names.named("orient.txconfig"))
            .toInstance(txConfig == null ? new TxConfig() : txConfig);

    configureCustomTypes();
    bind(CustomTypesInstaller.class);

    // extension points
    bind(TransactionManager.class);
    // SchemeInitializer.class
    // DataInitializer.class

    bind(PersistService.class).to(DatabaseManager.class);
    bind(OrientDB.class).toProvider(DatabaseManager.class);
    bind(UnitOfWork.class).to(TransactionManager.class);

    configurePools();
    configureInterceptor();
    bindRetryInterceptor();
}
 
Example #3
Source File: GlobalDiscoveryEntryPersistedStorePersistedTest.java    From joynr with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    Injector injector = Guice.createInjector(new JpaPersistModule("CapabilitiesDirectory"), new AbstractModule() {
        @Override
        protected void configure() {
            bind(String.class).annotatedWith(Names.named(PROPERTY_DISCOVERY_PROVIDER_DEFAULT_EXPIRY_TIME_MS))
                              .toInstance(String.valueOf(DEFAULT_EXPIRY_INTERVAL_MS));
            bind(CapabilitiesProvisioning.class).to(DefaultCapabilitiesProvisioning.class);
            requestStaticInjection(CapabilityUtils.class, RoutingTypesUtil.class);
        }
    });
    service = injector.getInstance(PersistService.class);
    store = injector.getInstance(GlobalDiscoveryEntryPersistedStorePersisted.class);
    entityManager = injector.getInstance(EntityManager.class);
}
 
Example #4
Source File: S3ConnectorFactory.java    From metacat with Apache License 2.0 5 votes vote down vote up
private void init() {
    //JPA module
    final Map<String, Object> props = Maps.newHashMap(configuration);
    props.put("hibernate.connection.datasource",
        DataSourceManager.get().load(catalogShardName, configuration).get(catalogShardName));
    final Module jpaModule = new JpaPersistModule("s3").properties(props);
    final Module s3Module = new S3Module(catalogName, configuration, infoConverter);
    final Injector injector = Guice.createInjector(jpaModule, s3Module);
    persistService = injector.getInstance(PersistService.class);
    persistService.start();
    this.databaseService = injector.getInstance(ConnectorDatabaseService.class);
    this.tableService = injector.getInstance(ConnectorTableService.class);
    this.partitionService = injector.getInstance(ConnectorPartitionService.class);
}
 
Example #5
Source File: JooqPersistModule.java    From guice-persist-jooq with Apache License 2.0 5 votes vote down vote up
@Override
protected void configurePersistence() {
  bind(JooqPersistService.class).in(Singleton.class);
  bind(PersistService.class).to(JooqPersistService.class);
  bind(UnitOfWork.class).to(JooqPersistService.class);
  bind(DSLContext.class).toProvider(JooqPersistService.class);

  transactionInterceptor = new JdbcLocalTxnInterceptor(getProvider(JooqPersistService.class),
                                                       getProvider(UnitOfWork.class));
  requestInjection(transactionInterceptor);
}
 
Example #6
Source File: AbstractSchemeModule.java    From guice-persist-orient with MIT License 5 votes vote down vote up
@Override
protected void configure() {
    // prevent usage without main OrientModule
    requireBinding(PersistService.class);

    // if package not provided empty string will mean root package (search all classpath)
    // not required if provided scheme initializers not used
    bindConstant().annotatedWith(Names.named("orient.model.package")).to(pkgs);

    // required explicit binding to inject correct injector instance (instead of always root injector)
    bind(ExtensionsDescriptorFactory.class);

    bindSchemeInitializer();
}
 
Example #7
Source File: OAutoScanSchemeModule.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
/**
 * Configure module.
 * Used init code from {@link AbstractSchemeModule}
 */
@Override
protected void configure() {
    // prevent usage without main OrientModule
    requireBinding(PersistService.class);

    // init empty set of packages
    Multibinder.newSetBinder(binder(), String.class, Names.named("orient.model.packages"));

    // required explicit binding to inject correct injector instance (instead of always root injector)
    bind(ExtensionsDescriptorFactory.class);
}
 
Example #8
Source File: Initializer.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
/**
 * Start {@link PersistService}
 * @see <a href="https://github.com/xvik/guice-persist-orient#lifecycle">Lifecycle of guice-persist-orient</a>
 * @param application Wicket application
 */
@Override
public void init(Application application) {
    OrienteerWebApplication app = (OrienteerWebApplication) application;
    PersistService persistService = app.getServiceInstance(PersistService.class);
    persistService.start();
}
 
Example #9
Source File: Initializer.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
/**
 * Stop {@link PersistService}
 * @see <a href="https://github.com/xvik/guice-persist-orient#lifecycle">Lifecycle of guice-persist-orient</a>
 * @param application Wicket application
 */
@Override
public void destroy(Application application) {
    OrienteerWebApplication app = (OrienteerWebApplication) application;
    PersistService persistService = app.getServiceInstance(PersistService.class);
    persistService.stop();
}
 
Example #10
Source File: GlobalDiscoveryEntryPersistedStorePersisted.java    From joynr with Apache License 2.0 5 votes vote down vote up
@Inject
public GlobalDiscoveryEntryPersistedStorePersisted(CapabilitiesProvisioning staticProvisioning,
                                                   Provider<EntityManager> entityManagerProvider,
                                                   PersistService persistService,
                                                   @Named(PROPERTY_DISCOVERY_PROVIDER_DEFAULT_EXPIRY_TIME_MS) String defaultExpiryTimeMs) {
    persistService.start();
    entityManager = entityManagerProvider.get();
    this.defaultExpiryTimeMs = Long.parseLong(defaultExpiryTimeMs);

    logger.debug("Creating CapabilitiesStore with static provisioning");
}
 
Example #11
Source File: DBTermination.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
@Inject
public DBTermination(PersistService persistService, EntityManagerFactory emFactory) {
  this.persistService = persistService;
  this.emFactory = emFactory;
}
 
Example #12
Source File: CapabilitiesDirectoryLauncher.java    From joynr with Apache License 2.0 4 votes vote down vote up
@Inject
public CapabilitiesDirectoryLauncher(PersistService persistService) {
    this.persistService = persistService;
}