-
1. Re: Accessing an MBean from within JVM
adrian.brock Apr 29, 2003 4:03 PM (in response to stevecoh1)You don't access the MBean directly.
One of the main points to MBeans is that they
are decoupled, you don't hold direct references
to the service you are trying to use.
Having that, it is possible with an MBean operation
like:
public MyClass getInstance()
{
return this;
}
I wouldn't recommend this approach.
If you are worried about the performance, don't :-)
You can always have a
public void add(int) operation.
Regards,
Adrian -
2. Re: Accessing an MBean from within JVM
stevecoh1 Apr 29, 2003 8:26 PM (in response to stevecoh1)Thanks. I had more or less come to the same conclusion and had figured out most of the points in my earlier question. However, it is blowing up on me in a most annoying way when I try to access the MBean indirectly.
Can you explain what is happening here:
see attached file. -
3. Re: Accessing an MBean from within JVM
stevecoh1 Apr 29, 2003 8:32 PM (in response to stevecoh1)Anyone answering might want to see the MBean code too, I suppose :-)
-
4. Re: Accessing an MBean from within JVM
adrian.brock Apr 29, 2003 8:59 PM (in response to stevecoh1)Change the method to something like:
public int getLastStoryHandled() {
try
{
if (this.lastStoryHandled < 0) {
load();
}
return this.lastStoryHandled;
}
catch (RuntimeException e)
{
e.printStackTrace();
throw e;
}
}
Regards,
Adrian -
5. Re: Accessing an MBean from within JVM
stevecoh1 Apr 29, 2003 11:25 PM (in response to stevecoh1)Thanks.
Doh! I didn't even need to put the logging in. There was an uninitialized null variable in my bean. I forgot to initialize it. I spent so much time tracking down errors due to naming mismatches I forgot to look at my own code.
Might be a good idea for the JBoss code to show a bit more stack trace there, though.