Package org.jboss.jmx.adaptor.rmi

Examples of org.jboss.jmx.adaptor.rmi.RMIAdaptor


   public void testNotification() throws Exception
   {
      log.info("+++ testNotification");
      RMIListener listener = new RMIListener(10);
      listener.export();
      RMIAdaptor server = (RMIAdaptor) getInitialContext().lookup("jmx/invoker/RMIAdaptor");
      server.addNotificationListener(getObjectName(), listener, null, "runTimer");
      server.invoke(getObjectName(), "startTimer", null, null);
      synchronized( listener )
      {
         listener.wait(15000);
      }
      server.removeNotificationListener(getObjectName(), listener);
      listener.unexport();
      int count = listener.getCount();
      assertTrue("Received 10 notifications, count="+count, count == 10);
   }
View Full Code Here


    * @throws Exception
    */
   public void testNotificationWithBadListener() throws Exception
   {
      log.info("+++ testNotificationWithBadListener");
      RMIAdaptor server = (RMIAdaptor) getInitialContext().lookup("jmx/invoker/RMIAdaptor");
      // Add a bad listener
      RMIBadListener badListener = new RMIBadListener();
      badListener.export();
      server.addNotificationListener(getObjectName(), badListener, null, "BadListener");
      RMIListener listener = new RMIListener(10);
      listener.export();
      // Add a good listener
      server.addNotificationListener(getObjectName(), listener, null, "runTimer");
      server.invoke(getObjectName(), "startTimer", null, null);
      // Wait 25 seconds for the good listener events to complete
      synchronized( listener )
      {
         listener.wait(25000);
      }
      server.removeNotificationListener(getObjectName(), listener);
      listener.unexport();
      int count = listener.getCount();
      assertTrue("Received 10 notifications from Listener, count="+count,
         count == 10);
      count = badListener.getCount();
      assertTrue("Received >= 1 notifications from BadListener, count="+count,
         count >= 1);
      try
      {
         server.removeNotificationListener(getObjectName(), badListener);
         badListener.unexport();
      }
      catch(ListenerNotFoundException e)
      {

View Full Code Here

         Thread.sleep(10000);

         // Compare all of the changed attribute values to the actual values.
         // They must all match for the test to pass.
         InitialContext ic = new InitialContext();
         RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/invoker/RMIAdaptor");
         ObjectName objectName = new ObjectName(data.getName());
         Properties attrs = data.getAttributes();
         Enumeration keys = attrs.keys();
         log.info("Verifying MBean attribute values:");
         while (keys.hasMoreElements())
         {
            String attr = (String) keys.nextElement();
            String expected = (String) attrs.get(attr);
            Object obj = server.getAttribute(objectName, attr);
            String actual = obj.toString();
            log.info("-- attribute    = " + attr);
            log.info("   expect value = " + expected);
            log.info("   actual value = " + actual);
            log.info("   actual type  = " + obj.getClass().getName());
View Full Code Here

      getLog().debug("+++ testMBeanInfoMarshalling");
     
      initURLHandlers();
     
      InitialContext ctx = getInitialContext();
      RMIAdaptor rmiAdaptor = (RMIAdaptor)ctx.lookup("jmx/invoker/RMIAdaptor");
      Iterator it = rmiAdaptor.queryNames(null, null).iterator();

      while (it.hasNext())  
      {
         ObjectName objectName = (ObjectName)it.next();
         try
         {
            MBeanInfo mbeanInfo = rmiAdaptor.getMBeanInfo(objectName);
         }
         catch (Throwable t)
         {
            getLog().error("Caught exception getting MBeanInfo for: " + objectName, t);
            super.fail("Failed to get MBeanInfo for bean named: " + objectName);
View Full Code Here

      }
      if( partitionName == null )
         throw new NamingException("Failed to find any parition");
      env.setProperty(NamingContext.JNP_PARTITION_NAME, partitionName);

      RMIAdaptor adaptor = (RMIAdaptor) ctx.lookup("jmx/rmi/RMIAdaptor");
      ObjectName clusterPartition = new ObjectName("jboss:service="+partitionName);
      Vector view = (Vector) adaptor.getAttribute(clusterPartition, "CurrentView");
      log.debug("Found ClusterPartition: "+clusterPartition);
      hosts = new String[view.size()];
      for(int v = 0; v < view.size(); v ++)
      {
         Object addr = view.get(v);
View Full Code Here

   public static void main(String[] args) throws Exception
   {
      try {
      InitialContext ctx = new InitialContext();
      //Get hold of the MBean server invoker
      RMIAdaptor server = (RMIAdaptor)ctx.lookup("jmx/invoker/RMIAdaptor");

      //Set attribute on singleton ServiceOne via remote interface
      ServiceOneRemote serviceOne = (ServiceOneRemote) ctx.lookup("serviceOne/remote");
      serviceOne.setAttribute(100);

      //Create object name for ServiceOne
      ObjectName service1 = new ObjectName("tutorial:service=serviceOne");
      //Get attribute of singleton ServiceOne via JMX
      int attr1 = (Integer)server.getAttribute(service1, "Attribute");
      System.out.println("attribute value for singleton obtained via JMX is what we set via remote interface: " + attr1);

      //Create object name for ServiceThree
      ObjectName service3 = new ObjectName("tutorial:service=serviceThree");
      //Call serviceOneHello() and serviceTwoHello() on ServiceThree
      Object[] noArgs = new Object[0];//No arguments
      String[] noSig = new String[0];//No parameters in signature

      String service1Hello = (String)server.invoke(service3, "serviceOneHello", noArgs, noSig);
      System.out.println(service1Hello);
      String service2Hello = (String)server.invoke(service3, "serviceTwoHello", noArgs, noSig);
      System.out.println(service2Hello);
      } catch (Exception e)
      {
         e.printStackTrace();
      }
View Full Code Here

{
   public static void main(String[] args) throws Exception
   {
      InitialContext ctx = new InitialContext();
      //Get hold of the MBean server invoker
      RMIAdaptor server = (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor");

      invokeService(ctx, server);

      invokeXMBean(ctx, server);
   }
View Full Code Here

    catch (final NamingException ne)
    {
      throw new ExceptionInInitializerError("Failed to initialize naming context: " + ne);
    }
   
    RMIAdaptor adaptor = null ;
    try
    {
      adaptor = (RMIAdaptor)ctx.lookup("jmx/rmi/RMIAdaptor") ;
    }
    catch (final NamingException ne)
View Full Code Here

/*     */     catch (NamingException ne)
/*     */     {
/*  68 */       throw new ExceptionInInitializerError("Failed to initialize naming context: " + ne);
/*     */     }
/*     */
/*  71 */     RMIAdaptor adaptor = null;
/*     */     try
/*     */     {
/*  74 */       adaptor = (RMIAdaptor)ctx.lookup("jmx/rmi/RMIAdaptor");
/*     */     }
/*     */     catch (NamingException ne)
View Full Code Here

TOP

Related Classes of org.jboss.jmx.adaptor.rmi.RMIAdaptor

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.