本文整理汇总了Java中com.google.inject.persist.PersistService.start方法的典型用法代码示例。如果您正苦于以下问题:Java PersistService.start方法的具体用法?Java PersistService.start怎么用?Java PersistService.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.inject.persist.PersistService
的用法示例。
在下文中一共展示了PersistService.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
示例3: 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();
}
}
示例4: 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;
}
示例5: 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);
}
示例6: setUp
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
@Before
public final void setUp() {
final Injector injector = Guice.createInjector(new JpaPersistModule(getPersistModuleName()));
injector.injectMembers(this);
final PersistService persistService = injector.getInstance(PersistService.class);
persistService.start();
}
示例7: DiscoveryEntryStorePersisted
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
@Inject
public DiscoveryEntryStorePersisted(CapabilitiesProvisioning staticProvisioning,
Provider<EntityManager> entityManagerProvider,
PersistService persistService) {
persistService.start();
entityManager = entityManagerProvider.get();
logger.debug("creating CapabilitiesStore {} with static provisioning", this);
}
示例8: DBInitializer
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
@Inject
public DBInitializer(PersistService service) {
service.start();
}
示例9: PersistenceServiceInitialiser
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
@javax.inject.Inject
public PersistenceServiceInitialiser(PersistService service) {
service.start();
}
示例10: main
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
public static void main(String[] args) {
final Injector injector = Guice.createInjector(new GraphDbModule("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());
// if you commit edge type creation in scheme initializer you will see that edge was created automatically
// but with warning
System.out.println("Edge types: " + Joiner.on(", ").join(service.getEdgeClasses()));
final Vertex sample = service.selectLast();
System.out.println("Last record: " + sample);
System.out.println("By the way, it's backed by document: " + ((OrientVertex) sample).getRecord().toJSON());
service.replaceName(sample.<String>getProperty("name"), "test");
// pay attention to record @version property in console
final Vertex renamed = service.findByName("test");
System.out.println("Renamed record: " + renamed + " name=" + renamed.getProperty("name"));
System.out.println("Records count is the same: " + service.count());
System.out.println();
Vertex parent = service.getParent(renamed.<String>getProperty("name"));
System.out.println("Parent record: " + parent + " with name " + parent.getProperty("name"));
List<Vertex> children = service.getChildren(parent.<String>getProperty("name"));
System.out.println("Parent children: " + Joiner.on(", ").join(children));
// now add new child to node already having a child
System.out.println();
final Vertex child = service.addChild(parent, "Child!", 12);
System.out.println("Added new element: " + child);
System.out.println("Records count now is: " + service.count());
children = service.getChildren(parent.<String>getProperty("name"));
System.out.println("Parent children after addition: " + Joiner.on(", ").join(children));
children = service.getChildren2(parent);
System.out.println("Parent children after addition (using api): " + Joiner.on(", ").join(children));
} finally {
// at the end service must be stopped
persistService.stop();
}
}
示例11: main
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
public static void main(String[] args) {
final Injector injector = Guice.createInjector(new DbModule("plocal:" + DB_PATH, "admin", "admin"));
final PersistService persistService = injector.getInstance(PersistService.class);
persistService.start();
try {
final SampleService service = injector.getInstance(SampleService.class);
// run multiple times: each time count will increase
System.out.println("Overall records: " + service.count());
// as an sample we will use service without unit of work defined
// so transaction must be defined manually
final NoTxService noTxService = injector.getInstance(NoTxService.class);
// normally you will simply inject this as PersistentContext<ODatabaseDocumentTx>
final PersistentContext<ODatabaseDocumentTx> context = injector.getInstance(
Key.get(new TypeLiteral<PersistentContext<ODatabaseDocumentTx>>() {
}));
context.doInTransaction(() -> {
// unit of work defined
noTxService.doSomething();
return null;
});
// now do one more manual transaction but with provided db object
final ODocument rec = context.doInTransaction(db -> {
// service use @Transactional annotation for unit of work definition
// in this case annotation will be ignored because unit of work is already defined
final long cnt = service.count();
// manually insert record
final ODocument rec1 = db.newInstance(ManualSchemeInitializer.CLASS_NAME)
.field("name", "Sample" + cnt)
.field("amount", (int) (Math.random() * 200))
.save();
// detaching object before let it leave transaction scope
rec1.detach();
return rec1;
});
System.out.println("Just inserted record: " + rec.toJSON());
} finally {
// at the end service must be stopped
persistService.stop();
}
}
示例12: PersistentInit
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
@Inject
PersistentInit(PersistService service) {
service.start();
}
示例13: JPAInitializer
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
@Inject
public JPAInitializer(final PersistService service) {
service.start();
}
示例14: PersistInitializer
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
@Inject
PersistInitializer(PersistService persistService) {
persistService.start();
}
示例15: JpaInitializer
import com.google.inject.persist.PersistService; //导入方法依赖的package包/类
@Inject
public JpaInitializer(PersistService service) {
service.start();
}