You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2012/11/16 22:10:52 UTC
svn commit: r1410572 - in /axis/axis1/java/trunk: ./ axis-rt-compat/
axis-rt-core/src/main/java/org/apache/axis/management/
axis-rt-core/src/main/java/org/apache/axis/transport/http/
axis-rt-management/ axis-rt-management/src/ axis-rt-management/src/ma...
Author: veithen
Date: Fri Nov 16 21:10:50 2012
New Revision: 1410572
URL: http://svn.apache.org/viewvc?rev=1410572&view=rev
Log:
Moved the JMX support to a separate Maven module.
Added:
axis/axis1/java/trunk/axis-rt-management/ (with props)
axis/axis1/java/trunk/axis-rt-management/pom.xml (with props)
axis/axis1/java/trunk/axis-rt-management/src/
axis/axis1/java/trunk/axis-rt-management/src/main/
axis/axis1/java/trunk/axis-rt-management/src/main/java/
axis/axis1/java/trunk/axis-rt-management/src/main/java/org/
axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/
axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/
axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/
- copied from r1404511, axis/axis1/java/trunk/axis-rt-core/src/main/java/org/apache/axis/management/
axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/servlet/
axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/servlet/AxisServerMBeanExporter.java (with props)
Removed:
axis/axis1/java/trunk/axis-rt-core/src/main/java/org/apache/axis/management/
Modified:
axis/axis1/java/trunk/axis-rt-compat/pom.xml
axis/axis1/java/trunk/axis-rt-core/src/main/java/org/apache/axis/transport/http/AxisServlet.java
axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/Registrar.java
axis/axis1/java/trunk/axis-war/pom.xml
axis/axis1/java/trunk/axis-war/src/main/webapp/WEB-INF/web.xml
axis/axis1/java/trunk/pom.xml
axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt
Modified: axis/axis1/java/trunk/axis-rt-compat/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-rt-compat/pom.xml?rev=1410572&r1=1410571&r2=1410572&view=diff
==============================================================================
--- axis/axis1/java/trunk/axis-rt-compat/pom.xml (original)
+++ axis/axis1/java/trunk/axis-rt-compat/pom.xml Fri Nov 16 21:10:50 2012
@@ -37,6 +37,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axis-rt-management</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
<groupId>jetty</groupId>
<artifactId>jetty</artifactId>
<version>5.1.10</version>
Modified: axis/axis1/java/trunk/axis-rt-core/src/main/java/org/apache/axis/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-rt-core/src/main/java/org/apache/axis/transport/http/AxisServlet.java?rev=1410572&r1=1410571&r2=1410572&view=diff
==============================================================================
--- axis/axis1/java/trunk/axis-rt-core/src/main/java/org/apache/axis/transport/http/AxisServlet.java (original)
+++ axis/axis1/java/trunk/axis-rt-core/src/main/java/org/apache/axis/transport/http/AxisServlet.java Fri Nov 16 21:10:50 2012
@@ -44,7 +44,6 @@ import org.apache.axis.Handler;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.SimpleTargetedChain;
-import org.apache.axis.management.ServiceAdmin;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ServiceDesc;
@@ -197,14 +196,6 @@ public class AxisServlet extends AxisSer
}
initQueryStringHandlers();
-
- // Setup the service admin
- try {
- ServiceAdmin.setEngine(this.getEngine(), context.getServerInfo());
- } catch (AxisFault af) {
- exceptionLog.info("Exception setting AxisEngine on ServiceAdmin " +
- af);
- }
}
Propchange: axis/axis1/java/trunk/axis-rt-management/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov 16 21:10:50 2012
@@ -0,0 +1,4 @@
+.classpath
+.project
+target
+.settings
Added: axis/axis1/java/trunk/axis-rt-management/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-rt-management/pom.xml?rev=1410572&view=auto
==============================================================================
--- axis/axis1/java/trunk/axis-rt-management/pom.xml (added)
+++ axis/axis1/java/trunk/axis-rt-management/pom.xml Fri Nov 16 21:10:50 2012
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.axis</groupId>
+ <artifactId>axis-project</artifactId>
+ <version>1.4.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>axis-rt-management</artifactId>
+ <name>JMX Support</name>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axis-rt-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-modeler</groupId>
+ <artifactId>commons-modeler</artifactId>
+ <version>2.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
Propchange: axis/axis1/java/trunk/axis-rt-management/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/Registrar.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/Registrar.java?rev=1410572&r1=1404511&r2=1410572&view=diff
==============================================================================
--- axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/Registrar.java (original)
+++ axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/Registrar.java Fri Nov 16 21:10:50 2012
@@ -16,11 +16,8 @@
package org.apache.axis.management;
import org.apache.axis.components.logger.LogFactory;
-import org.apache.axis.i18n.Messages;
import org.apache.commons.logging.Log;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import org.apache.commons.modeler.Registry;
/**
* class to act as a dynamic loading registrar to commons-modeler, so
@@ -35,8 +32,7 @@ public class Registrar {
protected static Log log = LogFactory.getLog(Registrar.class.getName());
/**
- * register using reflection. The perf hit is moot as jmx is
- * all reflection anyway
+ * register an MBean
*
* @param objectToRegister
* @param name
@@ -44,155 +40,16 @@ public class Registrar {
*/
public static boolean register(Object objectToRegister,
String name, String context) {
- if (isBound()) {
- if (log.isDebugEnabled()) {
- log.debug("Registering " + objectToRegister + " as "
- + name);
- }
- return modelerBinding.register(objectToRegister, name, context);
- } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Registering " + objectToRegister + " as "
+ + name);
+ }
+ try {
+ Registry.getRegistry(null, null).registerComponent(objectToRegister, name, context);
+ return true;
+ } catch (Exception ex) {
+ log.warn(ex);
return false;
}
}
-
- /**
- * Check for being bound to a modeler -this will force
- * a binding if none existed.
- *
- * @return
- */
-
- public static boolean isBound() {
- createModelerBinding();
- return modelerBinding.canBind();
- }
-
- /**
- * create the modeler binding if it is needed
- * At the end of this call, modelerBinding != null
- */
- private static void createModelerBinding() {
- if (modelerBinding == null) {
- modelerBinding = new ModelerBinding();
- }
- }
-
- /**
- * the inner class that does the binding
- */
- private static ModelerBinding modelerBinding = null;
-
- /**
- * This class provides a dynamic binding to the
- * commons-modeler registry at run time
- */
- static class ModelerBinding {
- /**
- * the constructor binds
- */
- public ModelerBinding() {
- bindToModeler();
- }
-
- /**
- * can the binding bind?
- *
- * @return true iff the classes are bound
- */
- public boolean canBind() {
- return registry != null;
- }
-
- /**
- * log
- */
- protected static Log log = LogFactory.getLog(ModelerBinding.class.getName());
- /**
- * registry object
- */
- Object registry;
- /**
- * method to call
- */
- Method registerComponent;
-
- /**
- * register using reflection. The perf hit is moot as jmx is
- * all reflection anyway
- *
- * @param objectToRegister
- * @param name
- * @param context
- */
- public boolean register(Object objectToRegister, String name, String context) {
- if (registry != null) {
- Object args[] = new Object[]{objectToRegister, name, context};
- try {
- registerComponent.invoke(registry, args);
- if (log.isDebugEnabled()) {
- log.debug("Registered " + name + " in " + context);
- }
- } catch (IllegalAccessException e) {
- log.error(e);
- return false;
- } catch (IllegalArgumentException e) {
- log.error(e);
- return false;
- } catch (InvocationTargetException e) {
- log.error(e);
- return false;
- }
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * bind to the modeler; return success/failure flag
- *
- * @return true if the binding worked
- */
- private boolean bindToModeler() {
- Exception ex = null;
- Class clazz;
- try {
- clazz = Class.forName("org.apache.commons.modeler.Registry");
- } catch (ClassNotFoundException e) {
- // just ignore it silently if we don't have commons-modeler.jar around
- registry = null;
- return false;
- }
- try {
- Class[] getRegistryArgs = new Class[]{Object.class, Object.class,};
- Method getRegistry = clazz.getMethod("getRegistry", getRegistryArgs);
- Object[] getRegistryOptions = new Object[]{null, null};
- registry = getRegistry.invoke(null, getRegistryOptions);
- Class[] registerArgs = new Class[]{Object.class,
- String.class,
- String.class};
- registerComponent = clazz.getMethod("registerComponent", registerArgs);
- } catch (IllegalAccessException e) {
- ex = e;
- } catch (IllegalArgumentException e) {
- ex = e;
- } catch (InvocationTargetException e) {
- ex = e;
- } catch (NoSuchMethodException e) {
- ex = e;
- }
- // handle any of these exceptions
- if (ex != null) {
- //log the error
- log.warn(Messages.getMessage("Registrar.cantregister"), ex);
- //mark the registration as a failure
- registry = null;
- //and fail
- return false;
- } else {
- //success
- return true;
- }
- }
- }
}
Added: axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/servlet/AxisServerMBeanExporter.java
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/servlet/AxisServerMBeanExporter.java?rev=1410572&view=auto
==============================================================================
--- axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/servlet/AxisServerMBeanExporter.java (added)
+++ axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/servlet/AxisServerMBeanExporter.java Fri Nov 16 21:10:50 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.axis.management.servlet;
+
+import javax.servlet.ServletContextAttributeEvent;
+import javax.servlet.ServletContextAttributeListener;
+
+import org.apache.axis.management.ServiceAdmin;
+import org.apache.axis.server.AxisServer;
+import org.apache.axis.transport.http.AxisServlet;
+
+/**
+ * Listener that registers the MBeans for the {@link AxisServer} created by {@link AxisServlet}. To
+ * enable MBean registration in your Web application, add the following configuration to
+ * <tt>web.xml</tt>:
+ *
+ * <pre>
+ * <listener>
+ * <listener-class>org.apache.axis.management.servlet.AxisServerMBeanExporter</listener-class>
+ * </listener>
+ * </pre>
+ *
+ * @author Andreas Veithen
+ */
+public class AxisServerMBeanExporter implements ServletContextAttributeListener {
+ public void attributeAdded(ServletContextAttributeEvent event) {
+ Object value = event.getValue();
+ if (value instanceof AxisServer) {
+ ServiceAdmin.setEngine((AxisServer)value, event.getServletContext().getServerInfo());
+ }
+ }
+
+ public void attributeRemoved(ServletContextAttributeEvent event) {
+ // TODO: we currently never unregister the MBeans, but this was also the case in Axis 1.4
+ }
+
+ public void attributeReplaced(ServletContextAttributeEvent event) {
+ attributeRemoved(event);
+ attributeAdded(event);
+ }
+}
Propchange: axis/axis1/java/trunk/axis-rt-management/src/main/java/org/apache/axis/management/servlet/AxisServerMBeanExporter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis1/java/trunk/axis-war/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-war/pom.xml?rev=1410572&r1=1410571&r2=1410572&view=diff
==============================================================================
--- axis/axis1/java/trunk/axis-war/pom.xml (original)
+++ axis/axis1/java/trunk/axis-war/pom.xml Fri Nov 16 21:10:50 2012
@@ -45,6 +45,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>axis-rt-management</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
Modified: axis/axis1/java/trunk/axis-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-war/src/main/webapp/WEB-INF/web.xml?rev=1410572&r1=1410571&r2=1410572&view=diff
==============================================================================
--- axis/axis1/java/trunk/axis-war/src/main/webapp/WEB-INF/web.xml (original)
+++ axis/axis1/java/trunk/axis-war/src/main/webapp/WEB-INF/web.xml Fri Nov 16 21:10:50 2012
@@ -9,6 +9,10 @@ Application 2.3//EN" "http://java.sun.co
<listener>
<listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
</listener>
+ <!-- Uncomment this to register the Axis MBeans -->
+ <!-- listener>
+ <listener-class>org.apache.axis.management.servlet.AxisServerMBeanExporter</listener-class>
+ </listener -->
<servlet>
<servlet-name>AxisServlet</servlet-name>
Modified: axis/axis1/java/trunk/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/pom.xml?rev=1410572&r1=1410571&r2=1410572&view=diff
==============================================================================
--- axis/axis1/java/trunk/pom.xml (original)
+++ axis/axis1/java/trunk/pom.xml Fri Nov 16 21:10:50 2012
@@ -66,6 +66,7 @@
<module>axis-rt-jws</module>
<module>axis-rt-databinding-castor</module>
<module>axis-rt-databinding-xmlbeans</module>
+ <module>axis-rt-management</module>
<module>axis-rt-provider-bsf</module>
<module>axis-rt-soapmonitor</module>
<module>axis-rt-transport-http-hc3</module>
Modified: axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt
URL: http://svn.apache.org/viewvc/axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt?rev=1410572&r1=1410571&r2=1410572&view=diff
==============================================================================
--- axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt (original)
+++ axis/axis1/java/trunk/src/site/apt/changelogs/1_4_1.apt Fri Nov 16 21:10:50 2012
@@ -47,4 +47,7 @@ Changes from 1.4 final
* WSDL4J has been upgraded from 1.5.1 to 1.6.2.
* Support for Java 1.3 has been dropped.
-
+
+ * <<<AxisServlet>>> no longer attempts to register the Axis MBeans automatically. To enable them, add
+ <<<axis-rt-management>>> as a dependency and register <<<org.apache.axis.management.servlet.AxisServerMBeanExporter>>>
+ as a listener in <<<web.xml>>>.