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");
}
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");
}
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");
}
Aggregations