Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

[NEXUS-4782] Add jetty-jmx jar + example configuration #216

Merged
merged 4 commits into from Jan 23, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions nexus/nexus-oss-webapp/pom.xml
Expand Up @@ -130,6 +130,11 @@
<artifactId>jetty-rewrite</artifactId> <artifactId>jetty-rewrite</artifactId>
<version>${jetty.version}</version> <version>${jetty.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${jetty.version}</version>
</dependency>
<!-- <!--
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
Expand Down
@@ -0,0 +1,152 @@
<?xml version="1.0"?>
<!--

Copyright (c) 2008-2011 Sonatype, Inc.
All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions

This program is free software: you can redistribute it and/or modify it only under the terms of the GNU Affero General
Public License Version 3 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License Version 3
for more details.

You should have received a copy of the GNU Affero General Public License Version 3 along with this program. If not, see
http://www.gnu.org/licenses.

Sonatype Nexus (TM) Open Source Version is available from Sonatype, Inc. Sonatype and Sonatype Nexus are trademarks of
Sonatype, Inc. Apache Maven is a trademark of the Apache Foundation. M2Eclipse is a trademark of the Eclipse Foundation.
All other trademarks are the property of their respective owners.

-->
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<!-- ============================================================ -->
<!-- -->
<!-- NOTE: Copy this file to ../jetty.xml to use it. -->
<!-- -->
<!-- For help using this configuration, see: -->
<!-- -->
<!-- https://docs.sonatype.com/display/NX/Jetty+Configuration -->
<!-- -->
<!-- ============================================================ -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host">${application-host}</Set>
<Set name="port">${application-port}</Set>
</New>
</Arg>
</Call>

<Set name="handler">
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
<!-- The following configuration is REQUIRED, and MUST BE FIRST.
It makes the Plexus container available for use in the Nexus webapp. -->
<Call name="addLifeCycleListener">
<Arg>
<New class="org.sonatype.plexus.jetty.custom.InjectExistingPlexusListener"/>
</Arg>
</Call>

<!-- The following configuration disables JSP taglib support, the validation of which
slows down Jetty's startup significantly. -->
<Call name="addLifeCycleListener">
<Arg>
<New class="org.sonatype.plexus.jetty.custom.DisableTagLibsListener"/>
</Arg>
</Call>
</New>
</Set>

<New id="NexusWebAppContext" class="org.eclipse.jetty.webapp.WebAppContext">
<Arg>
<Ref id="Contexts"/>
</Arg>
<Arg>${nexus-webapp}</Arg>
<Arg>${nexus-webapp-context-path}</Arg>
<Set name="extractWAR">false</Set>
</New>

<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>

<!-- ================= -->
<!-- JMX Configuration -->
<!-- ================= -->

<Call id="MBeanServer" class="java.lang.management.ManagementFactory" name="getPlatformMBeanServer"/>

<New id="MBeanContainer" class="org.eclipse.jetty.jmx.MBeanContainer">
<Arg>
<Ref id="MBeanServer"/>
</Arg>
</New>

<Get id="Container" name="container">
<Call name="addEventListener">
<Arg>
<Ref id="MBeanContainer"/>
</Arg>
</Call>
</Get>

<Call name="addBean">
<Arg>
<Ref id="MBeanContainer"/>
</Arg>
</Call>

<Get id="Logger" class="org.eclipse.jetty.util.log.Log" name="log"/>
<Ref id="MBeanContainer">
<Call name="addBean">
<Arg>
<Ref id="Logger"/>
</Arg>
</Call>
</Ref>

<!-- In order to connect to the JMX server remotely from a different
process, possibly running on a different host, Jetty JMX module
can create a remote JMX connector. It requires RMI registry to
be started prior to creating the connector server because the
JMX specification uses RMI to facilitate connections.
-->

<!-- Optionally start the RMI registry. Normally RMI registry runs on
port 1099. The argument below can be changed in order to comply
with the firewall requirements.
-->
<Call name="createRegistry" class="java.rmi.registry.LocateRegistry">
<Arg type="java.lang.Integer">1099</Arg>
<Call name="sleep" class="java.lang.Thread">
<Arg type="java.lang.Integer">1000</Arg>
</Call>
</Call>

<!-- Optionally add a remote JMX connector. The parameters of the constructor
below specify the JMX service URL, and the object name string for the
connector server bean. The parameters of the JMXServiceURL constructor
specify the protocol that clients will use to connect to the remote JMX
connector (RMI), the hostname of the server (local hostname), port number
(automatically assigned), and the URL path. Note that URL path contains
the RMI registry hostname and port number, that may need to be modified
in order to comply with the firewall requirements.
-->
<New id="ConnectorServer" class="org.eclipse.jetty.jmx.ConnectorServer">
<Arg>
<New class="javax.management.remote.JMXServiceURL">
<Arg type="java.lang.String">rmi</Arg>
<Arg type="java.lang.String"/>
<Arg type="java.lang.Integer">0</Arg>
<Arg type="java.lang.String">/jndi/rmi://localhost:1099/jmxrmi</Arg>
</New>
</Arg>
<Arg>org.eclipse.jetty:name=rmiconnectorserver</Arg>
<Call name="start"/>
</New>

</Configure>