Examples of MLet


Examples of javax.management.loading.MLet

      int initial = size.intValue();

      ObjectName name1 = new ObjectName(":name=mlet1");
      ObjectName name2 = new ObjectName(":name=mlet2");

      MLet mlet1 = new MLet();
      server.registerMBean(mlet1, name1);

      // Check that the mlet was registered as classloader
      size = (Integer)method.invoke(clr, new Object[0]);
      if (size.intValue() != initial + 1) fail("ClassLoader not registered in ClassLoaderRepository");

      // Add another classloader
      MLet mlet2 = new MLet();
      server.registerMBean(mlet2, name2);

      size = (Integer)method.invoke(clr, new Object[0]);
      if (size.intValue() != initial + 2) fail("ClassLoader not registered in ClassLoaderRepository");
   }
View Full Code Here

Examples of javax.management.loading.MLet

      int initial2 = size2.intValue();

      ObjectName name1 = new ObjectName(":name=mlet1");
      ObjectName name2 = new ObjectName(":name=mlet2");

      MLet mlet1 = new MLet();
      server1.registerMBean(mlet1, name1);

      MLet mlet2 = new MLet();
      server2.registerMBean(mlet2, name2);

      // Check that the mlet was registered as classloader
      size1 = (Integer)method.invoke(clr1, new Object[0]);
      if (size1.intValue() != initial1 + 1) fail("ClassLoader not registered in ClassLoaderRepository");
View Full Code Here

Examples of javax.management.loading.MLet

      int initial = size.intValue();

      ObjectName name1 = new ObjectName(":name=mlet1");
      ObjectName name2 = new ObjectName(":name=mlet2");

      MLet mlet1 = new MLet();
      server.registerMBean(mlet1, name1);
      server.registerMBean(mlet1, name2);

      // Check that the mlet was registered only once
      size = (Integer)method.invoke(clr, new Object[0]);
View Full Code Here

Examples of javax.management.loading.MLet

      System.setProperty(MX4JSystemKeys.MX4J_MBEANSERVER_CLASSLOADER_REPOSITORY, CLRWithOnlyMLets.class.getName());
      MBeanServer server = newMBeanServer();

      ObjectName mletName = new ObjectName(":loader=mlet1");

      MLet mlet = new MLet();
      server.registerMBean(mlet, mletName);

      Set mbeans = mlet.getMBeansFromURL(mletFile.toURL());
      if (mbeans.size() != 1) fail("Loaded wrong number of MBeans");
      ObjectInstance instance = (ObjectInstance)mbeans.iterator().next();
      if (!instance.getClassName().equals(className)) fail("Loaded a different MBean");
   }
View Full Code Here

Examples of javax.management.loading.MLet

      System.setProperty(MX4JSystemKeys.MX4J_MBEANSERVER_CLASSLOADER_REPOSITORY, CLRWithOnlyMLets.class.getName());
      MBeanServer server = newMBeanServer();

      ObjectName mletName = new ObjectName(":loader=mlet1");
      MLet mlet = new MLet();
      server.registerMBean(mlet, mletName);

      Set mbeans = mlet.getMBeansFromURL(mletFile.toURL());
      if (mbeans.size() != 1) fail("Loaded wrong number of MBeans");
      ObjectInstance instance = (ObjectInstance)mbeans.iterator().next();
      if (!instance.getClassName().equals(className)) fail("Loaded a different MBean");
   }
View Full Code Here

Examples of javax.management.loading.MLet

      MBeanServer server = MBeanServerFactory.newMBeanServer();

      // Needed to create an MLet, which is a ClassLoader
      addPermission(new RuntimePermission("createClassLoader"));
      ObjectName name = new ObjectName(server.getDefaultDomain(), "mbean", "mlet");
      MLet mlet = new MLet();
      addPermission(new MBeanPermission(mlet.getClass().getName(), "registerMBean"));
      server.registerMBean(mlet, name);

      try
      {
         server.getClassLoader(null);
         fail();
      }
      catch (SecurityException ignored)
      {
      }

      // Dummy class
      addPermission(new MBeanPermission("foo[" + name.getCanonicalName() + "]", "getClassLoader"));

      try
      {
         server.getClassLoader(name);
         fail();
      }
      catch (SecurityException ignored)
      {
      }

      addPermission(new MBeanPermission(mlet.getClass().getName() + "[" + name.getCanonicalName() + "]", "getClassLoader"));
      ClassLoader result = server.getClassLoader(name);
      assertSame(result, mlet);
   }
View Full Code Here

Examples of javax.management.loading.MLet

      Class cls = Simple.class;
      URL url = cls.getProtectionDomain().getCodeSource().getLocation();
      String className = cls.getName();

      MLet loader = new MLet(new URL[]{url}, ClassLoader.getSystemClassLoader().getParent());
      server.registerMBean(loader, loaderName);

      MLet mlet = new MLet(new URL[0], ClassLoader.getSystemClassLoader().getParent(), delegates);

      // Be sure the MLet cannot load the class
      try
      {
         mlet.loadClass(className);
         fail("MLet should not be able to load the class");
      }
      catch (ClassNotFoundException ignored)
      {
      }
View Full Code Here

Examples of javax.management.loading.MLet

      Class cls = Simple.class;
      URL url = cls.getProtectionDomain().getCodeSource().getLocation();
      String className = cls.getName();

      MLet mlet = new MLet(new URL[]{url}, ClassLoader.getSystemClassLoader().getParent());
      server.registerMBean(mlet, loaderName);

      server.createMBean(className, mbeanName, loaderName);
   }
View Full Code Here

Examples of javax.management.loading.MLet

      // Register some MLet
      for (int i = 0; i < loaderCount; ++i)
      {
         loaders[i] = new ObjectName("Loader", "id", String.valueOf(i));
         MLet mlet = new MLet(new URL[]{url}, ClassLoader.getSystemClassLoader().getParent());
         server.registerMBean(mlet, loaders[i]);
      }

      long start = System.currentTimeMillis();
View Full Code Here

Examples of javax.management.loading.MLet

      // Sleep to make sure the remote notifications threads started before we emit the notification
      sleep(1000);

      // Add an MBean to the remote MBeanServer: this will trigger a notification from the remote delegate,
      // that should be dispatched transparently the the listener above
      MLet remoteMLet = new MLet();
      ObjectName remoteMLetName = ObjectName.getInstance(":type=mlet");
      remoteServer.registerMBean(remoteMLet, remoteMLetName);

      synchronized (holder)
      {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.