users@glassfish.java.net

Re: GlassFish JMX for Dummies ?

From: Kedar Mhaswade <Kedar.Mhaswade_at_Sun.COM>
Date: Wed, 03 May 2006 08:11:02 -0700

(Posting rather long response, but subject matter mandates it).

Accessing/Invoking "MBeans" is way to administer systems that
have an implementation of instrumentation and agent
level of standard JMX: http://java.sun.com/jmx.

There is a standard way to connect to these MBeans so as
to manage them programmatically. This is much like standard
ways to invoke the Java EE server side entities using HTTP,
RMI/IIOP etc. An example of such a "standard" JMX Connector
is JConsole that's distributed with Java SE 5.0+ distribution.

MBeans are just like Java Beans although there are flavors
that make more flexible and powerful management possible using
rather complex structures. GlassFish uses such complex MBeans
called "Dynamic MBeans". The "standard" way to invoke these
MBeans is rather non object oriented. Thus, if an MBean had a
"management" method like "start(int timeout)", you'll need to
invoke it as

anMBeanRegistrar.invoke(mbeanId, "start", params, signature);

(names are chosen for sake of brevity).

What I am getting at is the concept of "proxied" Objects
so that you could write client programs just like any other
program. Unfortunately, pure JMX does not provide these proxies
over the MBeans that might be arbitrarily complex.

Hence, GlassFish goes one step further than other JMX enabled
systems like JBoss in that it uses a programmatic Java "API"
for you to able to do what other admin tools like "asadmin"
or "admin GUI" do. Deployment is just a part of it. You'd need
to for example "programmatically" create certain JVM options that
would be required by the GlassFish runtime. This comprehensive
API is called "AMX".

All this and more is documented at:

https://glassfish.dev.java.net/nonav/javaee5/amx/index.html

There are quite a few examples there, for example:

https://glassfish.dev.java.net/nonav/javaee5/amx/samples/javadoc/index.html

*Note*
This is the only official "programmatic" API to manage
GlassFish. Other ways suggested are just hacks.

The specific case of "deployment" is an interesting one because
Java EE "spec" tells users how to deploy apps to a server compliant
with JSR 88. So, in theory, you could be a JSR 88 client and do
*only* deployment that is Java EE standard compliant. But unfortunately,
you don't need to *only* deploy. A lot of configuration comes
along with it and you would need a more sophisticated way to do it.
That's what AMX tries to do.

While using AMX, on the client side all you need is a simple file
named "appserv-ext.jar" and not the entire GlassFish installation.

Regards,
Kedar



Mark Hansen wrote:
> There is a maven 2 plugin for JBoss (maven-plugin-jboss). It uses JMX
> to let you deploy/undeploy J2EE apps. I'm trying to modify it to create
> a similar plugin for GlassFish. Unfortunately, I am clueless about
> JMX. Is it possible to deploy/undeploy Java EE 5 apps (WAR, EAR, etc)
> to GlassFish using JMX? If so, is there a tutorial somewhere that I
> could use to get started?
>
> Thanks,
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>