You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/09/27 16:35:14 UTC
[tomcat] 01/13: Back-port JmxEnabled interface
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 9a69dcb9af9266add155f77d4bb993850b4b7fb9
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 27 13:54:02 2019 +0100
Back-port JmxEnabled interface
---
java/org/apache/catalina/JmxEnabled.java | 52 ++++++++++++++++++++++
.../apache/catalina/util/LifecycleMBeanBase.java | 14 +++---
2 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/catalina/JmxEnabled.java b/java/org/apache/catalina/JmxEnabled.java
new file mode 100644
index 0000000..2d514f4
--- /dev/null
+++ b/java/org/apache/catalina/JmxEnabled.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina;
+
+import javax.management.MBeanRegistration;
+import javax.management.ObjectName;
+
+/**
+ * This interface is implemented by components that will be registered with an
+ * MBean server when they are created and unregistered when they are destroyed.
+ * It is primarily intended to be implemented by components that implement
+ * {@link Lifecycle} but is not exclusively for them.
+ */
+public interface JmxEnabled extends MBeanRegistration {
+
+ /**
+ * @return the domain under which this component will be / has been
+ * registered.
+ */
+ String getDomain();
+
+
+ /**
+ * Specify the domain under which this component should be registered. Used
+ * with components that cannot (easily) navigate the component hierarchy to
+ * determine the correct domain to use.
+ *
+ * @param domain The name of the domain under which this component should be
+ * registered
+ */
+ void setDomain(String domain);
+
+
+ /**
+ * @return the name under which this component has been registered with JMX.
+ */
+ ObjectName getObjectName();
+}
diff --git a/java/org/apache/catalina/util/LifecycleMBeanBase.java b/java/org/apache/catalina/util/LifecycleMBeanBase.java
index 304e0c5..6501364 100644
--- a/java/org/apache/catalina/util/LifecycleMBeanBase.java
+++ b/java/org/apache/catalina/util/LifecycleMBeanBase.java
@@ -25,6 +25,7 @@ import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.apache.catalina.Globals;
+import org.apache.catalina.JmxEnabled;
import org.apache.catalina.LifecycleException;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
@@ -32,11 +33,11 @@ import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.res.StringManager;
public abstract class LifecycleMBeanBase extends LifecycleBase
- implements MBeanRegistration {
+ implements JmxEnabled {
- private static Log log = LogFactory.getLog(LifecycleMBeanBase.class);
+ private static final Log log = LogFactory.getLog(LifecycleMBeanBase.class);
- private static StringManager sm =
+ private static final StringManager sm =
StringManager.getManager("org.apache.catalina.util");
@@ -78,6 +79,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase
* with components that cannot (easily) navigate the component hierarchy to
* determine the correct domain to use.
*/
+ @Override
public final void setDomain(String domain) {
this.domain = domain;
}
@@ -87,6 +89,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase
* Obtain the domain under which this component will be / has been
* registered.
*/
+ @Override
public final String getDomain() {
if (domain == null) {
domain = getDomainInternal();
@@ -112,6 +115,7 @@ public abstract class LifecycleMBeanBase extends LifecycleBase
/**
* Obtain the name under which this component has been registered with JMX.
*/
+ @Override
public final ObjectName getObjectName() {
return oname;
}
@@ -168,8 +172,8 @@ public abstract class LifecycleMBeanBase extends LifecycleBase
/**
* Utility method to enable sub-classes to easily unregister additional
- * components that don't implement {@link MBeanRegistration} with
- * an MBean server.<br>
+ * components that don't implement {@link JmxEnabled} with an MBean server.
+ * <br>
* Note: This method should only be used once {@link #initInternal()} has
* been called and before {@link #destroyInternal()} has been called.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org