[jboss-cvs] JBossAS SVN: r89629 - projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 1 17:33:53 EDT 2009


Author: ALRubinger
Date: 2009-06-01 17:33:53 -0400 (Mon, 01 Jun 2009)
New Revision: 89629

Modified:
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
Log:
[JBBOOT-84] Added some missing ServerConfig @ManagementProperty annotations

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java	2009-06-01 21:32:54 UTC (rev 89628)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java	2009-06-01 21:33:53 UTC (rev 89629)
@@ -23,6 +23,7 @@
 package org.jboss.bootstrap.impl.as.config;
 
 import java.io.File;
+import java.lang.reflect.Type;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -34,6 +35,14 @@
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
 
 /**
  * BasicJBossASServerConfig
@@ -45,11 +54,7 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
- at ManagementObject(name = "jboss.system:type=ServerConfig", 
-      isRuntime = true, 
-      properties = ManagementProperties.EXPLICIT, 
-      description = "provides a view of server config information", 
-      componentType = @ManagementComponent(type = "MCBean", subtype = "*"))
+ at ManagementObject(name = "jboss.system:type=ServerConfig", isRuntime = true, properties = ManagementProperties.EXPLICIT, description = "provides a view of server config information", componentType = @ManagementComponent(type = "MCBean", subtype = "*"))
 public class BasicJBossASServerConfig extends AbstractBasicServerConfig<JBossASServerConfig>
       implements
          JBossASServerConfig
@@ -249,6 +254,7 @@
    /* (non-Javadoc)
     * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getServerName()
     */
