Programmatically administer Glassfish domain

743 views Asked by At

I need to start, stop, set options on, etc. a glassfish domain in a programmatic way. The only resource I necessarily have available is asadmin. Hence I can

$ asadmin  list-domains
Foo running
domain1 not running
Command list-domains executed successfully.

However, I can't see any way to actually tell asadmin how to talk to a domain other than the default domain, Foo in this case. To do so I need to know the port of Foo's administration server, and there doesn't seem to be any way to get that information. I could theoretically parse Foo's domain.xml, but to do that I need to know where it is.

Ideally there'd be an asadmin option like --domain Foo, or at least a way to get Foo's port or directory, but I can't seem to find anything along those lines.

Advice appreciated...

$ asadmin version
Version string could not be obtained from Server [localhost:4848] for some reason.
(Turn debugging on e.g. by setting AS_DEBUG=true in your environment, to see the details).
Using locally retrieved version string from version class.
Version = GlassFish Server Open Source Edition 3.1.2.2 (build 5)
Command version executed successfully.

UPDATE: For now I'm using the filthy hack of determining the location of domain.xml via which asadmin and chopping up the path. Then I parse the xml and extract the port. This is a terrible solution, so I'm leaving the question open to see if there's anything better.

1

There are 1 answers

1
unwichtich On

Most of the asadmin commands have the target option which is nearly the same as you want.

For example the command list-javamail-resources has the following syntax: list-javamail-resources [--help] [target]

with the following operands:

    target

    This operand specifies the target for which the JavaMail session 
    resources are to be listed. Valid values are:

    server
    Lists the resources for the default server instance. This is the default.

    domain
    Lists the resources for the domain.

    cluster_name
    Lists the resources for the specified cluster.

    instance_name
    Lists the resources for a particular server instance.

For a detailed overview of command operands and parameters see the oracle documentation.