本文整理汇总了Java中com.google.inject.persist.PersistService类的典型用法代码示例。如果您正苦于以下问题:Java PersistService类的具体用法?Java PersistService怎么用?Java PersistService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PersistService类属于com.google.inject.persist包,在下文中一共展示了PersistService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Client
import com.google.inject.persist.PersistService; //导入依赖的package包/类
public Client(@NonNull Path filePath, @NonNull Config config, boolean cleanRun, @NonNull List<?> listeners) {
this.filePath = checkFile(filePath);
this.cleanRun = cleanRun;
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);
}
示例2: configure
import com.google.inject.persist.PersistService; //导入依赖的package包/类
@Override
protected final void configure() {
configurePersistence();
requireBinding(PersistService.class);
requireBinding(UnitOfWork.class);
/*if[AOP]*/
// wrapping in an if[AOP] just to allow this to compile in NO_AOP -- it won't be used
// class-level @Transacational
bindInterceptor(annotatedWith(Transactional.class),
new TransactionalClassMethodMatcher(),
getTransactionInterceptor());
// method-level @Transacational
bindInterceptor(any(), new TransactionalMethodMatcher(), getTransactionInterceptor());
/*end[AOP]*/
}
示例3: configurePersistence
import com.google.inject.persist.PersistService; //导入依赖的package包/类
protected void configurePersistence() {
bind(String[].class).annotatedWith(Neo4j.class).toInstance(packages);
if (null != properties) {
bind(Properties.class).annotatedWith(Neo4j.class).toInstance(properties);
} else {
bind(Properties.class).annotatedWith(Neo4j.class).toProvider(Providers.of(null));
}
bind(Neo4jPersistService.class).in(Singleton.class);
bind(PersistService.class).to(Neo4jPersistService.class);
bind(UnitOfWork.class).to(Neo4jPersistService.class);
bind(Session.class).toProvider(Neo4jPersistService.class);
transactionInterceptor = new Neo4jLocalTxnInterceptor();
requestInjection(transactionInterceptor);
}
示例4: main
import com.google.inject.persist.PersistService; //导入依赖的package包/类
public static void main(String[] args) {
// admin/admin is default user, created for each new db
final Injector injector = Guice.createInjector(new DbModule("memory:sample", "admin", "admin"));
// to initialize db context we must manually call start
final PersistService persistService = injector.getInstance(PersistService.class);
persistService.start();
try {
final SampleService service = injector.getInstance(SampleService.class);
System.out.println("Overall records: " + service.count());
final ODocument rec = service.selectLast();
System.out.println("Last record: " + rec.toJSON());
service.replaceName(rec.<String>field("name"), "test");
// pay attention to record @version property in console
System.out.println("Renamed record: " + service.findByName("test").toJSON());
System.out.println("Records count is the same: " + service.count());
} finally {
// at the end service must be stopped
persistService.stop();
}
}
示例5: configurePersistence
import com.google.inject.persist.PersistService; //导入依赖的package包/类
@Override
protected void configurePersistence() {
bindConstant().annotatedWith(Jpa.class).to(jpaUnit);
bind(JpaPersistService.class).in(Singleton.class);
bind(PersistService.class).to(JpaPersistService.class);
bind(UnitOfWork.class).to(JpaPersistService.class);
bind(EntityManager.class).toProvider(JpaPersistService.class);
bind(EntityManagerFactory.class)
.toProvider(JpaPersistService.EntityManagerFactoryProvider.class);
transactionInterceptor = new JpaLocalTxnInterceptor();
requestInjection(transactionInterceptor);
// Bind dynamic finders.
for (Class<?> finder : dynamicFinders) {
bindFinder(finder);
}
}
示例6: configurePersistence
import com.google.inject.persist.PersistService; //导入依赖的package包/类
@Override protected void configurePersistence() {
bindConstant().annotatedWith(Jpa.class).to(jpaUnit);
if (null != properties) {
bind(Properties.class).annotatedWith(Jpa.class).toInstance(properties);
} else {
bind(Properties.class).annotatedWith(Jpa.class)
.toProvider(Providers.<Properties>of(null));
}
bind(JpaPersistService.class).in(Singleton.class);
bind(PersistService.class).to(JpaPersistService.class);
bind(UnitOfWork.class).to(JpaPersistService.class);
bind(EntityManager.class).toProvider(JpaPersistService.class);
bind(EntityManagerFactory.class)
.toProvider(JpaPersistService.EntityManagerFactoryProvider.class);
transactionInterceptor = new JpaLocalTxnInterceptor();
requestInjection(transactionInterceptor);
// Bind dynamic finders.
for (Class<?> finder : dynamicFinders) {
bindFinder(finder);
}
}
示例7: setUp
import com.google.inject.persist.PersistService; //导入依赖的package包/类
@Before
public void setUp() {
InputStream src = DatabaseTest.class.getResourceAsStream("/databaseconfig.test-h2.json");
DatabaseProperties props;
try {
props = new CommonModule().objectMapper().readValue(src, DatabaseProperties.class);
} catch (IOException e) {
throw new ConfigurationException("Could not read test config", e);
}
injector = createInjector(new PersistenceModule(props, ""));
structure = injector.getInstance(DatabaseStructure.class);
persistService = injector.getInstance(PersistService.class);
persistService.start();
em = injector.getInstance(EntityManager.class);
beginTransaction();
}
示例8: setUp
import com.google.inject.persist.PersistService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(new JpaPersistModule("CapabilitiesDirectory"), new AbstractModule() {
@Override
protected void configure() {
bind(DiscoveryEntryStore.class).to(DiscoveryEntryStorePersisted.class);
bind(DiscoveryEntry.class).to(GlobalDiscoveryEntryPersisted.class);
bind(CapabilitiesProvisioning.class).to(DefaultCapabilitiesProvisioning.class);
}
});
service = injector.getInstance(PersistService.class);
store = injector.getInstance(DiscoveryEntryStore.class);
entityManager = injector.getInstance(EntityManager.class);
}
示例9: init
import com.google.inject.persist.PersistService; //导入依赖的package包/类
private void init() {
//JPA module
final Map<String, Object> props = Maps.newHashMap(configuration);
props.put("hibernate.connection.datasource",
DataSourceManager.get().load(name, configuration).get(name));
final Module jpaModule = new JpaPersistModule("s3").properties(props);
final Module s3Module = new S3Module(name, 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);
}
示例10: App
import com.google.inject.persist.PersistService; //导入依赖的package包/类
@Inject
public App(PersistService persistService,
SchemaUpdater schemaUpdater,
RestApiServer restApiServer,
UdpServer udpServer,
SongSchedulerService songSchedulerService) throws Exception {
this.persistService = persistService;
this.restApiServer = restApiServer;
this.udpServer = udpServer;
this.songSchedulerService = songSchedulerService;
this.schemaUpdater = schemaUpdater;
}
示例11: initializeInjector
import com.google.inject.persist.PersistService; //导入依赖的package包/类
protected static void initializeInjector() {
if (injector == null) {
injector = Guice.createInjector(new TestModule(), new JpaPersistModule("testPU"));
Injectors.set(new InjectorProvider() {
@Override
public Injector provide() {
return injector;
}
});
injector.getInstance(PersistService.class).start();
}
}
示例12: main
import com.google.inject.persist.PersistService; //导入依赖的package包/类
public static void main(String[] args) {
final Injector injector = Guice.createInjector(new RepoDbModule("memory:sample", "admin", "admin"));
final PersistService persistService = injector.getInstance(PersistService.class);
persistService.start();
try {
final SampleRepository repository = injector.getInstance(SampleRepository.class);
System.out.println("Overall records: " + repository.count());
Sample sample = repository.first();
// not detached entity will not contain data outside of transaction (its a proxy!)
System.out.println("Last record (not detached): " + sample);
// use list here just to show how multiple entities could be returned
List<Sample> samples = repository.selectDetached();
sample = samples.get(0);
System.out.println("Detached record: " + sample);
// without detaching name would be null
int res = repository.updateName("test", sample.getName());
System.out.println("Rename result: " + res);
// pay attention to record @version property in console
System.out.println("Renamed record: " + repository.findByNameDetached("test"));
System.out.println("Records count is the same: " + repository.count());
System.out.println("Document search: " + repository.findDocumentByName("test"));
} finally {
// at the end service must be stopped
persistService.stop();
}
}
示例13: main
import com.google.inject.persist.PersistService; //导入依赖的package包/类
public static void main(String[] args) {
final Injector injector = Guice.createInjector(new ObjectDbModule("memory:sample", "admin", "admin"));
final PersistService persistService = injector.getInstance(PersistService.class);
persistService.start();
try {
final SampleService service = injector.getInstance(SampleService.class);
System.out.println("Overall records: " + service.count());
System.out.println("Overall records with query: " + service.count2());
Sample sample = service.selectLast();
// not detached entity will not contain data outside of transaction (its a proxy!)
System.out.println("Last record (not detached): " + sample);
sample = service.detach(sample);
System.out.println("Last record (detached): " + sample);
// without detaching name would be null
service.replaceName(sample.getName(), "test");
// pay attention to record @version property in console
System.out.println("Renamed record: " + service.detach(service.findByName("test")));
System.out.println("Records count is the same: " + service.count());
} finally {
// at the end service must be stopped
persistService.stop();
}
}
示例14: setUp
import com.google.inject.persist.PersistService; //导入依赖的package包/类
/**
* Runs any test set up code before the actual test is run. The data for the
* test is created from this method.
*
* @throws Exception Thrown if there are errors while creating test data, or
* propagating exception from super.setUp().
*/
@Override
public final void setUp() throws Exception {
super.setUp();
PersistService persistService = this.injector.getInstance(PersistService.class);
persistService.start();
this.persistService = persistService;
TestDataProvider dataProvider = this.injector.getInstance(this.getDataProvider());
dataProvider.setUp();
this.dataProvider = dataProvider;
}
示例15: run
import com.google.inject.persist.PersistService; //导入依赖的package包/类
/**
* Run the bulk insertion.
*
* @throws Exception
* when the bulkinsertion has failed.
*/
public void run() throws Exception {
final Injector injector = Guice.createInjector(new BulkInsertServletModule());
final PersistService persistService = injector.getInstance(PersistService.class);
persistService.start();
final BulkInsertData bulkInsertData = injector.getInstance(BulkInsertData.class);
bulkInsertData.clear();
bulkInsertData.insertData();
bulkInsertData.insertRandomRooms(NUMBER_OF_ROOMS);
}