tags:

views:

268

answers:

1

Hello. I have a stateless EJB (3) that uses internal cache which is refreshed automatically every 24 hours. I would like to expose a MBean method to be able to force cache expiration or even cache reload on this EJB via JMX console on Jboss 4.2.

Can someone share an example on how to code this scenario? I'm totally new to JMX when it comes to creating my own beans.

Should I create an MBean that calls my EJB or is it possible to expose a specific EJB method as an Mbean interface by using annotation on EJB itself?

EJB looks like this:

@Stateless
@Local(BusinessCalendar.class)
public class BusinessCalendarBean implements BusinessCalendar {

    synchronized private LocalDateKitCalculatorsFactory getCalculatorFactory() {

        LocalDateKitCalculatorsFactory ldkc = (LocalDateKitCalculatorsFactory) CacheService.get(CACHE_KEY);

        if (ldkc == null) {
            ldkc = getCalculatorFactory();
            CacheService.put(CACHE_KEY, ldkc);
        }

        return ldkc;

    }

    public function expireCache() {
         // I would like to expose this as JMX managed method
    }

    ...

}
+1  A: 

Have you looked at the online JBoss configuration guide yet? This may be of some help: http://www.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/4.2.0.cp08/html/Server_Configuration_Guide/EJB3_Services-Message_Driven_Beans.html

Péter Török
The link you provided is about MDB not JMX MBeans. But I found this while browsing JBoss site:http://www.jboss.org/ejb3/docs/reference/build/reference/en/html/jboss_extensions.htmlI will probably use @Service though it's architectural change and introduces a vendor lock in by using JBoss classes instead of a standard JMX.
Michał Minicki
@Michal,glad you found something to help you forward, even if I couldn't help you much :-)
Péter Török