db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r627131 - in /db/derby/code/trunk/java/engine: ./ org/apache/derby/iapi/services/info/ org/apache/derby/impl/services/jmx/ org/apache/derby/mbeans/
Date Tue, 12 Feb 2008 21:42:52 GMT
Author: djd
Date: Tue Feb 12 13:42:50 2008
New Revision: 627131

URL: http://svn.apache.org/viewvc?rev=627131&view=rev
Log:
DERBY-1387 (partial) Establish a pattern of registering a Derby mbean using StandardMBean.
This allows the MBean interface and implementation class to be in separate packages (and if
required have unrelated names). This means the public api org.apache.derby.mbeans is not forced
to contain the implementation of the MBeans and thus have references to other classes that
are not part of the public api.
Fix the build order for o.a.d.mbeans to be early since it does not depend on internal classes
and should not require JDK 1.5.
Added a version string attribute to the VersionMBean that shows the full version.

Added:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/Version.java
      - copied, changed from r627101, db/derby/code/trunk/java/engine/org/apache/derby/mbeans/Version.java
    db/derby/code/trunk/java/engine/org/apache/derby/mbeans/build.xml   (with props)
Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/mbeans/Version.java
Modified:
    db/derby/code/trunk/java/engine/build.xml
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
    db/derby/code/trunk/java/engine/org/apache/derby/mbeans/VersionMBean.java

Modified: db/derby/code/trunk/java/engine/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/build.xml?rev=627131&r1=627130&r2=627131&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/build.xml (original)
+++ db/derby/code/trunk/java/engine/build.xml Tue Feb 12 13:42:50 2008
@@ -74,6 +74,7 @@
           description="Build base JSR169 elements of Derby engine">
     <ant dir="${derby.engine.dir}/iapi/reference"/>
     <ant dir="${derby.engine.dir}/authentication"/>
+  	<ant dir="${derby.engine.dir}/mbeans"/>
     <ant dir="${derby.engine.dir}/io"/>
      <ant dir="${derby.engine.dir}/iapi" target="compile_iapi_error_jsr169"/>
      <ant dir="${derby.engine.dir}/database"/>

Copied: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/Version.java (from
r627101, db/derby/code/trunk/java/engine/org/apache/derby/mbeans/Version.java)
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/Version.java?p2=db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/Version.java&p1=db/derby/code/trunk/java/engine/org/apache/derby/mbeans/Version.java&r1=627101&r2=627131&rev=627131&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/mbeans/Version.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/info/Version.java Tue Feb
12 13:42:50 2008
@@ -1,6 +1,6 @@
 /*
 
-   Derby - Class org.apache.derby.mbeans.Version
+   Derby - Class org.apache.derby.iapi.services.info.Version
 
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -19,9 +19,9 @@
 
 */
 
-package org.apache.derby.mbeans;
+package org.apache.derby.iapi.services.info;
 
