Package javax.management.remote

Examples of javax.management.remote.JMXConnectorServer


   }

   public void testStartStop() throws Exception
   {
      JMXServiceURL url = createJMXConnectorServerAddress();
      JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer());
      cntorServer.start();
      cntorServer.stop();
   }
View Full Code Here


   }

   public void testStartStopStart() throws Exception
   {
      JMXServiceURL url = createJMXConnectorServerAddress();
      JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer());
      cntorServer.start();
      cntorServer.stop();
      try
      {
         cntorServer.start();
         fail();
      }
      catch (IOException x)
      {
      }
View Full Code Here

   }

   public void testStartStopStop() throws Exception
   {
      JMXServiceURL url = createJMXConnectorServerAddress();
      JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer());
      cntorServer.start();
      cntorServer.stop();
      cntorServer.stop();
   }
View Full Code Here

      cntorServer.stop();
   }

   public void testTwoConnectorServers() throws Exception
   {
      JMXConnectorServer cntorServer1 = null;
      JMXConnectorServer cntorServer2 = null;
      JMXConnector cntor10 = null;
      JMXConnector cntor11 = null;
      JMXConnector cntor12 = null;
      JMXConnector cntor20 = null;
      try
      {
         JMXServiceURL url1 = createJMXConnectorServerAddress();
         JMXServiceURL url2 = new JMXServiceURL(url1.getProtocol(), url1.getHost(), (url1.getPort() > 0) ? (url1.getPort() + 1) : 0, url1.getURLPath());

         MBeanServer server = newMBeanServer();
         cntorServer1 = JMXConnectorServerFactory.newJMXConnectorServer(url1, getEnvironment(), server);
         cntorServer2 = JMXConnectorServerFactory.newJMXConnectorServer(url2, getEnvironment(), server);
         cntorServer1.start();
         cntorServer2.start();

         cntor10 = JMXConnectorFactory.connect(cntorServer1.getAddress(), getEnvironment());
         cntor11 = JMXConnectorFactory.connect(cntorServer1.getAddress(), getEnvironment());
         cntor12 = JMXConnectorFactory.connect(cntorServer1.getAddress(), getEnvironment());
         cntor20 = JMXConnectorFactory.connect(cntorServer2.getAddress(), getEnvironment());

         if (cntor10.getConnectionId().equals(cntor11.getConnectionId())) fail();
         if (cntor10.getConnectionId().equals(cntor12.getConnectionId())) fail();
         if (cntor10.getConnectionId().equals(cntor20.getConnectionId())) fail();

      }
      finally
      {
         if (cntor20 != null) cntor20.close();
         if (cntor12 != null) cntor12.close();
         if (cntor11 != null) cntor11.close();
         if (cntor10 != null) cntor10.close();

         if (cntorServer2 != null) cntorServer2.stop();
         if (cntorServer1 != null) cntorServer1.stop();
      }
   }
View Full Code Here

      }
   }

   public void testStartWithProviderClassLoader() throws Exception
   {
      JMXConnectorServer cntorServer = null;
      try
      {
         JMXServiceURL url = createJMXConnectorServerAddress();
         MBeanServer server = newMBeanServer();
         Map serverEnv = getEnvironment();
         serverEnv.put(JMXConnectorServerFactory.PROTOCOL_PROVIDER_CLASS_LOADER, getClass().getClassLoader());
         Thread.currentThread().setContextClassLoader(getClass().getClassLoader().getParent());
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, serverEnv, server);
         cntorServer.start();
      }
      finally
      {
         if (cntorServer != null) cntorServer.stop();
      }
   }
View Full Code Here

   public abstract Map getEnvironment();

   public void testConnectionNotificationOpenedOnServer() throws Exception
   {
      JMXConnectorServer cntorServer = null;
      try
      {
         JMXServiceURL url = createJMXConnectorServerAddress();
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer());
         cntorServer.start();
         sleep(5000);

         final MutableObject holder = new MutableObject(null);
         cntorServer.addNotificationListener(new NotificationListener()
         {
            public void handleNotification(Notification notification, Object handback)
            {
               holder.set(notification);
            }
         }, null, null);

         JMXConnectorFactory.connect(cntorServer.getAddress(), getEnvironment());

         Notification notification = (Notification) holder.get();
         if (!(notification instanceof JMXConnectionNotification)) fail();
         assertEquals(notification.getType(), JMXConnectionNotification.OPENED);
      } catch (Exception x)
      {
         x.printStackTrace();
         throw x;
      } finally
      {
         if (cntorServer != null) cntorServer.stop();
      }
   }
