类javax.management.ServiceNotFoundException源码实例Demo

下面列出了怎么用javax.management.ServiceNotFoundException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spring-boot-shiro   文件: GlobalExceptionHand.java
/**
 * 500 - Internal Server Error
 */
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(ServiceNotFoundException.class)
public Response handleServiceException(ServiceNotFoundException e) {
    String msg = "服务内部异常:" + e.getMessage();
    log.error(msg, e);
    return new Response().failure(msg);
}
 
源代码2 项目: jdk1.8-source-analysis   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码4 项目: TencentKona-8   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码5 项目: openjdk-8-source   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码6 项目: jdk8u60   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码7 项目: JDKSourceCode1.8   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码8 项目: openjdk-jdk8u   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.FINEST)) {
            MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
                    "addUrl", "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码10 项目: openjdk-jdk9   文件: MLet.java
/**
 * Appends the specified URL to the list of URLs to search for classes and
 * resources.
 * @exception ServiceNotFoundException The specified URL is malformed.
 */
public void addURL(String url) throws ServiceNotFoundException {
    try {
        URL ur = new URL(url);
        if (!Arrays.asList(getURLs()).contains(ur))
            super.addURL(ur);
    } catch (MalformedURLException e) {
        if (MLET_LOGGER.isLoggable(Level.DEBUG)) {
            MLET_LOGGER.log(Level.DEBUG, "Malformed URL: " + url, e);
        }
        throw new
            ServiceNotFoundException("The specified URL is malformed");
    }
}
 
源代码11 项目: dragonwell8_jdk   文件: ParserInfiniteLoopTest.java
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);
    }
 
源代码12 项目: dragonwell8_jdk   文件: GetMBeansFromURLTest.java
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);
    }
 
源代码13 项目: jdk8u_jdk   文件: GetMBeansFromURLTest.java
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);
    }
 
源代码14 项目: TencentKona-8   文件: ParserInfiniteLoopTest.java
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);
    }
 
源代码15 项目: hottub   文件: GetMBeansFromURLTest.java
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);
    }
 
源代码16 项目: openjdk-8   文件: GetMBeansFromURLTest.java
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);
    }
 
源代码17 项目: jdk8u60   文件: ParserInfiniteLoopTest.java
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);
    }
 
源代码18 项目: jdk8u-jdk   文件: GetMBeansFromURLTest.java
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);
    }
 
源代码19 项目: openjdk-8-source   文件: GetMBeansFromURLTest.java
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);
    }
 
源代码20 项目: openjdk-jdk8u   文件: ParserInfiniteLoopTest.java
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);
    }
 
源代码21 项目: openjdk-jdk8u   文件: GetMBeansFromURLTest.java
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);
    }
 
源代码22 项目: jdk8u_jdk   文件: ParserInfiniteLoopTest.java
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);
    }
 
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);
    }
 
源代码24 项目: openjdk-jdk9   文件: GetMBeansFromURLTest.java
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);
    }
 
/**
 * <p>Captures the current state of this MBean instance and writes
 * it out to the persistent store.  The state stored could include
 * attribute and operation values.</p>
 *
 * <p>If the implementation of this class does not support
 * persistence, an {@link MBeanException} wrapping a {@link
 * ServiceNotFoundException} is thrown.</p>
 *
 * <p>Persistence policy from the MBean and attribute descriptor
 * is used to guide execution of this method. The MBean should be
 * stored if 'persistPolicy' field is:</p>
 *
 * <PRE>{@literal  != "never"
 *   = "always"
 *   = "onTimer" and now > 'lastPersistTime' + 'persistPeriod'
 *   = "NoMoreOftenThan" and now > 'lastPersistTime' + 'persistPeriod'
 *   = "onUnregister"
 * }</PRE>
 *
 * <p>Do not store the MBean if 'persistPolicy' field is:</p>
 * <PRE>{@literal
 *    = "never"
 *    = "onUpdate"
 *    = "onTimer" && now < 'lastPersistTime' + 'persistPeriod'
 * }</PRE>
 *
 * @exception MBeanException Wraps another exception, or
 * persistence is not supported
 * @exception RuntimeOperationsException Wraps exceptions from the
 * persistence mechanism
 * @exception InstanceNotFoundException Could not find/access the
 * persistent store
 */
public void store()
    throws MBeanException, RuntimeOperationsException,
           InstanceNotFoundException {
    final ServiceNotFoundException x = new ServiceNotFoundException(
                            "Persistence not supported for this MBean");
    throw new MBeanException(x, x.getMessage());
}
 
源代码26 项目: jdk1.8-source-analysis   文件: MLet.java
/**
 * Loads a text file containing MLET tags that define the MBeans to
 * be added to the MBean server. The location of the text file is specified by
 * a URL. The MBeans specified in the MLET file will be instantiated and
 * registered in the MBean server.
 *
 * @param url The URL of the text file to be loaded as URL object.
 *
 * @return  A set containing one entry per MLET tag in the m-let text file loaded.
 * Each entry specifies either the ObjectInstance for the created MBean, or a throwable object
 * (that is, an error or an exception) if the MBean could not be created.
 *
 * @exception ServiceNotFoundException One of the following errors has occurred: The m-let text file does
 * not contain an MLET tag, the m-let text file is not found, a mandatory
 * attribute of the MLET tag is not specified, the value of url is
 * null.
 * @exception IllegalStateException MLet MBean is not registered with an MBeanServer.
 */
public Set<Object> getMBeansFromURL(URL url)
        throws ServiceNotFoundException  {
    if (url == null) {
        throw new ServiceNotFoundException("The specified URL is null");
    }
    return getMBeansFromURL(url.toString());
}
 
