Skip to content

Commit

Permalink
[MOD] Important: all REST/rest artifacts renamed to JAX-RX/jaxrx.
Browse files Browse the repository at this point in the history
  • Loading branch information
christian gruen committed Feb 15, 2011
1 parent 699fb4e commit f241e76
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/main/java/org/basex/examples/perf/Benchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
* @author BaseX Team 2005-11, ISC License
*/
public abstract class Benchmark {
/** Database context. */
public final Context context = new Context();
/** Server reference. */
private BaseXServer server;
/** Session. */
private Session session;
/** Input document. */
Expand All @@ -34,8 +38,6 @@ public abstract class Benchmark {
private int max = Integer.MAX_VALUE;
/** Local vs server flag. */
private boolean local;
/** Server started flag. */
private boolean start;

/**
* Initializes the benchmark.
Expand All @@ -47,16 +49,13 @@ protected boolean init(final String... args) throws Exception {
out.println("=== " + Util.name(this) + " Test ===");
if(!parseArguments(args)) return false;

final Context ctx = new Context();

// Check if server is (not) running
start = !local &&
!BaseXServer.ping(LOCALHOST, ctx.prop.num(Prop.SERVERPORT));

if(start) new BaseXServer("");
server = !local &&
!BaseXServer.ping(LOCALHOST, context.prop.num(Prop.SERVERPORT)) ?
new BaseXServer("") : null;

session = local ? new LocalSession(ctx) :
new ClientSession(ctx, "admin", "admin");
session = local ? new LocalSession(context) :
new ClientSession(context, "admin", "admin");

// Create test database
session.execute(new Set(Prop.QUERYINFO, true));
Expand All @@ -69,7 +68,7 @@ protected boolean init(final String... args) throws Exception {
* Stops the server.
*/
protected void finish() {
if(start) BaseXServer.stop(1984);
if(server != null) server.stop();
}

/**
Expand Down

0 comments on commit f241e76

Please sign in to comment.