Example #1
0
 /** Unregister all log4j MBeans if there are any left over the old deployment */
 protected void unregisterMBeansIfNecessary()
     throws MalformedObjectNameException, InstanceNotFoundException, MBeanRegistrationException {
   if (mBeanServer.isRegistered(jmxSupport.getObjectName(JMX_OBJECT_NAME))) {
     // unregister all log4jMBeans and loggers
     Set log4jMBeans = mBeanServer.queryMBeans(jmxSupport.getObjectName("log4j*:*"), null);
     for (Iterator it = log4jMBeans.iterator(); it.hasNext(); ) {
       ObjectInstance objectInstance = (ObjectInstance) it.next();
       ObjectName theName = objectInstance.getObjectName();
       mBeanServer.unregisterMBean(theName);
     }
   }
 }
Example #2
0
 /*
  * (non-Javadoc)
  *
  * @see org.mule.umo.lifecycle.Initialisable#initialise()
  */
 public void initialise() throws InitialisationException {
   try {
     mBeanServer = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
     final ObjectName objectName = jmxSupport.getObjectName(JMX_OBJECT_NAME);
     // unregister existing Log4j MBean first if required
     unregisterMBeansIfNecessary();
     mBeanServer.registerMBean(new HierarchyDynamicMBean(), objectName);
   } catch (Exception e) {
     throw new InitialisationException(CoreMessages.failedToStart("JMX Agent"), e, this);
   }
 }