Package javax.management

Examples of javax.management.MBeanServer


  }

  private void createBeanForStatistics() {
    // Adding a Bean for statistical access using jmanager
    try {
      MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
      // Unique identification of MBeans
      Statistics statBean = Statistics.getStatistics();
      // Uniquely identify the MBeans and register them with the platform
      // MBeanServer
      ObjectName statName = new ObjectName("marauroad:name=Statistics");
      mbs.registerMBean(statBean, statName);
      logger.debug("Statistics bean registered.");
    } catch (Exception e) {
      logger.error("cannot register statistics bean, continuing anyway.", e);
    }
  }
View Full Code Here


         loadClientAOPConfig();

         loadServerAOPConfig();

         MBeanServer mbeanServer = getServer();

         // Acquire references to plugins. Each plug-in will be accessed directly via a reference
         // circumventing the MBeanServer. However, they are installed as services to take advantage
         // of their automatically-creating management interface.

         persistenceManager = (PersistenceManager)mbeanServer.
            getAttribute(persistenceManagerObjectName, "Instance");

         jmsUserManager = (JMSUserManager)mbeanServer.
            getAttribute(jmsUserManagerObjectName, "Instance");

         // We get references to some plugins lazily to avoid problems with circular MBean
         // dependencies
View Full Code Here

   private String deployDestinationInternal(String destinationMBeanConfig, ObjectName on,
                                            String jndiName, boolean params, int fullSize,
                                            int pageSize, int downCacheSize) throws Exception
   {
      MBeanServer mbeanServer = getServer();

      Element element = Util.stringToElement(destinationMBeanConfig);

      ServiceCreator sc = new ServiceCreator(mbeanServer);

      ClassLoader cl = this.getClass().getClassLoader();
      ObjectName loaderObjectName = null;
      if (cl instanceof UnifiedClassLoader3)
      {
         loaderObjectName = ((UnifiedClassLoader3)cl).getObjectName();
      }

      sc.install(on, loaderObjectName, element);

      // inject dependencies
      mbeanServer.setAttribute(on, new Attribute("ServerPeer", getServiceName()));
      mbeanServer.setAttribute(on, new Attribute("JNDIName", jndiName));
      if (params)
      {
         mbeanServer.setAttribute(on, new Attribute("FullSize", new Integer(fullSize)));
         mbeanServer.setAttribute(on, new Attribute("PageSize", new Integer(pageSize)));
         mbeanServer.setAttribute(on, new Attribute("DownCacheSize", new Integer(downCacheSize)));
      }
      mbeanServer.invoke(on, "create", new Object[0], new String[0]);
      mbeanServer.invoke(on, "start", new Object[0], new String[0]);

      return (String)mbeanServer.getAttribute(on, "JNDIName");

      //
      // end of TODO
      //
   }
View Full Code Here

   {
      String destType = isQueue ? "Queue" : "Topic";
      String ons ="jboss.messaging.destination:service=" + destType + ",name=" + name;
      ObjectName on = new ObjectName(ons);

      MBeanServer mbeanServer = getServer();

      // we can only undeploy destinations that exist AND that have been created programatically
      if (!mbeanServer.isRegistered(on))
      {
         return false;
      }
      Boolean b = (Boolean)mbeanServer.getAttribute(on, "CreatedProgrammatically");
      if (!b.booleanValue())
      {
         log.warn("Cannot undeploy a destination that has not been created programatically");
         return false;
      }
      mbeanServer.invoke(on, "stop", new Object[0], new String[0]);
      mbeanServer.invoke(on, "destroy", new Object[0], new String[0]);
      mbeanServer.unregisterMBean(on);
      return true;
   }
View Full Code Here

   {
      String destType = isQueue ? "Queue" : "Topic";
      String ons ="jboss.messaging.destination:service=" + destType + ",name=" + name;
      ObjectName on = new ObjectName(ons);

      MBeanServer mbeanServer = getServer();

      // we can only destroy destinations that exist AND that have been created programatically
      if (!mbeanServer.isRegistered(on))
      {
         return false;
      }
                 
      //First deactivate
     
      if (isQueue)
      {
         Binding binding = postOffice.getBindingForQueueName(name);
        
         if (binding != null)
         {
            binding.getQueue().deactivate();
         }
      }
      else
      {
         JMSCondition topicCond = new JMSCondition(false, name);   
        
         Collection bindings = postOffice.getBindingsForCondition(topicCond);
        
         Iterator iter = bindings.iterator();
         while (iter.hasNext())           
         {
            Binding binding = (Binding)iter.next();
           
            binding.getQueue().deactivate();
         }
      }
           
      //Delete any message data
     
      mbeanServer.invoke(on, "removeAllMessages", null, null);
     
      //undeploy the mbean
      if (!undeployDestination(isQueue, name))
      {
         return false;
View Full Code Here

        this.logger.debug("carolProps: {0}", carolConf);

        String domainName = null;
        try {
            MBeanServer mBeanServer = MBeanServerHelper.getMBeanServerServer();
            if (mBeanServer != null) {
                domainName = mBeanServer.getDefaultDomain();
            }
        } catch (JMXRemoteException e) {
            this.logger.debug("No domain name for JMX", e);
        }
View Full Code Here

* @version $Revision: 20459 $
*/
public class MBeanTest extends TestSupport {

    public void testGetProperty() throws Exception {
        MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
        ObjectName name = new ObjectName("groovy.test:role=TestMBean,type=Dummy");
        mbeanServer.registerMBean(new Dummy(), name);

        assertEquals("JMX value of Name", "James", mbeanServer.getAttribute(name, "Name"));

        GroovyObject object = new GroovyMBean(mbeanServer, name);

        Object value = object.getProperty("Name");
        assertEquals("Name property", "James", value);

        object.setProperty("Name", "Bob");
        assertEquals("Name property", "Bob", object.getProperty("Name"));

        // now let's look up the name via JMX to check
        assertEquals("JMX value of Name", "Bob", mbeanServer.getAttribute(name, "Name"));
    }
View Full Code Here

    public static void registerMBean(Object instance, String objName) {
        try {
            ObjectName objectName = new ObjectName(objName);
            /* register with JSR160 MBean Server*/
            MBeanServer server = getMBeanServer();
            server.registerMBean(instance, objectName);
            /* register with JDK 1.5 MBean server */
            ManagementFactory.getPlatformMBeanServer().registerMBean(instance, objectName);
            logger.info("registered MBean: " + objName);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Failed to register MBean: " + objName, e);
View Full Code Here

    public void testJMXStart()
    {
        try
        {
            MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();

            ObjectName name;
            try
            {
                name = new ObjectName( "de.netseeker.ejoe.jmx:type=EJServerConfig" );
                mbeanServer.registerMBean( server.getJMXConfigurationBean(), name );
            }
            catch ( Exception e )
            {
                e.printStackTrace();
            }
View Full Code Here

    {
        EJServerJMXSupportTest test = new EJServerJMXSupportTest();
        try
        {
            test.setUp();
            MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
            ObjectName name;
            try
            {
                name = new ObjectName( "de.netseeker.ejoe.jmx:type=EJServerConfig" );
                mbeanServer.registerMBean( test.server.getJMXConfigurationBean(), name );
                JOptionPane.showMessageDialog( null, "Ende" );
                test.tearDown();
            }
            catch ( Exception e )
            {
View Full Code Here

TOP

Related Classes of javax.management.MBeanServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.