Search in sources :

Example 1 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer 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();
    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$");
    //set up jmx remote
    MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    JMXServiceURL serviceUrl = new JMXServiceURL("rmi", "localhost", 1099, "/jndi/rmi://localhost:1099/jmxrmi");
    ConnectorServer jmxConnServer = new ConnectorServer(serviceUrl, "org.eclipse.jetty.jmx:name=rmiconnectorserver");
    //start server
    //remember chosen port
    __port = ((NetworkConnector) __server.getConnectors()[0]).getLocalPort();
Also used : JMXServiceURL( WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Server(org.eclipse.jetty.server.Server) ConnectorServer(org.eclipse.jetty.jmx.ConnectorServer) Configuration(org.eclipse.jetty.webapp.Configuration) MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) ConnectorServer(org.eclipse.jetty.jmx.ConnectorServer) File(

Example 2 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer in project jetty.project by eclipse.

the class AttrEventTriggerTest method setUp.

public void setUp() throws Exception {
    File docRoot = new File("target/test-output/docroot/");
    System.setProperty("org.eclipse.jetty.util.log.DEBUG", "");
    _server = new Server();
    ServerConnector connector = new ServerConnector(_server);
    _server.setConnectors(new Connector[] { connector });
    _handler = new TestHandler();
    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    _mBeanContainer = new MBeanContainer(mBeanServer);
    _server.addBean(_mBeanContainer, true);
    _counter = _handler.getRequestCounter();
    _monitor = new JMXMonitor();
    int port = connector.getLocalPort();
    _requestUrl = "http://localhost:" + port + "/";
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) MBeanServer( Server(org.eclipse.jetty.server.Server) MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) File( MBeanServer( Before(org.junit.Before)

Example 3 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer 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);
    ConnectorServer jmx = new ConnectorServer(new JMXServiceURL("rmi", null, 1999, "/jndi/rmi://localhost:1999/jmxrmi"), "org.eclipse.jetty.jmx:name=rmiconnectorserver");
Also used : JMXServiceURL( ConnectorServer(org.eclipse.jetty.jmx.ConnectorServer) Server(org.eclipse.jetty.server.Server) MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) ConnectorServer(org.eclipse.jetty.jmx.ConnectorServer)

Example 4 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer in project jetty.project by eclipse.

the class OneWebAppWithJsp method main.

public static void main(String[] args) throws Exception {
    // Create a basic jetty server object that will listen on port 8080.
    // Note that if you set this to port 0 then
    // a randomly available port will be assigned that you can either look
    // in the logs for the port,
    // or programmatically obtain it for use in test cases.
    Server server = new Server(8080);
    // Setup JMX
    MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    // The WebAppContext is the entity that controls the environment in
    // which a web application lives and
    // breathes. In this example the context path is being set to "/" so it
    // is suitable for serving root context
    // requests and then we see it setting the location of the war. A whole
    // host of other configurations are
    // available, ranging from configuring to support annotation scanning in
    // the webapp (through
    // PlusConfiguration) to choosing where the webapp will unpack itself.
    WebAppContext webapp = new WebAppContext();
    File warFile = new File("../../jetty-distribution/target/distribution/demo-base/webapps/test.war");
    if (!warFile.exists()) {
        throw new RuntimeException("Unable to find WAR File: " + warFile.getAbsolutePath());
    // This webapp will use jsps and jstl. We need to enable the
    // AnnotationConfiguration in order to correctly
    // set up the jsp container
    Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(server);
    classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
    // Set the ContainerIncludeJarPattern so that jetty examines these
    // container-path jars for tlds, web-fragments etc.
    // If you omit the jar that contains the jstl .tlds, the jsp engine will
    // scan for them instead.
    webapp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
    // A WebAppContext is a ContextHandler as well so it needs to be set to
    // the server so it is aware of where to
    // send the appropriate requests.
    // Configure a LoginService.
    // Since this example is for our test webapp, we need to setup a
    // LoginService so this shows how to create a very simple hashmap based
    // one. The name of the LoginService needs to correspond to what is
    // configured in the webapp's web.xml and since it has a lifecycle of
    // its own we register it as a bean with the Jetty server object so it
    // can be started and stopped according to the lifecycle of the server
    // itself.
    HashLoginService loginService = new HashLoginService();
    loginService.setName("Test Realm");
    // Start things up! 
    // The use of server.join() the will make the current thread join and
    // wait until the server is done executing.
    // See
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HashLoginService( Server(org.eclipse.jetty.server.Server) Configuration(org.eclipse.jetty.webapp.Configuration) MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer) File(

Example 5 with MBeanContainer

use of org.eclipse.jetty.jmx.MBeanContainer in project camel by apache.

the class WebsocketComponent method enableJmx.

private void enableJmx(Server server) {
    MBeanContainer containerToRegister = getMbContainer();
    if (containerToRegister != null) {"Jetty JMX Extensions is enabled");
    // Since we may have many Servers running, don't tie the MBeanContainer
    // to a Server lifecycle or we end up closing it while it is still in use.
Also used : MBeanContainer(org.eclipse.jetty.jmx.MBeanContainer)


MBeanContainer (org.eclipse.jetty.jmx.MBeanContainer)34 Server (org.eclipse.jetty.server.Server)21 ServerConnector (org.eclipse.jetty.server.ServerConnector)11 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)11 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)10 File ( MBeanServer ( HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)9 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)9 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)8 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)8 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)7 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)6 ConnectorServer (org.eclipse.jetty.jmx.ConnectorServer)5 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)5 JMXServiceURL ( DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)4 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)4 Connector (org.eclipse.jetty.server.Connector)3 HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)3