Discussion:
[Openjmx-devel] MBean view with constructors
Carlos Quiroz
2002-01-30 19:52:02 UTC
Permalink
Hi all

I just added what I believe is a crucial feature of the HttpAdaptor. Now the
default MBean view will lead you to a page where you can query the
constructors of a given class. As an answer you will get the class'
constructors and you can create MBeans.

Please give it a try.

Some things open:
First:
How to handle classloaders?
Should the classloader be a MBean?
I guess so since the createMBean and instantiate methods allow only an
ObjectName as loaderName.

If so, how can you create a ClassLoader which is MBean and has ObjectName?
AFAIK there is no such MBean, please correct me if I'm wrong. Should we
create one in none is available?

Second question:
What's the best way to do this. Do a createMBean (current option) or do a
instantiate and then a registerMBean

Regards

Carlos Quiroz
Bordet, Simone
2002-01-30 20:27:04 UTC
Permalink
Hi,
Post by Carlos Quiroz
Hi all
I just added what I believe is a crucial feature of the
HttpAdaptor. Now the
default MBean view will lead you to a page where you can query the
constructors of a given class. As an answer you will get the class'
constructors and you can create MBeans.
Please give it a try.
How to handle classloaders?
Should the classloader be a MBean?
I guess so since the createMBean and instantiate methods
allow only an
ObjectName as loaderName.
The classloader can be an MBean or the classloader of the MBeanServer class (on the server), if you specify it null, or the DLR, is you don't specify it. Jar must be available through an URL; so or local to the server, or served by an http server.
Post by Carlos Quiroz
If so, how can you create a ClassLoader which is MBean and
has ObjectName?
AFAIK there is no such MBean, please correct me if I'm wrong.
Aaaahhhhhh ! :)
javax.management.loading.MLet
Post by Carlos Quiroz
Should we
create one in none is available?
You can always do that: subclass URLClassLoader and give it a management interface (empty for that matters), and register it.
Post by Carlos Quiroz
What's the best way to do this. Do a createMBean (current
option) or do a
instantiate and then a registerMBean
So, I did not totally get your feature.
You can create objects of whatever class that will be stored along with the http session that then you can pass to constructors or setter methods ?
Or you just display MBeanConstructorInfo metadata ?
If the latter, then parameter to constructor must be simple types (int, strings), right ?
Do you use JavaBeans API to convert (PropertyEditors) ?

Finally, unless you perform instantiate and register in 2 http requests (I guess you don't), doing createMBean or instantiate + registerMBean is the same. One call is probably simpler.

One question: if you have this MBean:

public class Service implements ServiceMBean
{
public Service(Info info) {...}
}
public class Info
{
public Info(String date, String user) {...}
}

it is not yet possible to create an Info object, store it along with http session and tell the adaptor to use that object to create the MBean, right ? Just curious.

However, great job Carlos !

Simon
Carlos Quiroz
2002-01-30 20:40:02 UTC
Permalink
Post by Bordet, Simone
Hi,
Post by Carlos Quiroz
Hi all
I just added what I believe is a crucial feature of the
HttpAdaptor. Now the
default MBean view will lead you to a page where you can query the
constructors of a given class. As an answer you will get the class'
constructors and you can create MBeans.
Please give it a try.
How to handle classloaders?
Should the classloader be a MBean?
I guess so since the createMBean and instantiate methods
allow only an
ObjectName as loaderName.
The classloader can be an MBean or the classloader of the MBeanServer class
(on the server), if you specify it null, or the DLR, is you don't specify
it. Jar must be available through an URL; so or local to the server, or
served by an http server.
Now is working by using a null classloader
Post by Bordet, Simone
Post by Carlos Quiroz
If so, how can you create a ClassLoader which is MBean and
has ObjectName?
AFAIK there is no such MBean, please correct me if I'm wrong.
Aaaahhhhhh ! :)
javax.management.loading.MLet
Right, this is the one. I knew it couldn't be missing :-)
I guess I will add an interface to create MLets, where you can pass a list of
URLs
Post by Bordet, Simone
Post by Carlos Quiroz
Should we
create one in none is available?
You can always do that: subclass URLClassLoader and give it a management
interface (empty for that matters), and register it.
I guess the MLet is enough
Post by Bordet, Simone
Post by Carlos Quiroz
What's the best way to do this. Do a createMBean (current
option) or do a
instantiate and then a registerMBean
So, I did not totally get your feature.
You can create objects of whatever class that will be stored along with the
http session that then you can pass to constructors or setter methods ? Or
you just display MBeanConstructorInfo metadata ?
No session ever, never :-)
the constructor request will return the constructors for a given class (any
class). Then you get a GUI for using that constructor, that is fiels to set
params and an objectname. Obviously if you query for java.lang.String you
will get some constructor but if you try to construct it there will be a
problem because it is not an MBean

