public class ProcessRunner
extends java.lang.Object
This class can be used on its own and is provided with the jar library z.jar that can be found in the
bin
folder of a z2 home installation.
There are some important considerations and pre-requisites to run z2 embedded successfully:
com.zfabrik.home
or by specifying an environment property Z2_HOME
pointing to a z2 home installation. This is required so that the root repository information (in Z2_HOME/bin/runtime.properties
) local repository
caches (in Z2_HOME/work
) can be found. The system property takes precedence over the environment variable.
public static void main(String[] args) throws Exception { ProcessRunner.start(); ProcessRunner.work(new CallableProcess running is cumulative. Repeated start/stop calls will be counted and only the outer calls are really effectiv.() { public Void call() throws Exception { ((Runnable) new InitialContext().lookup("components:<my component>?type="+Runnable.class.getName())).run(); return null; } }); ProcessRunner.stop(); }
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
COM_ZFABRIK_HOME |
|
static java.lang.String |
Z2_HOME |
Modifier and Type | Method | Description |
---|---|---|
static void |
beginWork() |
Begin a unit of work.
|
static void |
closeWork() |
End a unit of work.
|
boolean |
isRunning() |
check if the process is already initialized
|
static void |
setRollBackOnly() |
Flag a unit of work as rollback only.
|
static void |
start() |
Initialize the z2 environment in this process.
|
static void |
stop() |
stop the z2 environment in this process.
|
static void |
work(java.lang.Runnable r) |
Tasks in z2 generally require an association with a work unit (an abstract
transaction).
|
static <T> T |
work(java.util.concurrent.Callable<T> c) |
Tasks in z2 generally require an association with a work unit (an abstract
transaction).
|
public static final java.lang.String Z2_HOME
public static final java.lang.String COM_ZFABRIK_HOME
public static void start()
public static void work(java.lang.Runnable r)
Runnable
or a Callable
and
use the work(java.lang.Runnable)
methods.public static <T> T work(java.util.concurrent.Callable<T> c)
Runnable
or a Callable
and
use the work(java.lang.Runnable)
methods.public static void beginWork()
public static void closeWork()
public static void setRollBackOnly()
public boolean isRunning()
public static void stop()