-
1. Re: XMBean examples from Juha's JMX book
juha Mar 11, 2002 5:00 PM (in response to sebjerke)Something in the preRegister() method is not agreeing with you. Try getting the root cause from the MBeanRegistrationException and print it out to see the real reason... probably not finding the URL for the xml definition, or something similar.
-- Juha -
2. Re: XMBean examples from Juha's JMX book
sebjerke Mar 13, 2002 10:32 AM (in response to sebjerke)Hi Juha,
Well, I think the error is that I have an operation taking an int as parameter. When coming as far as to createSignature(ModelMBeanOperationInfo info) ofXMBeanOperation.java taken from your book, an exception is thrown when calling loadClass(), since type in my case is an int:
String type = sign.getType();
paramTypes = DefaultLoaderRepository.loadClass(type);
Am I correct when I say that your code here doesn't support primitive type data types as parameters to operations?
I have a more general question; I see from the current JBossMX code (taken from CVS a few days ago) that the XMBean is quite changed compared to the one in your book. I wonder if you could say a few things why for instance XMBeanOperation.java and XMBeanAttribute.java are gone? And maybe also short comment the big changes from the book's XMBean?
Thanks for your help!
--
Sven Erik -
3. Re: XMBean examples from Juha's JMX book
juha Mar 13, 2002 11:00 AM (in response to sebjerke)> Well, I think the error is that I have an operation
> taking an int as parameter. When coming as far as to
> createSignature(ModelMBeanOperationInfo info)
> ofXMBeanOperation.java taken from your book, an
> exception is thrown when calling loadClass(), since
> type in my case is an int:
>
> String type = sign.getType();
> paramTypes = DefaultLoaderRepository.loadClass(type);
oi, that might be a bug indeed.
> I have a more general question; I see from the
> current JBossMX code (taken from CVS a few days ago)
> that the XMBean is quite changed compared to the one
> in your book. I wonder if you could say a few things
> why for instance XMBeanOperation.java and
> XMBeanAttribute.java are gone?
yes, I wanted the functionality from these two classes implemented as interceptors, as it seemed to me to simplify the overall design when new behaviour is added to the model mbean.
> And maybe also short comment the big changes from the book's XMBean?
well the biggest one is the book version is currently a bit more completed. However, I don't think I'll be going back to that design so at some point this will be turned the other way around. -
4. Re: XMBean examples from Juha's JMX book
juha Mar 13, 2002 11:06 AM (in response to sebjerke)> > String type = sign.getType();
> > paramTypes = DefaultLoaderRepository.loadClass(type);
>
> oi, that might be a bug indeed.
>
On the other hand, now that I think about it, Adrian implemented a fix in JBossMX DefaultLoaderRepository to recognize primary type names and handle them correctly, so the book XMBean implementation might work if you try to run it with JBoss JMX implementation.
-- Juha -
5. Re: XMBean examples from Juha's JMX book
sebjerke Mar 13, 2002 11:49 AM (in response to sebjerke)Hi,
When compiling and running it with JBossMX (alpha2), and still using the HtmlAdaptorServer from Sun, it works :-)
(And for the record; it doesn't work with the RI from Sun).
Thanks for your help!
--
Sven Erik -
6. Re: XMBean examples from Juha's JMX book
madhu Mar 27, 2002 10:35 AM (in response to sebjerke)Please confirm this.
In order to use the XMBean WITH native data types in the method signatures, one should use ONLY JBossMX and never the JMXRI because of the above found bug.
Right?
Thanks
Madhu -
7. Re: XMBean examples from Juha's JMX book
adrian.brock Mar 27, 2002 10:52 AM (in response to sebjerke)Yes,
Technically, it is not a bug because it is not
required by the standard. Standard support across
all JMX implementations is some way off.
Look at point 23 in the DELAYED section
http://jcp.org/aboutJava/communityprocess/maintenance/jsr003/final_list.html
Regards,
Adrian -
8. Re: XMBean examples from Juha's JMX book
sebjerke Apr 2, 2002 10:08 AM (in response to sebjerke)> Please confirm this.
> In order to use the XMBean WITH native data types in
> the method signatures, one should use ONLY JBossMX
> and never the JMXRI because of the above found bug.
> Right?
Inspired by Juha's tip, I had a look at the code of org.joss.mx.loading.LoaderRepository, and modified
the createSignature of XMBeanOperation to use i.e. Integer.TYPE in the case of primitive data types in method signatures. That way, the XMBean also works with the Sun RI.
I hope this helps! If not, tell me, and I'll post what I did in more detail.
--
Sven Erik -
9. Re: XMBean examples from Juha's JMX book
juha Apr 7, 2002 4:04 PM (in response to sebjerke)please submit the changes to code if possible
I want to include bug fixes, corrections, etc. in the subsequent printings (and you'll get your name on the website too ;)
-- Juha -
10. Re: XMBean examples from Juha's JMX book
sebjerke May 4, 2002 11:47 AM (in response to sebjerke)> please submit the changes to code if possible
Ok, here are the changes I did. In
XMBeanOperation.createSignature(ModelMBeanOperationInfo info):
ORIGINAL CODE WAS:
for (int j = 0; j < paramTypes.length; ++j) {
try {
String type = sign[j].getType();
paramTypes[j] = DefaultLoaderRepository.loadClass(type);
}
CHANGED TO:
for ( int j = 0; j<paramTypes.length; ++j) {
try {
String type = sign[j].getType();
Class cls = (Class) nativeClassBySignature.get(type);
if ( cls != null ) {
paramTypes[j] = cls;
}
else {
paramTypes[j] = DefaultLoaderRepository.loadClass(type);
}
The class NativeClassMapping was more or less taken directly from org.jboss.mx.loading.LoaderRepository, as indicated in an earlier post:
import java.util.Vector;
import java.util.HashMap;
public abstract class NativeClassMapping {
protected static HashMap nativeClassBySignature = new HashMap();
static {
nativeClassBySignature.put(boolean.class.getName(), Boolean.TYPE);
nativeClassBySignature.put(byte.class.getName(), Byte.TYPE);
nativeClassBySignature.put(char.class.getName(), Character.TYPE);
nativeClassBySignature.put(double.class.getName(), Double.TYPE);
nativeClassBySignature.put(float.class.getName(), Float.TYPE);
nativeClassBySignature.put(int.class.getName(), Integer.TYPE);
nativeClassBySignature.put(long.class.getName(), Long.TYPE);
nativeClassBySignature.put(short.class.getName(), Short.TYPE);
nativeClassBySignature.put(void.class.getName(), Void.TYPE);
}
}
XMBeanOperation has to extend NativeClassBySignature, of course.
I don't know how elegant this solution is, but it works for me. Sorry for my late reply, but hope this is what you wanted. Also thanks again to Juha for his book, and thanks to all in this forum for all posts; it has helped me a lot to understand JMX better.
--
Sven Erik