当前位置: 首页>>代码示例>>Java>>正文


Java MLet.getMBeansFromURL方法代码示例

本文整理汇总了Java中javax.management.loading.MLet.getMBeansFromURL方法的典型用法代码示例。如果您正苦于以下问题:Java MLet.getMBeansFromURL方法的具体用法?Java MLet.getMBeansFromURL怎么用?Java MLet.getMBeansFromURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.loading.MLet的用法示例。


在下文中一共展示了MLet.getMBeansFromURL方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNativeLib

import javax.management.loading.MLet; //导入方法依赖的package包/类
/**
 * Test for the method getLibraryDirectory()
 * 
 * @see javax.management.loading.mlet#getLibraryDirectory()
 */
public Result testNativeLib() throws Exception {
    try{
    MBeanServer server = MBeanServerFactory.createMBeanServer();
    MLet mlet = new MLet();
    ObjectName name = new ObjectName("test:name=mlet");
    server.registerMBean(mlet, name);
    mlet.getMBeansFromURL(MLET_URL+"mlet2.conf");
    String libPath = mlet.getLibraryDirectory();
    //System.out.println(libPath);
    if(libPath.equals(null))
        return failed("method MLet.getLibraryDirectory()return wrong value = " + libPath);
}catch(Exception e){
    //e.printStackTrace();
    return failed("Unexpected Exception occur");
}
    return result();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:23,代码来源:LoadingMBeanTest.java

示例2: testSetLibraryDirectory

import javax.management.loading.MLet; //导入方法依赖的package包/类
/**
 * Test for the method
 *  getLibraryDirectory()
 *  setLibraryDirectory()
 * 
 * @see javax.management.loading.mlet#setLibraryDirectory()
 */

public Result testSetLibraryDirectory() throws Exception {
    try{
    MBeanServer server = MBeanServerFactory.createMBeanServer();
    MLet mlet = new MLet();
    ObjectName name = new ObjectName("test:name=mlet");
    server.registerMBean(mlet, name);
    mlet.getMBeansFromURL(MLET_URL+"mlet2.conf");
    String libPath = mlet.getLibraryDirectory();
    mlet.setLibraryDirectory(libPath);
    if(libPath.equals(null))
        return failed("method MLet.getLibraryDirectory()return wrong value = " + libPath);
    }catch(Exception e){
        //e.printStackTrace();
        return failed("Unexpected Exception occur");
    }
    return result();
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:26,代码来源:LoadingMBeanTest.java

示例3: main

import javax.management.loading.MLet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        boolean error = false;

        // Instantiate the MBean server
        //
        System.out.println("Create the MBean server");
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();

        // Instantiate an MLet
        //
        System.out.println("Create the MLet");
        MLet mlet = new MLet();

        // Register the MLet MBean with the MBeanServer
        //
        System.out.println("Register the MLet MBean");
        ObjectName mletObjectName = new ObjectName("Test:type=MLet");
        mbs.registerMBean(mlet, mletObjectName);

        // Call getMBeansFromURL
        //
        System.out.println("Call mlet.getMBeansFromURL(<url>)");
        String testSrc = System.getProperty("test.src");
        System.out.println("test.src = " + testSrc);
        String urlCodebase;
        if (testSrc.startsWith("/")) {
            urlCodebase =
                "file:" + testSrc.replace(File.separatorChar, '/') + "/";
        } else {
            urlCodebase =
                "file:/" + testSrc.replace(File.separatorChar, '/') + "/";
        }
        String mletFile = urlCodebase + args[0];
        System.out.println("MLet File = " + mletFile);
        try {
            mlet.getMBeansFromURL(mletFile);
            System.out.println(
                "TEST FAILED: Expected ServiceNotFoundException not thrown");
            error = true;
        } catch (ServiceNotFoundException e) {
            if (e.getCause() == null) {
                System.out.println("TEST FAILED: Got unexpected null cause " +
                    "in ServiceNotFoundException");
                error = true;
            } else if (!(e.getCause() instanceof IOException)) {
                System.out.println("TEST FAILED: Got unexpected non-null " +
                    "cause in ServiceNotFoundException");
                error = true;
            } else {
                System.out.println("TEST PASSED: Got expected non-null " +
                    "cause in ServiceNotFoundException");
                error = false;
            }
            e.printStackTrace(System.out);
        }

        // Unregister the MLet MBean
        //
        System.out.println("Unregister the MLet MBean");
        mbs.unregisterMBean(mletObjectName);

        // Release MBean server
        //
        System.out.println("Release the MBean server");
        MBeanServerFactory.releaseMBeanServer(mbs);

        // End Test
        //
        System.out.println("Bye! Bye!");
        if (error) System.exit(1);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:73,代码来源:ParserInfiniteLoopTest.java

示例4: main

import javax.management.loading.MLet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        boolean error = false;

        // Instantiate the MBean server
        //
        System.out.println("Create the MBean server");
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();

        // Instantiate an MLet
        //
        System.out.println("Create the MLet");
        MLet mlet = new MLet();

        // Register the MLet MBean with the MBeanServer
        //
        System.out.println("Register the MLet MBean");
        ObjectName mletObjectName = new ObjectName("Test:type=MLet");
        mbs.registerMBean(mlet, mletObjectName);

        // Call getMBeansFromURL
        //
        System.out.println("Call mlet.getMBeansFromURL(<url>)");
        try {
            mlet.getMBeansFromURL("bogus://whatever");
            System.out.println("TEST FAILED: Expected " +
                               ServiceNotFoundException.class +
                               " exception not thrown.");
            error = true;
        } catch (ServiceNotFoundException e) {
            if (e.getCause() == null) {
                System.out.println("TEST FAILED: Got null cause in " +
                                   ServiceNotFoundException.class +
                                   " exception.");
                error = true;
            } else {
                System.out.println("TEST PASSED: Got non-null cause in " +
                                   ServiceNotFoundException.class +
                                   " exception.");
                error = false;
            }
            e.printStackTrace(System.out);
        }

        // Unregister the MLet MBean
        //
        System.out.println("Unregister the MLet MBean");
        mbs.unregisterMBean(mletObjectName);

        // Release MBean server
        //
        System.out.println("Release the MBean server");
        MBeanServerFactory.releaseMBeanServer(mbs);

        // End Test
        //
        System.out.println("Bye! Bye!");
        if (error) System.exit(1);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:GetMBeansFromURLTest.java

示例5: main

import javax.management.loading.MLet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        boolean error = false;

        // Instantiate the MBean server
        //
        System.out.println("Create the MBean server");
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();

        // Get Default Locale
        Locale loc = Locale.getDefault();

        // Instantiate an MLet
        //
        System.out.println("Create the MLet");
        MLet mlet = new MLet();

        // Register the MLet MBean with the MBeanServer
        //
        System.out.println("Register the MLet MBean");
        ObjectName mletObjectName = new ObjectName("Test:type=MLet");
        mbs.registerMBean(mlet, mletObjectName);

        // Call getMBeansFromURL
        //
        System.out.println("Call mlet.getMBeansFromURL(<url>)");
        String testSrc = System.getProperty("test.src");
        System.out.println("test.src = " + testSrc);
        String urlCodebase;
        if (testSrc.startsWith("/")) {
            urlCodebase =
                "file:" + testSrc.replace(File.separatorChar, '/') + "/";
        } else {
            urlCodebase =
                "file:/" + testSrc.replace(File.separatorChar, '/') + "/";
        }
        String mletFile = urlCodebase + args[0];
        System.out.println("MLet File = " + mletFile);
        try {
            // Change default Locale to Turkish
            Locale.setDefault(new Locale("tr", "TR"));
            mlet.getMBeansFromURL(mletFile);
            System.out.println("Test Passes");
        } catch (Exception e) {
            error = true;
            e.printStackTrace(System.out);
        }finally {
            Locale.setDefault(loc);
        }

        // Unregister the MLet MBean
        //
        System.out.println("Unregister the MLet MBean");
        mbs.unregisterMBean(mletObjectName);

        // Release MBean server
        //
        System.out.println("Release the MBean server");
        MBeanServerFactory.releaseMBeanServer(mbs);

        // End Test
        //
        System.out.println("Bye! Bye!");
        if (error) System.exit(1);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:66,代码来源:MletParserLocaleTest.java

示例6: main

import javax.management.loading.MLet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
   // Create the MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Register the MLet in the MBeanServer
   MLet mlet = new MLet();
   ObjectName mletName = new ObjectName("system:mbean=loader");
   server.registerMBean(mlet, mletName);

   // Set the MLet as context classloader
   // Can be useful for the loaded services that want to access this classloader.
   Thread.currentThread().setContextClassLoader(mlet);

   // Resolve the file to load MBeans from
   // If we got a program argument, we load it from there, otherwise
   // we assume we have a 'mbeans.mlet' file in this example's directory
   URL mbeansURL = null;
   if (args.length == 1)
   {
      String file = args[0];
      mbeansURL = new File(file).toURL();
   }
   else
   {
      mbeansURL = mlet.getResource("examples/services/loading/mbeans.mlet");
   }

   // If the URL is still null, abort
   if (mbeansURL == null) throw new ServiceNotFoundException("Could not find MBeans to load");

   // Load the MBeans
   Set mbeans = mlet.getMBeansFromURL(mbeansURL);

   System.out.println("MLet has now the following classpath: " + Arrays.asList(mlet.getURLs()));

   // Now let's check everything is ok.
   checkMBeansLoadedSuccessfully(mbeans);

   // Now the system is loaded, but maybe we should initialize and start them
   initializeMBeans(server, mbeans);
   startMBeans(server, mbeans);

   // Now the system is up and running
   System.out.println("System up and running !");

   // The program exits because none of the loaded MBeans in this example started a non-daemon thread.
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:49,代码来源:Main.java


注:本文中的javax.management.loading.MLet.getMBeansFromURL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。