-
Notifications
You must be signed in to change notification settings - Fork 2
Standalone Application Setup
sclassen edited this page Jan 4, 2013
·
2 revisions
public static void main(String[] args) {
final PersistenceModule persistenceModule = new PersistenceModule();
persistenceModule.addApplicationManagedPersistenceUnit("puName").useResourceLocalTransaction();
final Injector injector = Guice.createInjector(persistenceModule, getApplicationSpecificModules());
final PersistenceService persistenceService = injector.getInstance(injector.getInstance(PersistenceService.class).class)
try {
persistenceService.start();
while(notTerminated()) {
// run application
}
}
finally {
persistenceService.stop();
}
}
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="puName" transaction-type="RESOURCE_LOCAL">
<!-- your configuration -->
</peristence-unit>
</peristence>
+ app.jar
| + META-INF
| | + MANIFEST.MF
| | + persistence.xml
| + foo
| | + bar
| | | + Main.class
| | | + App.class