View Full Code Here

      }
   }

   public void testConnectionNotificationClosedOnServer() throws Exception
   {
      JMXConnectorServer cntorServer = null;
      try
      {
         JMXServiceURL url = createJMXConnectorServerAddress();
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), newMBeanServer());
         cntorServer.start();
         sleep(5000);

         final MutableObject holder = new MutableObject(null);
         cntorServer.addNotificationListener(new NotificationListener()
         {
            public void handleNotification(Notification notification, Object handback)
            {
               holder.set(notification);
            }
         }, null, null);

         JMXConnector cntor = JMXConnectorFactory.connect(cntorServer.getAddress(), getEnvironment());
         cntor.close();

         Notification notification = (Notification) holder.get();
         if (!(notification instanceof JMXConnectionNotification)) fail();
         assertEquals(notification.getType(), JMXConnectionNotification.CLOSED);
      } catch (Exception x)
      {
         x.printStackTrace();
         throw x;
      } finally
      {
         if (cntorServer != null) cntorServer.stop();
      }
   }
View Full Code Here

      }
   }

   public void testConnectionNotificationOpenedOnClient() throws Exception
   {
      JMXConnectorServer cntorServer = null;
      JMXConnector cntor = null;
      try
      {
         JMXServiceURL url = createJMXConnectorServerAddress();
         MBeanServer server = newMBeanServer();
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), server);
         cntorServer.start();
         sleep(5000);

         final MutableObject holder = new MutableObject(null);
         cntor = JMXConnectorFactory.newJMXConnector(cntorServer.getAddress(), getEnvironment());
         cntor.addConnectionNotificationListener(new NotificationListener()
         {
            public void handleNotification(Notification notification, Object handback)
            {
               holder.set(notification);
            }
         }, null, null);

         cntor.connect(getEnvironment());

         JMXConnectionNotification notification = (JMXConnectionNotification) holder.get();
         assertEquals(notification.getType(), JMXConnectionNotification.OPENED);
      } catch (Exception x)
      {
         x.printStackTrace();
         throw x;
      } finally
      {
         if (cntor != null) cntor.close();
         if (cntorServer != null) cntorServer.stop();
      }
   }
View Full Code Here

      }
   }

   public void testConnectionNotificationClosedOnClient() throws Exception
   {
      JMXConnectorServer cntorServer = null;
      JMXConnector cntor = null;
      try
      {
         JMXServiceURL url = createJMXConnectorServerAddress();
         MBeanServer server = newMBeanServer();
         cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), server);
         cntorServer.start();
         sleep(5000);

         final MutableObject holder = new MutableObject(null);
         cntor = JMXConnectorFactory.newJMXConnector(cntorServer.getAddress(), getEnvironment());
         cntor.addConnectionNotificationListener(new NotificationListener()
         {
            public void handleNotification(Notification notification, Object handback)
            {
               holder.set(notification);
            }
         }, null, null);

         cntor.connect(getEnvironment());
         cntor.close();

         JMXConnectionNotification notification = (JMXConnectionNotification) holder.get();
         assertEquals(notification.getType(), JMXConnectionNotification.CLOSED);
      } catch (Exception x)
      {
         x.printStackTrace();
         throw x;
      } finally
      {
         if (cntor != null) cntor.close();
         if (cntorServer != null) cntorServer.stop();
      }
   }
View Full Code Here

   public void testConnectionNotificationFailedOnClient() throws Exception
   {
      JMXServiceURL url = createJMXConnectorServerAddress();
      MBeanServer server = newMBeanServer();
      JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, getEnvironment(), server);

      cntorServer.start();
      sleep(5000);

      final MutableObject holder = new MutableObject(null);
      long period = 1000;
      int retries = 3;
      try
      {
         JMXConnector cntor = JMXConnectorFactory.newJMXConnector(cntorServer.getAddress(), getEnvironment());
         cntor.addConnectionNotificationListener(new NotificationListener()
         {
            public void handleNotification(Notification notification, Object handback)
            {
               holder.set(notification);
            }
         }, null, null);

         Map clientEnv = getEnvironment();
         clientEnv.put(MX4JRemoteConstants.CONNECTION_HEARTBEAT_PERIOD, new Long(period));
         clientEnv.put(MX4JRemoteConstants.CONNECTION_HEARTBEAT_RETRIES, new Integer(retries));
         cntor.connect(clientEnv);

         JMXConnectionNotification notification = (JMXConnectionNotification) holder.get();
         assertEquals(notification.getType(), JMXConnectionNotification.OPENED);
         holder.set(null);
      } catch (Exception x)
      {
         x.printStackTrace();
         throw x;
      } finally
      {
         cntorServer.stop();
         sleep(5000);
      }

      // Wait for the heartbeat to send the failed notification
      sleep((retries * 3) * period);
 
View Full Code Here

TOP

Related Classes of javax.management.remote.JMXConnectorServer

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.