Danny Choi
Danny Choi

Reputation: 261

How to check my jboss is started in JAVA?

ex) abc.war is deployed in Jboss.

I want to know that jboss is started or not... in already deployed java source(abc.war).

there is running a thread to check it out.

but I wondering how can I know my jboss is completelly started.

or How to know the end point which jboss is successfully started.

cos I have to execute some method after jboss is completelly on.

jboss5.0 + spring3.0 + jre1.6

Upvotes: 1

Views: 879

Answers (2)

kostja
kostja

Reputation: 61538

EDIT: I just realized that you were aiming at JBoss 5. AFAIK, the below advice works only with JBoss 7.x. Please tell if it is still relevant to you. Otherwise I will delete the answer.

You can use the Jboss Management API for this. HEre is an example of how to access JBoss management using JBoss detyped management (jboss.dmr) library:

    final ModelNode request = new ModelNode();
    request.get(ClientConstants.OP).set("read-resource");
    request.get("recursive").set(true);
    request.get(ClientConstants.OP_ADDR).add("subsystem", "deployments");

    ModelControllerClient client = null;
    try {
        client = ModelControllerClient.Factory.create(InetAddress.getByName(MANAGEMENT_HOST),
                MANAGEMENT_PORT);
    } catch (final UnknownHostException e) {
        log.warn("unable to create ModelControllerClient on {}:{}, {}", new Object[] {
                MANAGEMENT_HOST, MANAGEMENT_PORT, e });
        return;
    }
    ModelNode response = null;
    try {
        response = client.execute(new OperationBuilder(request).build());
    } catch (final IOException e) {
        log.warn("unable to perform operation : {}, {}", request, e);
        return;
    }

    log.info("request returned following results:");
    final ModelNode resultNode = response.get(ClientConstants.RESULT);
    for (final String key : resultNode.keys()) {
        log.info("{} : {}", key, resultNode.get(key));
    }

Upvotes: 1

hd1
hd1

Reputation: 34657

Perhaps JSR-88 would be of assistance, which JBoss supports and even provides example code to note its use?

Upvotes: 0

Related Questions