Package javax.management.j2ee

Examples of javax.management.j2ee.Management


    * @throws Exception
    */
   public void testEJBModule() throws Exception
   {
      getLog().debug("+++ testEJBModule");
      Management jsr77MEJB = getManagementEJB();
      String domainName = jsr77MEJB.getDefaultDomain();
      ObjectName mejbModuleName = new ObjectName(domainName + ":" +
         "J2EEServer=Local,J2EEApplication=null,"
         + J2EEManagedObject.TYPE + "=" + J2EETypeConstants.EJBModule
         + ",name=ejb-management.jar");
      boolean isRegistered = jsr77MEJB.isRegistered(mejbModuleName);
      assertTrue(mejbModuleName + " is not registered", isRegistered);
      String[] ejbs = (String[]) jsr77MEJB.getAttribute(mejbModuleName, "ejbs");
      // TODO assertTrue("ejb-management.jar.Ejbs.length == 0", ejbs.length > 0);
      for (int n = 0; n < ejbs.length; n++)
      {
         ObjectName ejb = new ObjectName(ejbs[n]);
         getLog().debug("Ejbs[" + n + "]=" + ejb);
         StatelessSessionBeanStats stats = (StatelessSessionBeanStats)
            jsr77MEJB.getAttribute(ejb, "stats");
         String[] statNames = stats.getStatisticNames();
         for (int s = 0; s < statNames.length; s++)
         {
            Statistic theStat = stats.getStatistic(statNames[s]);
            getLog().debug(theStat);
         }
      }
      jsr77MEJB.remove();
   }
