[jboss-cvs] JBossAS SVN: r81432 - in projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed: plugins/factory and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 21 09:57:19 EST 2008


Author: alesj
Date: 2008-11-21 09:57:19 -0500 (Fri, 21 Nov 2008)
New Revision: 81432

Added:
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/BaseManagedObjectDefinition.java
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ConfigurableManagedObjectDefinition.java
Modified:
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectDefinition.java
   projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
Log:
[JBMAn-40]; add mo definition.

Copied: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/BaseManagedObjectDefinition.java (from rev 81429, projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectDefinition.java)
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/BaseManagedObjectDefinition.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/BaseManagedObjectDefinition.java	2008-11-21 14:57:19 UTC (rev 81432)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.managed.api.factory;
+
+import org.jboss.managed.spi.factory.ManagedObjectBuilder;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Base managed object definition.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class BaseManagedObjectDefinition extends JBossObject
+{
+   private Class<?> type;
+   private ManagedObjectBuilder builder;
+
+   protected BaseManagedObjectDefinition()
+   {
+   }
+
+   protected BaseManagedObjectDefinition(Class<?> type, ManagedObjectBuilder builder)
+   {
+      this.type = type;
+      this.builder = builder;
+   }
+
+   /**
+    * Is definition valid.
+    *
+    * @return true if valid
+    */
+   public boolean isValid()
+   {
+      return type != null && builder != null;
+   }
+
+   /**
+    * Get type.
+    *
+    * @return the type
+    */
+   public Class<?> getType()
+   {
+      return type;
+   }
+
+   /**
+    * Set type.
+    *
+    * @param type the type
+    */
+   public void setType(Class<?> type)
+   {
+      this.type = type;
+   }
+
+   /**
+    * Get builder.
+    *
+    * @return the builder
+    */
+   public ManagedObjectBuilder getBuilder()
+   {
+      return builder;
+   }
+
+   /**
+    * Set builder.
+    *
+    * @param builder the builder
+    */
+   public void setBuilder(ManagedObjectBuilder builder)
+   {
+      this.builder = builder;
+   }
+
+   @Override
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append("type=").append(type);
+      buffer.append(", builder=").append(builder);
+   }
+
+   @Override
+   protected void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("type=").append(type);
+      buffer.append(", builder=").append(builder);
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/BaseManagedObjectDefinition.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ConfigurableManagedObjectDefinition.java (from rev 81429, projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectDefinition.java)
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ConfigurableManagedObjectDefinition.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ConfigurableManagedObjectDefinition.java	2008-11-21 14:57:19 UTC (rev 81432)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.managed.api.factory;
+
+import org.jboss.managed.spi.factory.ManagedObjectBuilder;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Configurable managed object definition.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class ConfigurableManagedObjectDefinition extends BaseManagedObjectDefinition
+{
+   private ManagedObjectFactory factory;
+
+   public ConfigurableManagedObjectDefinition()
+   {
+   }
+
+   public ConfigurableManagedObjectDefinition(ManagedObjectFactory factory)
+   {
+      this(factory, null, null);
+   }
+
+   public ConfigurableManagedObjectDefinition(ManagedObjectFactory factory, Class<?> type, ManagedObjectBuilder builder)
+   {
+      super(type, builder);
+      this.factory = factory;
+   }
+
+   @Override
+   public boolean isValid()
+   {
+      return super.isValid() && factory != null;
+   }
+
+   /**
+    * Add builder to factory.
+    */
+   public void start()
+   {
+      if (isValid() == false)
+         throw new IllegalArgumentException("Definition is invalid: " + toString());
+
+      factory.setBuilder(getType(), getBuilder());
+   }
+
+   /**
+    * Remove builder from factory.
+    */
+   public void stop()
+   {
+      if (factory == null)
+         throw new IllegalArgumentException("Missing managed object factory");
+      if (getType() == null)
+         throw new IllegalArgumentException("Missing type");
+
+      factory.setBuilder(getType(), null);
+   }
+
+   /**
+    * Get managed obejct factory.
+    *
+    * @return the managed object factory
+    */
+   public ManagedObjectFactory getFactory()
+   {
+      return factory;
+   }
+
+   /**
+    * Set managed object factory.
+    *
+    * @param factory the managed object factory
+    */
+   public void setFactory(ManagedObjectFactory factory)
+   {
+      this.factory = factory;
+   }
+
+   @Override
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      super.toShortString(buffer);
+      buffer.append(", factory=").append(factory);
+   }
+
+   @Override
+   protected void toString(JBossStringBuilder buffer)
+   {
+      super.toString(buffer);
+      buffer.append(", factory=").append(factory);
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ConfigurableManagedObjectDefinition.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectDefinition.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectDefinition.java	2008-11-21 14:48:37 UTC (rev 81431)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/api/factory/ManagedObjectDefinition.java	2008-11-21 14:57:19 UTC (rev 81432)
@@ -28,114 +28,14 @@
  *
  * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
  */
-public class ManagedObjectDefinition
+public class ManagedObjectDefinition extends BaseManagedObjectDefinition
 {
-   private ManagedObjectFactory factory;
-
-   private Class<?> type;
-   private ManagedObjectBuilder builder;
-
    public ManagedObjectDefinition()
    {
    }
 
-   public ManagedObjectDefinition(ManagedObjectFactory factory)
+   public ManagedObjectDefinition(Class<?> type, ManagedObjectBuilder builder)
    {
-      this.factory = factory;
+      super(type, builder);
    }
-
-   public ManagedObjectDefinition(ManagedObjectFactory factory, Class<?> type, ManagedObjectBuilder builder)
-   {
-      this(factory);
-      this.type = type;
-      this.builder = builder;
-   }
-
-   /**
-    * Add builder to factory.
-    */
-   public void start()
-   {
-      if (factory == null)
-         throw new IllegalArgumentException("Missing managed object factory");
-      if (type == null)
-         throw new IllegalArgumentException("Missing type");
-      if (builder == null)
-         throw new IllegalArgumentException("Missing builder");
-
-      factory.setBuilder(type, builder);
-   }
-
-   /**
-    * Remove builder from factory.
-    */
-   public void stop()
-   {
-      if (factory == null)
-         throw new IllegalArgumentException("Missing managed object factory");
-      if (type == null)
-         throw new IllegalArgumentException("Missing type");
-
-      factory.setBuilder(type, null);
-   }
-
-   /**
-    * Get managed obejct factory.
-    *
-    * @return the managed object factory
-    */
-   public ManagedObjectFactory getFactory()
-   {
-      return factory;
-   }
-
-   /**
-    * Set managed object factory.
-    *
-    * @param factory the managed object factory
-    */
-   public void setFactory(ManagedObjectFactory factory)
-   {
-      this.factory = factory;
-   }
-
-   /**
-    * Get type.
-    *
-    * @return the type
-    */
-   public Class<?> getType()
-   {
-      return type;
-   }
-
-   /**
-    * Set type.
-    *
-    * @param type the type
-    */
-   public void setType(Class<?> type)
-   {
-      this.type = type;
-   }
-
-   /**
-    * Get builder.
-    *
-    * @return the builder
-    */
-   public ManagedObjectBuilder getBuilder()
-   {
-      return builder;
-   }
-
-   /**
-    * Set builder.
-    *
-    * @param builder the builder
-    */
-   public void setBuilder(ManagedObjectBuilder builder)
-   {
-      this.builder = builder;
-   }
 }

Modified: projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
===================================================================
--- projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java	2008-11-21 14:48:37 UTC (rev 81431)
+++ projects/jboss-man/trunk/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java	2008-11-21 14:57:19 UTC (rev 81432)
@@ -57,6 +57,7 @@
 import org.jboss.managed.api.annotation.ManagementProperty;
 import org.jboss.managed.api.annotation.ManagementRuntimeRef;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.api.factory.ManagedObjectDefinition;
 import org.jboss.managed.plugins.DefaultFieldsImpl;
 import org.jboss.managed.plugins.ManagedObjectImpl;
 import org.jboss.managed.plugins.ManagedOperationImpl;
@@ -181,6 +182,32 @@
    }
 
    /**
+    * Add managed object definition.
+    *
+    * @param definition the MO definition
+    */
+   public void addManagedObjectDefinition(ManagedObjectDefinition definition)
+   {
+      if (definition == null || definition.isValid() == false)
+         throw new IllegalArgumentException("Invalid MO definition: " + definition);
+
+      setBuilder(definition.getType(), definition.getBuilder());
+   }
+
+   /**
+    * Remove managed object definition.
+    *
+    * @param definition the MO definition
+    */
+   public void removeManagedObjectDefinition(ManagedObjectDefinition definition)
+   {
+      if (definition == null)
+         return;
+
+      setBuilder(definition.getType(), null);
+   }
+
+   /**
     * Get the configuration
     * 
     * @return the configuration




More information about the jboss-cvs-commits mailing list