Thanks,
On 6 Dec, Andy "Mad" Schaefer wrote:
> Hi
>
> Yes, I know that I already promissed to create a HowTo on the time
> issue but I didn't got the time.
> But for short there's the way (I assume that you are in the same JVM
> as jBoss is running):
> - Add a <MLET> tag to jBoss.conf loading "javax.management.timer.Timer"
> - Get a reference to the MBeanServer. If you are in a MBean then you
> get it for free (during pre or post registration) otherwise you have it
> to get it from JNDI or through MBeanFactory.getMBeanServer() ).
What is the JNDI name?
> - Get the ObjectInstance through the MBeanServer like:
> Set lBeans = lBeanServer.queryMBeans(
> new ObjectName( "DefaultDomain", "service", "timer" ),
> null
> );
> if( !lBeans.isEmpty() ) {
> ObjectInstance lTimerBean = (ObjectInstance)
> lBeans.iterator().next();
> - use addNotification() on the Timer to set what you are interested in:
> lBeanServer.invoke( lTimerBean.getObjectName(), "addNotification",
> new Object[] { <List of parameters see JavaDoc> },
> new String[] { <List of parameters data type> }
> );
> - add yourself as a Notification Listener:
> lBeanServer.addNotificationListener(
> lTimerBean.getObjectName(), <your listener instance>
> );
>
Here is an alternative (at least it seems to work for mee):
1. Ad listeners:
MBeanServer server = (MBeanServer) MBeanServerFactory.
findMBeanServer(null).iterator().next();
server.addNotificationListener(new ObjectName("Timer:service=Timer"),
listener,
filter,
o);
2. Add stuff to time:
timer = (TimerMBean)MBeanProxy.create(TimerMBean.class,"Timer:service=Timer");
timer.addNotification("test", "testing",
null, new java.util.Date(new java.util.Date().
getTime() +Timer.ONE_MINUTE )
);
With MLET set to:
<MLET CODE = "javax.management.timer.Timer" ARCHIVE="jmxri.jar" NAME="Timer:serv
ice=Timer" CODEBASE="../../lib/">
</MLET>
//Peter
> That's it.
>
> Have fun - Mad Andy / Better Pizza
>
> Senior Java Developer
> eBuilt Inc. (www.ebuilt.com)
>
> while( true ) { think(); write(); publish(); }
>
> ----- Original Message -----
> From: "Peter Antman" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, December 06, 2000 8:31 AM
> Subject: [jBoss-User] Timer Mbean - how to get at it
>
>
>> Hi,
>> I am trying to build some fun stuff around jboss, MBeans and the new
>> MessageDriven beans.
>>
>> I would like to use the javax.management.Timer to do some message
>> thinks. But how do I get access to it? I can't figure that out.
>>
>> If I add it to the jboss.conf file it starts ok. But it does not bind to
>> JNDI, or if it does, no one knows.
>>
>> I have tried using the nice MBeanProxy to get access to it, and that
>> also works fine, with one minor flaw: you can only add stuff to time,
>> but no listeneres to get the event sent to, since the API for this is
>> not part of the TimerMBean interface.
>>
>> So how do I get access to the real Timer, so I can add
>> NotificationListeners?
>>
>> Richard, any clue here?
>>
>> //Peter
>>
>> --
>> Jobba hos oss: http://www.tim.se/weblab
>> ------------------------------------------------------------
>> Peter Antman Technology in Media, Box 34105 100 26 Stockholm
>> Systems Architect WWW: http://www.tim.se
>> Email: [EMAIL PROTECTED] WWW: http://www.backsource.org
>> Phone: +46-(0)8-506 381 11 Mobile: 070-675 3942
>> ------------------------------------------------------------
>>
>>
>>
>> --
>> --------------------------------------------------------------
>> To subscribe: [EMAIL PROTECTED]
>> To unsubscribe: [EMAIL PROTECTED]
>> Problems?: [EMAIL PROTECTED]
>>
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Problems?: [EMAIL PROTECTED]
>
--
Jobba hos oss: http://www.tim.se/weblab
------------------------------------------------------------
Peter Antman Technology in Media, Box 34105 100 26 Stockholm
Systems Architect WWW: http://www.tim.se
Email: [EMAIL PROTECTED] WWW: http://www.backsource.org
Phone: +46-(0)8-506 381 11 Mobile: 070-675 3942
------------------------------------------------------------
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]