View Full Code Here


            "stateManageable",
            "eventProvider",
            "server"
      };
      getLog().debug("+++ testWebModules");
      Management jsr77MEJB = getManagementEJB();
      String domainName = jsr77MEJB.getDefaultDomain();
      ObjectName webModules = new ObjectName(domainName+":j2eeType=WebModule,*");
      Set<ObjectName> names = jsr77MEJB.queryNames(webModules, null);
      assertTrue("", names.size() > 0);
      getLog().debug("Found web modules: "+names);
      boolean sawNullAttributes = false;
      for(ObjectName name : names)
      {
         getLog().debug("Checking module: "+name);
         for(String attrName : attributes)
         {
            Object attr = jsr77MEJB.getAttribute(name, attrName);
            if(attr == null)
            {
               getLog().error(name+" has null attribute: "+attrName);
               sawNullAttributes = true;
            }
View Full Code Here

    * @throws Exception
    */
   public void testEJBStats() throws Exception
   {
      getLog().debug("+++ testEJBStats");
      Management jsr77MEJB = getManagementEJB();
      String beanName = null;
      String query = "*:j2eeType=StatelessSessionBean,*";
      log.info(query);
      ObjectName ejbName = new ObjectName(query);
      Set managedObjects = jsr77MEJB.queryNames(ejbName,  null);
      log.info("Found " + managedObjects.size() + " objects");
      Iterator i = managedObjects.iterator();
      while (i.hasNext())
      {
         ObjectName oName = (ObjectName) i.next();
         beanName = oName.getKeyProperty("name");
         StatelessSessionBeanStats stats =
            (StatelessSessionBeanStats) jsr77MEJB.getAttribute(oName,
               "stats");
         Statistic[] allStats = stats.getStatistics();
         for (int s = 0; s < allStats.length; s++)
         {
            Statistic theStat = allStats[s];
            getLog().debug(theStat);
         }
      }
      jsr77MEJB.remove();
   }
View Full Code Here

    * @throws Exception
    */
   public void testWebModule() throws Exception
   {
      getLog().debug("+++ testWebModule");
      Management jsr77MEJB = getManagementEJB();
      String domainName = jsr77MEJB.getDefaultDomain();
      ObjectName webModuleName = new ObjectName(domainName + ":" +
         "J2EEServer=Local,J2EEApplication=null,"
         + J2EEManagedObject.TYPE + "=" + J2EETypeConstants.WebModule
         + ",name=jmx-console.war");
      boolean isRegistered = jsr77MEJB.isRegistered(webModuleName);
      assertTrue(webModuleName + " is not registered", isRegistered);
      String[] servlets = (String[]) jsr77MEJB.getAttribute(webModuleName, "servlets");
      // TODO assertTrue("jmx-console.war.Servlets.length == 0", servlets.length > 0);
      for (int n = 0; n < servlets.length; n++)
         getLog().debug("Servlets[" + n + "]=" + servlets[n]);
      jsr77MEJB.remove();
   }
View Full Code Here

    * @throws Exception
    */
   public void testResourceAdapterModule() throws Exception
   {
      getLog().debug("+++ testResourceAdapterModule");
      Management jsr77MEJB = getManagementEJB();
      String domainName = jsr77MEJB.getDefaultDomain();
      ObjectName rarModuleName = new ObjectName(domainName + ":" +
         "J2EEServer=Local,J2EEApplication=null,"
         + J2EEManagedObject.TYPE + "=" + J2EETypeConstants.ResourceAdapterModule
         + ",name=jboss-local-jdbc.rar");
      boolean isRegistered = jsr77MEJB.isRegistered(rarModuleName);
      assertTrue(rarModuleName + " is not registered", isRegistered);
      String[] ras = (String[]) jsr77MEJB.getAttribute(rarModuleName, "resourceAdapters");
      // TODO assertTrue("jboss-local-jdbc.rar.ResourceAdapters.length == 0", ras.length > 0);
      for (int n = 0; n < ras.length; n++)
         getLog().debug("ResourceAdapters[" + n + "]=" + ras[n]);
      jsr77MEJB.remove();
   }
View Full Code Here

      throws Exception
   {
      try
      {
         getLog().debug("+++ testNotificationDeliver");
         Management jsr77MEJB = getManagementEJB();
         Set names = jsr77MEJB.queryNames(getMailName(jsr77MEJB), null);
         if (names.isEmpty())
         {
            fail("Could not found JSR-77 JavaMailResource'" + TEST_MAIL + "'");
         }
         ObjectName lMail = (ObjectName) names.iterator().next();
         Listener lLocalListener = new Listener();
         ListenerRegistration lListenerFactory = jsr77MEJB.getListenerRegistry();
         getLog().debug("+++ testNotificationDeliver, add Notification Listener to " + TEST_MAIL +
            " with Listener Registry: " + lListenerFactory);
         lListenerFactory.addNotificationListener(
            lMail,
            lLocalListener,
            null,
            null
         );
         getLog().debug("+++ testNotificationDeliver, stop " + TEST_MAIL + "");
         jsr77MEJB.invoke(lMail, "stop", new Object[]{}, new String[]{});
         getLog().debug("+++ testNotificationDeliver, start " + TEST_MAIL + "");
         jsr77MEJB.invoke(lMail, "start", new Object[]{}, new String[]{});
         // Wait 5 seconds to ensure that the notifications are delivered
         Thread.sleep(5000);
         if (lLocalListener.getNumberOfNotifications() < 2)
         {
            fail("Not enough notifications received: " + lLocalListener.getNumberOfNotifications());
         }
         getLog().debug("+++ testNotificationDeliver, remove Notification Listener from " + TEST_MAIL + "");
         lListenerFactory.removeNotificationListener(
            lMail,
            lLocalListener
         );
         jsr77MEJB.remove();
      }
      catch (Exception e)
      {
         log.debug("failed", e);
         throw e;
View Full Code Here

    */
   public void testNavigation()
      throws Exception
   {
      log.info("+++ testNavigation");
      Management jsr77MEJB = null;
      try
      {
         // Get Management EJB and then the management domain
         jsr77MEJB = getManagementEJB();
         String domain = jsr77MEJB.getDefaultDomain();
         ObjectName domainQuery = new ObjectName(domain
            + ":" + J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEDomain
            + ",name="+domain);
         Set names = jsr77MEJB.queryNames(domainQuery, null);

         if (names.isEmpty())
         {
            fail("Could not find any J2EEDomain");
         }
         if (names.size() > 1)
         {
            fail("Found more than one J2EEDomain, "+names);
         }

         ObjectName jsr77MEJBDomain = (ObjectName) names.iterator().next();
         log.info("J2EEDomain: "+jsr77MEJBDomain);
         jsr77Domain = jsr77MEJBDomain.getDomain();
         // Report the attributes and references
         report(jsr77MEJB, jsr77MEJBDomain, new HashSet());
      }
      catch (Exception e)
      {
         log.debug("failed", e);
         throw e;
      }
      catch (Error err)
      {
         log.debug("failed", err);
         throw err;
      }
      finally
      {
         if (jsr77MEJB != null)
         {
            jsr77MEJB.remove();
         }
      }
   }
View Full Code Here

    * @throws Exception
    */
   public void testConnect() throws Exception
   {
      log.debug("+++ testConnect");
      Management jsr77MEJB = getManagementEJB();
      String lDomain = jsr77MEJB.getDefaultDomain();
      log.debug("+++ testConnect, domain: " + lDomain);
      jsr77MEJB.remove();
   }
View Full Code Here

   public void testJ2EEDomain()
      throws
      Exception
   {
      getLog().debug("+++ testJ2EEDomain");
      Management jsr77MEJB = getManagementEJB();
      String domain = jsr77MEJB.getDefaultDomain();
      log.debug("domain=("+domain+")");
      String nameStr = domain
         + ":" + J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEDomain
         + ",name="+domain;
      log.debug("nameStr=("+nameStr+")");
      ObjectName domainQuery = new ObjectName(nameStr);
      log.debug("domainQuery=("+domainQuery+")");
      Set names = jsr77MEJB.queryNames(domainQuery, null);
      if (names.isEmpty())
      {
         fail("Could not find JSR-77 J2EEDomain '" + J2EETypeConstants.J2EEDomain + "'");
      }
      if (names.size() > 1)
      {
         fail("Found more than one JSR-77 J2EEDomain '" + J2EETypeConstants.J2EEDomain + "'");
      }
      ObjectName jsr77MEJBDomain = (ObjectName) names.iterator().next();
      getLog().debug("+++ testJ2EEDomain, root: " + jsr77MEJBDomain);
      jsr77MEJB.remove();
   }
View Full Code Here

    * @throws Exception
    */
   public void testJ2EEServer() throws Exception
   {
      getLog().debug("+++ testJ2EEServer");
      Management jsr77MEJB = getManagementEJB();
      String domainName = jsr77MEJB.getDefaultDomain();
      ObjectName queryName = new ObjectName(domainName + ":" +
         J2EEManagedObject.TYPE + "=" + J2EETypeConstants.J2EEServer + "," + "*");

      Set names = jsr77MEJB.queryNames(queryName, null);
      if (names.isEmpty())
      {
         fail("Could not find JSR-77 J2EEServer '" + J2EETypeConstants.J2EEServer + "'");
      }
      Iterator iter = names.iterator();
      ObjectName serverName = null;
      while (iter.hasNext())
      {
         serverName = (ObjectName) iter.next();
         getLog().debug("J2EEServer: " + serverName);
      }

      // Get the server info
      String vendor = (String) jsr77MEJB.getAttribute(serverName, "serverVendor");
      getLog().debug("ServerVendor: " + vendor);
      String version = (String) jsr77MEJB.getAttribute(serverName, "serverVersion");
      getLog().debug("ServerVersion: " + version);

      // Get the list of JVMs
      String[] jvms = (String[]) jsr77MEJB.getAttribute(serverName, "javaVMs");
      if (jvms == null || jvms.length == 0)
         fail("Failed to find any JavaVMs");
      ObjectName jvm = new ObjectName(jvms[0]);
      getLog().debug("JavaVMs[0]: " + jvms[0]);
      String javaVendor = (String) jsr77MEJB.getAttribute(jvm, "javaVendor");
      getLog().debug("JavaVendor: " + javaVendor);
      String javaVersion = (String) jsr77MEJB.getAttribute(jvm, "javaVersion");
      getLog().debug("JavaVersion: " + javaVersion);
      String node = (String) jsr77MEJB.getAttribute(jvm, "node");
      getLog().debug("Node: " + node);

      jsr77MEJB.remove();
   }
View Full Code Here

TOP

Related Classes of javax.management.j2ee.Management

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.