A more refined version could do the cheking beforehand
Post by Bordet, Simone
If the latter, then parameter to constructor must be simple types (int,
strings), right ? Do you use JavaBeans API to convert (PropertyEditors) ?
Now is only basic types + ObjectName. I'm thinking how to do it for adding
custom types in principle is not a problem as fas as you can have an empty
constructor or a constructor that takes a String, that includes things like
ObjectName, URL, Date.
This requires a bit more thinking tough
Post by Bordet, Simone
Finally, unless you perform instantiate and register in 2 http requests (I
guess you don't), doing createMBean or instantiate + registerMBean is the
same. One call is probably simpler.
Ok. I'm doing registerMBean, that's also better since if the class is not
MBean it won't be instantiated, will be?
Post by Bordet, Simone
public class Service implements ServiceMBean
{
public Service(Info info) {...}
}
public class Info
{
public Info(String date, String user) {...}
}
it is not yet possible to create an Info object, store it along with http
session and tell the adaptor to use that object to create the MBean, right
? Just curious.
No. Again no session has been implemented
Post by Bordet, Simone
However, great job Carlos !
Simon
_______________________________________________
Openjmx-devel mailing list
https://lists.sourceforge.net/lists/listinfo/openjmx-devel
Bordet, Simone
2002-01-31 08:18:04 UTC
Permalink
Hi,
Post by Bordet, Simone
Post by Bordet, Simone
Post by Carlos Quiroz
What's the best way to do this. Do a createMBean (current
option) or do a
instantiate and then a registerMBean
So, I did not totally get your feature.
You can create objects of whatever class that will be
stored along with the
Post by Bordet, Simone
http session that then you can pass to constructors or
setter methods ? Or
Post by Bordet, Simone
you just display MBeanConstructorInfo metadata ?
No session ever, never :-)
the constructor request will return the constructors for a
given class (any
class). Then you get a GUI for using that constructor, that
is fiels to set
params and an objectname. Obviously if you query for
java.lang.String you
will get some constructor but if you try to construct it
there will be a
problem because it is not an MBean
Ok, so it is useful only for MBeans.
Post by Bordet, Simone
A more refined version could do the cheking beforehand
Well, if you use it only for MBeans, no check: use MBeanConstructorInfo metadata.
Post by Bordet, Simone
Post by Bordet, Simone
Finally, unless you perform instantiate and register in 2
http requests (I
Post by Bordet, Simone
guess you don't), doing createMBean or instantiate +
registerMBean is the
Post by Bordet, Simone
same. One call is probably simpler.
Ok. I'm doing registerMBean, that's also better since if the
class is not
MBean it won't be instantiated, will be?
No, it will be instantiated. Checks are done upon registration. You can create whatever class with instantiate.

Simon
Carlos Quiroz
2002-01-31 09:14:02 UTC
Permalink
Hi
Post by Bordet, Simone
Hi,
<snip>
Post by Bordet, Simone
Ok, so it is useful only for MBeans.
Yes that's the idea
Post by Bordet, Simone
Post by Carlos Quiroz
A more refined version could do the cheking beforehand
Well, if you use it only for MBeans, no check: use MBeanConstructorInfo metadata.
How can you get a MBeanConstructorInfo if your only data is classname?
I was thinking to use you MBeanIntrospector class
Post by Bordet, Simone
Post by Carlos Quiroz
Post by Bordet, Simone
Finally, unless you perform instantiate and register in 2
http requests (I
Post by Bordet, Simone
guess you don't), doing createMBean or instantiate +
registerMBean is the
Post by Bordet, Simone
same. One call is probably simpler.
Ok. I'm doing registerMBean, that's also better since if the
class is not
MBean it won't be instantiated, will be?
No, it will be instantiated. Checks are done upon registration. You can
create whatever class with instantiate.
Perhaps this is not desirable in this case. You would like the object not to
be create unless it can be a MBean. This can be enforced outside the
registerMBean method tough
Post by Bordet, Simone
Simon
_______________________________________________
Openjmx-devel mailing list
https://lists.sourceforge.net/lists/listinfo/openjmx-devel
Loading...