+   @ManagementProperty(description = "the name of the active profile the sever is using", readOnly = true)
    public String getServerName()
    {
       return this.serverName;
@@ -306,6 +312,7 @@
    /* (non-Javadoc)
     * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getJBossHome()
     */
+   @ManagementProperty(description = "the local home directory which the server is running from", readOnly = true, name = "homeUrl")
    public URL getJBossHome()
    {
       URL url = null;
@@ -337,6 +344,7 @@
    /* (non-Javadoc)
     * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#bootLibraryLocation(java.net.URL)
     */
+   @ManagementProperty(description = "the bootstrap library URL for the server.", readOnly = true)
    public synchronized JBossASServerConfig bootLibraryLocation(final URL bootLibraryLocation)
    {
       // Set
@@ -365,6 +373,7 @@
    /* (non-Javadoc)
     * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getServerBaseLocation()
     */
+   @ManagementProperty(description = "the base URL for calculating server home URLs", readOnly = true, name = "serverBaseURL")
    public URL getServerBaseLocation()
    {
       URL url = null;
@@ -412,6 +421,7 @@
    /* (non-Javadoc)
     * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#serverHomeLocation()
     */
+   @ManagementProperty(description = "the server home URL", readOnly = true, name = "serverHomeURL")
    public URL getServerHomeLocation()
    {
       URL url = null;
@@ -492,6 +502,7 @@
    /* (non-Javadoc)
     * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getCommonBaseLocation()
     */
+   @ManagementProperty(description = "the common library URL base", readOnly = true, name = "commonBaseURL")
    public URL getCommonBaseLocation()
    {
       URL url = null;
@@ -538,6 +549,7 @@
    /* (non-Javadoc)
     * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getCommonLibLocation()
     */
+   @ManagementProperty(description = "the URL for the common library jars", readOnly = true, name = "commonLibraryURL")
    public URL getCommonLibLocation()
    {
       URL url = null;
@@ -659,6 +671,7 @@
    /* (non-Javadoc)
     * @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#getServerLibLocation()
     */
+   @ManagementProperty(description = "the server library URL", readOnly = true, name = "serverLibraryURL")
    public URL getServerLibLocation()
    {
       URL url = null;
@@ -1005,6 +1018,102 @@
    }
 
    //-------------------------------------------------------------------------------||
+   // Managed Metadata Operations --------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /*
+    * These overridden implementations are to append the management object
+    * metadata required by AS and the Consoles
+    * 
+    * JBBOOT-84
+    */
+
+   /* (non-Javadoc)
+    * @see org.jboss.bootstrap.impl.base.config.AbstractBasicServerConfig#getBootstrapUrl()
+    */
+   @ManagementProperty(description = "the bootstrap url", readOnly = true, name = "bootstrapURL")
+   @Override
+   public URL getBootstrapUrl()
+   {
+      return super.getBootstrapUrl();
+   }
+
+   @ManagementProperty(description = "the local home directory which the server is running from", readOnly = true)
+   @MetaMapping(FileMetaMapper.class)
+   public File getHomeDir()
+   {
+      return this.urlToFile(this.getJBossHome());
+   }
+
+   @ManagementProperty(description = "the base directory for calculating server home directories", readOnly = true)
+   @MetaMapping(FileMetaMapper.class)
+   public File getServerBaseDir()
+   {
+      return this.urlToFile(this.getServerBaseLocation());
+   }
+
+   @ManagementProperty(description = "the server home directory", readOnly = true)
+   @MetaMapping(FileMetaMapper.class)
+   public File getServerHomeDir()
+   {
+      return this.urlToFile(this.getServerHomeLocation());
+   }
+
+   @ManagementProperty(description = "the server log directory", readOnly = true)
+   @MetaMapping(FileMetaMapper.class)
+   public File getServerLogDir()
+   {
+      return this.urlToFile(this.getServerLogLocation());
+   }
+
+   @ManagementProperty(description = "the directory where temporary files will be stored", readOnly = true)
+   @MetaMapping(FileMetaMapper.class)
+   public File getServerTempDir()
+   {
+      return this.urlToFile(this.getServerTempLocation());
+   }
+
+   @ManagementProperty(description = "the directory where local data will be stored", readOnly = true)
+   @MetaMapping(FileMetaMapper.class)
+   public File getServerDataDir()
+   {
+      return this.urlToFile(this.getServerDataLocation());
+   }
+
+   @ManagementProperty(description = "the directory for platform native files", readOnly = true)
+   @MetaMapping(FileMetaMapper.class)
+   public File getServerNativeDir()
+   {
+      return this.urlToFile(this.getNativeLibraryLocation());
+   }
+
+   /**
+    * Represents the specified URL as a file.  Throws unchecked
+    * exception upon type errors 
+    * 
+    * @param url
+    * @return The File representation, or null if null was passed in
+    */
+   private File urlToFile(final URL url)
+   {
+      // If null
+      if (url == null)
+      {
+         return null;
+      }
+
+      // Convert to File
+      try
+      {
+         return new File(url.toURI());
+      }
+      catch (URISyntaxException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   //-------------------------------------------------------------------------------||
    // Internal Helper Methods ------------------------------------------------------||
    //-------------------------------------------------------------------------------||
 
@@ -1099,4 +1208,44 @@
       }
    }
 
+   //-------------------------------------------------------------------------------||
+   // Inner Classes ----------------------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /**
+    * TODO: move to managed project, JBMAN-49
+    */
+   public static class FileMetaMapper extends MetaMapper<File>
+   {
+      @Override
+      public MetaValue createMetaValue(MetaType metaType, File object)
+      {
+         return SimpleValueSupport.wrap(object.getAbsolutePath());
+      }
+
+      @Override
+      public MetaType getMetaType()
+      {
+         return SimpleMetaType.STRING;
+      }
+
+      @Override
+      public Type mapToType()
+      {
+         return File.class;
+      }
+
+      @Override
+      public File unwrapMetaValue(MetaValue metaValue)
+      {
+         SimpleValue svalue = (SimpleValue) metaValue;
+         File f = null;
+         if (svalue != null)
+         {
+            f = new File(svalue.getValue().toString());
+         }
+         return f;
+      }
+   }
+
 }




More information about the jboss-cvs-commits mailing list