-import org.apache.derby.iapi.services.info.ProductVersionHolder;
+import org.apache.derby.mbeans.VersionMBean;
 
 /**
  * This implementation of VersionMBean instruments a
@@ -32,52 +32,55 @@
  */
 public class Version implements VersionMBean {
     
-    private final ProductVersionHolder engineVersionRef;
+    private final ProductVersionHolder versionInfo;
     
     public Version(ProductVersionHolder pvh) {
-        engineVersionRef = pvh;
+        versionInfo = pvh;
     }
     
     // ------------------------- MBEAN ATTRIBUTES  ----------------------------
     
     public String getProductName(){
-        return engineVersionRef.getProductName();
+        return versionInfo.getProductName();
     }
     
      public String getProductTechnologyName(){
-        return engineVersionRef.getProductTechnologyName();
+        return versionInfo.getProductTechnologyName();
     }
     
     public String getProductVendorName(){
-        return engineVersionRef.getProductVendorName();
+        return versionInfo.getProductVendorName();
     }
     
+    public String getVersionString() {
+        return versionInfo.getVersionBuildString(true);
+    }
     public int getMajorVersion(){
-        return engineVersionRef.getMajorVersion();
+        return versionInfo.getMajorVersion();
     }
     
     public int getMinorVersion(){
-        return engineVersionRef.getMinorVersion();
+        return versionInfo.getMinorVersion();
     }
     
     public int getMaintVersion(){
-        return engineVersionRef.getMaintVersion();
+        return versionInfo.getMaintVersion();
     }
     
     public String getBuildNumber(){
-        return engineVersionRef.getBuildNumber();
+        return versionInfo.getBuildNumber();
     }
     
     public int getBuildNumberAsInt(){
-        return engineVersionRef.getBuildNumberAsInt();
+        return versionInfo.getBuildNumberAsInt();
     }
     
-    public boolean getIsBeta(){
-        return engineVersionRef.isBeta();
+    public boolean isBeta(){
+        return versionInfo.isBeta();
     }
     
     public boolean isAlpha(){
-        return engineVersionRef.isAlpha();
+        return versionInfo.isAlpha();
     }
   
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java?rev=627131&r1=627130&r2=627131&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
Tue Feb 12 13:42:50 2008
@@ -29,14 +29,16 @@
 import javax.management.JMException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
+import javax.management.StandardMBean;
 
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.Property;
+import org.apache.derby.iapi.services.info.Version;
 import org.apache.derby.iapi.services.jmx.ManagementService;
 import org.apache.derby.iapi.services.monitor.ModuleControl;
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.services.property.PropertyUtil;
-import org.apache.derby.mbeans.Version;
+import org.apache.derby.mbeans.VersionMBean;
 
 /** 
  * This class implements the ManagementService interface and provides a simple
@@ -108,6 +110,7 @@
                     });
 
             registerMBean(new Version(Monitor.getMonitor().getEngineVersion()),
+                    VersionMBean.class,
                     "org.apache.derby:type=Version,jar=derby.jar");
             
         } catch (SecurityException se) {
@@ -117,14 +120,22 @@
     }
 
     /**
-     * Registers an MBean with the MBean server. The object name instance 
+     * Registers an MBean with the MBean server as a StandardMBean.
+     * Use of the StandardMBean allows the implementation details
+     * of Derby's mbeans to be hidden from JMX, thus only exposing
+     * the MBean's interface in org.apache.derby.mbeans.
+     * 
+     * The object name instance 
      * represented by the given String will be created by this method.
      * 
-     * @param bean The MBean to register
+     * @param bean The MBean to wrap with a StandardMBean and register
+     * @param beanInterface The management interface for the MBean.
      * @param name The String representation of the MBean's object name.
      * 
      */
-    private synchronized void registerMBean(final Object bean, final String name)
+    private synchronized void registerMBean(final Object bean,
+            final Class beanInterface,
+            final String name)
             throws StandardException {
 
         if (mbeanServer == null)
@@ -132,13 +143,15 @@
 
         try {
             final ObjectName beanName = new ObjectName(name);
+            final StandardMBean standardMBean =
+                new StandardMBean(bean, beanInterface);
             try {
 
                 AccessController
                         .doPrivileged(new PrivilegedExceptionAction<Object>() {
 
                             public Object run() throws JMException {
-                                mbeanServer.registerMBean(bean, beanName);
+                                mbeanServer.registerMBean(standardMBean, beanName);
                                 return null;
                             }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/mbeans/VersionMBean.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/mbeans/VersionMBean.java?rev=627131&r1=627130&r2=627131&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/mbeans/VersionMBean.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/mbeans/VersionMBean.java Tue Feb 12 13:42:50
2008
@@ -23,7 +23,7 @@
 
 /** 
 * This interface defines a Standard MBean for exposing the version information
-* of the running Derby engine.
+* of a running Derby component.
 * 
 * Refer to the getters of the interface for defined attributes. All attributes
 * are read-only.
@@ -41,10 +41,16 @@
     public int getMinorVersion();
     public int getMaintVersion();
     
+    /**
+     * Return the full version string.
+     * @return Full version string.
+     */
+    public String getVersionString();
+    
     public String getBuildNumber();
     public int getBuildNumberAsInt();
     
-    public boolean getIsBeta();
+    public boolean isBeta();
     public boolean isAlpha();
     
 }

Added: db/derby/code/trunk/java/engine/org/apache/derby/mbeans/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/mbeans/build.xml?rev=627131&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/mbeans/build.xml (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/mbeans/build.xml Tue Feb 12 13:42:50
2008
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+  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 default="compile_mbeans" basedir="../../../../../..">
+
+<!-- Set Properties -->
+  <!-- User settings -->
+  <property file="${user.home}/ant.properties"/>
+  <!-- Set property lib dir -->
+  <property name="properties.dir" value="tools/ant/properties"/>
+  <!-- Significant dirs -->
+  <property file="${properties.dir}/dirs.properties"/>
+  <!-- Compiler settings -->
+  <property file="${properties.dir}/defaultcompiler.properties"/>
+  <property file="${properties.dir}/${build.compiler}.properties"/>
+  <!-- Compile-time classpath properties files -->
+  <property file="${properties.dir}/extrapath.properties"/>
+  <property file="${properties.dir}/compilepath.properties"/>
+
+<!-- Targets -->
+  <target name="compile_mbeans">
+    <javac
+      source="1.4"
+      target="1.4"
+      bootclasspath="${empty}"
+      nowarn="on"
+      debug="${debug}"
+      depend="${depend}"
+      deprecation="${deprecation}"
+      optimize="${optimize}"
+      proceed="${proceed}"
+      verbose="${verbose}"
+      srcdir="${derby.engine.src.dir}"
+      destdir="${out.dir}">
+      <classpath>
+        <pathelement path="${compile.classpath}"/>
+      </classpath>
+      <include name="${derby.dir}/mbeans/**"/>
+    </javac>
+  </target>
+
+</project>
+

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/mbeans/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message