| Java EE 7 SDK |
This is the standalone Java client for a simple EJB module that demonstrates how to use the EJB automatic timer.
This sample application consists of two parts: an EJB module and a test client (this project). The rest of this document describes the test client.
AutomaticTimerJavaClient is a client that runs outside of a Java EE container.
In this case, the client performs a global JNDI lookup since dependency injection is not
available outside of a Java EE environment.
Standalone Java Client
public class AutomaticTimerJavaClient {
public static void main(String args[]) {
try {
StatelessSession sless = (StatelessSession)
ic.lookup("java:global/automatic-timer-ejb/StatelessSessionBean");
System.out.println("Waiting for the timer to expire");
Thread.sleep(7000);
List<String> result = sless.getRecords();
System.out.println("Got " + result.size() + " log records:");
for (String s : result) {
System.out.println(s);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
Since this is the client of automatic-timer-server, so please first go to samples_install_dir/javaee7/ejb/automatic-timer/automatic-timer-server, and run the instructions described in section "Building, Deploying, and Running the Application" in the sample's document.
Following are the instructions for building and running
the Java Client.
app_dir is the sample application base
directory: samples_install_dir/javaee7/ejb/automatic-timer/automatic-timer-client.Change directory to app_dir.mvn clean verify exec:java
If you have problems when running the application, refer to the troubleshooting document.
Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.