Search in sources :

Example 1 with JMXProviderException

use of javax.management.remote.JMXProviderException in project jdk8u_jdk by JetBrains.

the class JMXConnectorServerProviderImpl method newJMXConnectorServer.

public JMXConnectorServer newJMXConnectorServer(JMXServiceURL url, Map<String, ?> map, MBeanServer mbeanServer) throws IOException {
    final String protocol = url.getProtocol();
    called = true;
    System.out.println("JMXConnectorServerProviderImpl called");
    if (protocol.equals("rmi"))
        return new RMIConnectorServer(url, map, mbeanServer);
    if (protocol.equals("throw-provider-exception"))
        throw new JMXProviderException("I have been asked to throw");
    throw new IllegalArgumentException("UNKNOWN PROTOCOL");
}
Also used : JMXProviderException(javax.management.remote.JMXProviderException) RMIConnectorServer(javax.management.remote.rmi.RMIConnectorServer)

Example 2 with JMXProviderException

use of javax.management.remote.JMXProviderException in project jdk8u_jdk by JetBrains.

the class ProviderTest method main.

public static void main(String[] args) throws Exception {
    System.out.println("Starting ProviderTest");
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    // First do the test with a protocol handled by Service providers
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    dotest(url, mbs);
    boolean clientCalled = provider.JMXConnectorProviderImpl.called();
    boolean serverCalled = provider.JMXConnectorServerProviderImpl.called();
    boolean ok = clientCalled && serverCalled;
    if (!ok) {
        if (!clientCalled)
            System.out.println("Client provider not called");
        if (!serverCalled)
            System.out.println("Server provider not called");
        throw new RuntimeException("Test failed - see log for details");
    }
    // The Service Provider doesn't handle IIOP. Default providers MUST
    // be called, which may or may not support IIOP.
    url = new JMXServiceURL("service:jmx:iiop://");
    try {
        dotest(url, mbs);
    } catch (MalformedURLException e) {
        try {
            Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
            e.printStackTrace(System.out);
            throw new RuntimeException("MalformedURLException throw but IIOP appears to be supported");
        } catch (ClassNotFoundException expected) {
        }
        System.out.println("MalformedURLException thrown, IIOP transport not supported");
    }
    // Unsupported protocol.
    JMXConnectorServer server = null;
    JMXConnector client = null;
    url = new JMXServiceURL("service:jmx:unknown-protocol://");
    try {
        server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
        throw new RuntimeException("Exception not thrown.");
    } catch (MalformedURLException e) {
        System.out.println("Expected MalformedURLException thrown.");
    }
    try {
        client = JMXConnectorFactory.newJMXConnector(url, null);
        throw new RuntimeException("Exception not thrown.");
    } catch (MalformedURLException e) {
        System.out.println("Expected MalformedURLException thrown.");
    }
    //JMXConnectorProviderException
    url = new JMXServiceURL("service:jmx:throw-provider-exception://");
    try {
        server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
        throw new RuntimeException("Exception not thrown.");
    } catch (JMXProviderException e) {
        System.out.println("Expected JMXProviderException thrown.");
    }
    try {
        client = JMXConnectorFactory.newJMXConnector(url, null);
        throw new RuntimeException("Exception not thrown.");
    } catch (JMXProviderException e) {
        System.out.println("Expected JMXProviderException thrown.");
    }
    System.out.println("Test OK");
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) JMXProviderException(javax.management.remote.JMXProviderException) MalformedURLException(java.net.MalformedURLException) JMXConnector(javax.management.remote.JMXConnector) MBeanServer(javax.management.MBeanServer) JMXConnectorServer(javax.management.remote.JMXConnectorServer)

Example 3 with JMXProviderException

use of javax.management.remote.JMXProviderException in project jdk8u_jdk by JetBrains.

the class JMXConnectorProviderImpl method newJMXConnector.

public JMXConnector newJMXConnector(JMXServiceURL url, Map<String, ?> map) throws IOException {
    final String protocol = url.getProtocol();
    called = true;
    System.out.println("JMXConnectorProviderImpl called");
    if (protocol.equals("rmi"))
        return new RMIConnector(url, map);
    if (protocol.equals("throw-provider-exception"))
        throw new JMXProviderException("I have been asked to throw");
    throw new IllegalArgumentException("UNKNOWN PROTOCOL");
}
Also used : RMIConnector(javax.management.remote.rmi.RMIConnector) JMXProviderException(javax.management.remote.JMXProviderException)

Aggregations

JMXProviderException (javax.management.remote.JMXProviderException)3 MalformedURLException (java.net.MalformedURLException)1 MBeanServer (javax.management.MBeanServer)1 JMXConnector (javax.management.remote.JMXConnector)1 JMXConnectorServer (javax.management.remote.JMXConnectorServer)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1 RMIConnector (javax.management.remote.rmi.RMIConnector)1 RMIConnectorServer (javax.management.remote.rmi.RMIConnectorServer)1