源代码27 项目: dragonwell8_jdk   文件: RequiredModelMBean.java
/**
 * <p>Instantiates this MBean instance with the data found for
 * the MBean in the persistent store.  The data loaded could include
 * attribute and operation values.</p>
 *
 * <p>This method should be called during construction or
 * initialization of this instance, and before the MBean is
 * registered with the MBeanServer.</p>
 *
 * <p>If the implementation of this class does not support
 * persistence, an {@link MBeanException} wrapping a {@link
 * ServiceNotFoundException} is thrown.</p>
 *
 * @exception MBeanException Wraps another exception, or
 * persistence is not supported
 * @exception RuntimeOperationsException Wraps exceptions from the
 * persistence mechanism
 * @exception InstanceNotFoundException Could not find or load
 * this MBean from persistent storage
 */
public void load()
    throws MBeanException, RuntimeOperationsException,
           InstanceNotFoundException {
    final ServiceNotFoundException x = new ServiceNotFoundException(
                            "Persistence not supported for this MBean");
    throw new MBeanException(x, x.getMessage());
}
 
源代码28 项目: dragonwell8_jdk   文件: RequiredModelMBean.java
/**
 * <p>Captures the current state of this MBean instance and writes
 * it out to the persistent store.  The state stored could include
 * attribute and operation values.</p>
 *
 * <p>If the implementation of this class does not support
 * persistence, an {@link MBeanException} wrapping a {@link
 * ServiceNotFoundException} is thrown.</p>
 *
 * <p>Persistence policy from the MBean and attribute descriptor
 * is used to guide execution of this method. The MBean should be
 * stored if 'persistPolicy' field is:</p>
 *
 * <PRE>{@literal  != "never"
 *   = "always"
 *   = "onTimer" and now > 'lastPersistTime' + 'persistPeriod'
 *   = "NoMoreOftenThan" and now > 'lastPersistTime' + 'persistPeriod'
 *   = "onUnregister"
 * }</PRE>
 *
 * <p>Do not store the MBean if 'persistPolicy' field is:</p>
 * <PRE>{@literal
 *    = "never"
 *    = "onUpdate"
 *    = "onTimer" && now < 'lastPersistTime' + 'persistPeriod'
 * }</PRE>
 *
 * @exception MBeanException Wraps another exception, or
 * persistence is not supported
 * @exception RuntimeOperationsException Wraps exceptions from the
 * persistence mechanism
 * @exception InstanceNotFoundException Could not find/access the
 * persistent store
 */
public void store()
    throws MBeanException, RuntimeOperationsException,
           InstanceNotFoundException {
    final ServiceNotFoundException x = new ServiceNotFoundException(
                            "Persistence not supported for this MBean");
    throw new MBeanException(x, x.getMessage());
}
 
源代码29 项目: dragonwell8_jdk   文件: MLet.java
/**
 * Loads a text file containing MLET tags that define the MBeans to
 * be added to the MBean server. The location of the text file is specified by
 * a URL. The MBeans specified in the MLET file will be instantiated and
 * registered in the MBean server.
 *
 * @param url The URL of the text file to be loaded as URL object.
 *
 * @return  A set containing one entry per MLET tag in the m-let text file loaded.
 * Each entry specifies either the ObjectInstance for the created MBean, or a throwable object
 * (that is, an error or an exception) if the MBean could not be created.
 *
 * @exception ServiceNotFoundException One of the following errors has occurred: The m-let text file does
 * not contain an MLET tag, the m-let text file is not found, a mandatory
 * attribute of the MLET tag is not specified, the value of url is
 * null.
 * @exception IllegalStateException MLet MBean is not registered with an MBeanServer.
 */
public Set<Object> getMBeansFromURL(URL url)
        throws ServiceNotFoundException  {
    if (url == null) {
        throw new ServiceNotFoundException("The specified URL is null");
    }
    return getMBeansFromURL(url.toString());
}
 
源代码30 项目: openjdk-8   文件: RequiredModelMBean.java
/**
 * <p>Captures the current state of this MBean instance and writes
 * it out to the persistent store.  The state stored could include
 * attribute and operation values.</p>
 *
 * <p>If the implementation of this class does not support
 * persistence, an {@link MBeanException} wrapping a {@link
 * ServiceNotFoundException} is thrown.</p>
 *
 * <p>Persistence policy from the MBean and attribute descriptor
 * is used to guide execution of this method. The MBean should be
 * stored if 'persistPolicy' field is:</p>
 *
 * <PRE>{@literal  != "never"
 *   = "always"
 *   = "onTimer" and now > 'lastPersistTime' + 'persistPeriod'
 *   = "NoMoreOftenThan" and now > 'lastPersistTime' + 'persistPeriod'
 *   = "onUnregister"
 * }</PRE>
 *
 * <p>Do not store the MBean if 'persistPolicy' field is:</p>
 * <PRE>{@literal
 *    = "never"
 *    = "onUpdate"
 *    = "onTimer" && now < 'lastPersistTime' + 'persistPeriod'
 * }</PRE>
 *
 * @exception MBeanException Wraps another exception, or
 * persistence is not supported
 * @exception RuntimeOperationsException Wraps exceptions from the
 * persistence mechanism
 * @exception InstanceNotFoundException Could not find/access the
 * persistent store
 */
public void store()
    throws MBeanException, RuntimeOperationsException,
           InstanceNotFoundException {
    final ServiceNotFoundException x = new ServiceNotFoundException(
                            "Persistence not supported for this MBean");
    throw new MBeanException(x, x.getMessage());
}
 
 类所在包
 同包方法