use of javax.management.remote.JMXServiceURL in project jetty.project by eclipse.
the class JmxIT method connectToMBeanServer.
@BeforeClass
public static void connectToMBeanServer() throws Exception {
startJetty();
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost:1099/jndi/rmi://localhost:1099/jmxrmi");
__jmxc = JMXConnectorFactory.connect(url, null);
__mbsc = __jmxc.getMBeanServerConnection();
}
use of javax.management.remote.JMXServiceURL in project jetty.project by eclipse.
the class JmxIT method startJetty.
public static void startJetty() throws Exception {
File target = MavenTestingUtils.getTargetDir();
File jettyBase = new File(target, "test-base");
File webapps = new File(jettyBase, "webapps");
File war = new File(webapps, "jmx-webapp.war");
//create server instance
__server = new Server(0);
//set up the webapp
WebAppContext context = new WebAppContext();
context.setWar(war.getCanonicalPath());
context.setContextPath("/jmx-webapp");
Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(__server);
classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/javax.servlet-[^/]*\\.jar$|.*/servlet-api-[^/]*\\.jar$");
__server.setHandler(context);
//set up jmx remote
MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
__server.addBean(mbContainer);
JMXServiceURL serviceUrl = new JMXServiceURL("rmi", "localhost", 1099, "/jndi/rmi://localhost:1099/jmxrmi");
ConnectorServer jmxConnServer = new ConnectorServer(serviceUrl, "org.eclipse.jetty.jmx:name=rmiconnectorserver");
__server.addBean(jmxConnServer);
//start server
__server.start();
//remember chosen port
__port = ((NetworkConnector) __server.getConnectors()[0]).getLocalPort();
}
use of javax.management.remote.JMXServiceURL in project jetty.project by eclipse.
the class ConnectorServerTest method testIsLoopbackAddressWithWrongValue.
@Test
@Ignore
public void testIsLoopbackAddressWithWrongValue() throws Exception {
// given
JMXServiceURL serviceURLWithOutPort = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + InetAddress.getLocalHost() + ":1199/jmxrmi");
// when
connectorServer = new ConnectorServer(serviceURLWithOutPort, " domain: key5 = value5");
// then
assertNull("As loopback address returns false...registry must be null", connectorServer._registry);
}
use of javax.management.remote.JMXServiceURL in project jetty.project by eclipse.
the class ConnectorServerTest method testConnServerWithRmiDefaultPort.
@Test
// collides on ci server
@Ignore
public void testConnServerWithRmiDefaultPort() throws Exception {
// given
LocateRegistry.createRegistry(1099);
JMXServiceURL serviceURLWithOutPort = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
connectorServer = new ConnectorServer(serviceURLWithOutPort, " domain: key3 = value3");
// when
connectorServer.start();
// then
assertThat("Server status must be in started or starting", connectorServer.getState(), anyOf(is(ConnectorServer.STARTED), is(ConnectorServer.STARTING)));
}
use of javax.management.remote.JMXServiceURL in project jetty.project by eclipse.
the class ServerWithJMX method main.
public static void main(String[] args) throws Exception {
// === jetty-jmx.xml ===
MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
Server server = new Server(8080);
server.addBean(mbContainer);
ConnectorServer jmx = new ConnectorServer(new JMXServiceURL("rmi", null, 1999, "/jndi/rmi://localhost:1999/jmxrmi"), "org.eclipse.jetty.jmx:name=rmiconnectorserver");
server.addBean(jmx);
server.start();
server.dumpStdErr();
server.join();
}
Aggregations