javax.management.ServiceNotFoundException Java Examples

The following examples show how to use javax.management.ServiceNotFoundException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MLet.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #2
Source File: MLet.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #3
Source File: MLet.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #4
Source File: MLet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #5
Source File: MLet.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #6
Source File: MLet.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #7
Source File: MLet.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #8
Source File: GlobalExceptionHand.java    From spring-boot-shiro with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source File: MLet.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #10
Source File: MLet.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * 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");
    }
}
 
Example #11
Source File: GetMBeansFromURLTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #12
Source File: GetMBeansFromURLTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #13
Source File: GetMBeansFromURLTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #14
Source File: GetMBeansFromURLTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #15
Source File: ParserInfiniteLoopTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #16
Source File: GetMBeansFromURLTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #17
Source File: GetMBeansFromURLTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #18
Source File: ParserInfiniteLoopTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #19
Source File: ParserInfiniteLoopTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #20
Source File: ParserInfiniteLoopTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #21
Source File: ParserInfiniteLoopTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #22
Source File: GetMBeansFromURLTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #23
Source File: GetMBeansFromURLTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #24
Source File: GetMBeansFromURLTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
 
Example #25
Source File: RequiredModelMBean.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <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());
}
 
Example #26
Source File: RequiredModelMBean.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <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());
}
 
Example #27
Source File: RequiredModelMBean.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <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());
}
 
Example #28
Source File: RequiredModelMBean.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * <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());
}
 
Example #29
Source File: MLet.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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());
}
 
Example #30
Source File: RequiredModelMBean.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <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());
}