[jboss-cvs] JBossAS SVN: r78471 - in trunk: profileservice/src/main/org/jboss/managed/plugins and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 11 19:52:51 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-09-11 19:52:51 -0400 (Thu, 11 Sep 2008)
New Revision: 78471

Removed:
   trunk/profileservice/src/main/org/jboss/managed/plugins/factory/
   trunk/profileservice/src/main/org/jboss/metatype/
Modified:
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
The only managed property values should be MetaValues. An unwrapped java value should never been used. Get rid of duplicate classes now located in the jboss-man artifacts.

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2008-09-11 22:46:07 UTC (rev 78470)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2008-09-11 23:52:51 UTC (rev 78471)
@@ -21,7 +21,6 @@
  */
 package org.jboss.profileservice.management;
 
-import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -74,9 +73,7 @@
 import org.jboss.metatype.api.values.CollectionValue;
 import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
 import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.profileservice.management.plugins.BasicDeploymentTemplateInfo;
 import org.jboss.profileservice.spi.AttachmentsSerializer;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
@@ -110,7 +107,7 @@
    private long activeProfileLastModified;
    /** */
    private MainDeployer mainDeployer;
-   /** */
+   /** The attachments serializer used to */
    private AttachmentsSerializer serializer;
    private InvokerLocator locator;
 
@@ -702,7 +699,7 @@
                ManagedObject mo = prop.getManagedObject();
                if(mo instanceof ManagedObjectImpl)
                {
-                  // TODO: need a MutableManagedObject type
+                  // TODO: need a MutableManagedObject type, JBMAN-23
                   ManagedObjectImpl moi = (ManagedObjectImpl) mo;
                   moi.setName(name);
                }
@@ -766,31 +763,18 @@
             String msg = formatter.format(args);
             throw new IllegalArgumentException(msg);
          }
-         // TODO - decide what is the type of value when we set it
-         // since currently get always returns MetaValue, but we see some cases
-         // where plain Serializable is enough
-         Serializable serializable;
-         MetaValue metaValue;
+         // The property value must be a MetaValue
          Object value = prop.getValue();
-         if (value instanceof MetaValue)
+         if ((value instanceof MetaValue) == false)
          {
-            metaValue = (MetaValue)value;
-            MetaType metaType = metaValue.getMetaType();
-            if (metaType.isSimple())
-               serializable = ((SimpleValue)metaValue).getValue();
-            else if (metaType.isGeneric())
-               serializable = ((GenericValue)metaValue).getValue();
-            else
-               serializable = null;
+            formatter.applyPattern(i18n.getString("ManagementView.InvalidPropertyValue")); //$NON-NLS-1$
+            Object[] args = {prop.getName(), value.getClass()};
+            String msg = formatter.format(args);
+            throw new IllegalArgumentException(msg);
          }
-         else
-         {
-            serializable = (Serializable)value;
-            metaValue = MetaValueFactory.getInstance().create(value);
-         }
+         MetaValue metaValue = (MetaValue)value;
+         ctxProp.setValue(metaValue);
 
-         if(serializable != null)
-            ctxProp.setValue(serializable);
          // todo - should this also dispatch to runtime component?
          Object componentName = getComponentName(ctxProp);
          if (componentName != null)
@@ -908,10 +892,7 @@
             String msg = formatter.format(args);
             throw new IllegalArgumentException(msg);
          }
-         // TODO - decide what is the type of value when we set it
-         // since currently get always returns MetaValue, but we see some cases
-         // where plain Serializable is enough
-         Serializable serializable;
+         // The property value must be a MetaValue
          Object value = prop.getValue();
          if ((value instanceof MetaValue) == false)
          {
@@ -921,22 +902,6 @@
             throw new IllegalArgumentException(msg);
          }
          MetaValue metaValue = (MetaValue)value;
-         /*
-         {
-            MetaType metaType = metaValue.getMetaType();
-            if (metaType.isSimple())
-               serializable = ((SimpleValue)metaValue).getValue();
-            else if (metaType.isGeneric())
-               serializable = ((GenericValue)metaValue).getValue();
-            else
-               serializable = null;
-         }
-         else
-         {
-            serializable = (Serializable)value;
-            metaValue = SimpleValueSupport.wrap(serializable);
-         }
-         */
          ctxProp.setValue(metaValue);
          Object componentName = getComponentName(ctxProp);
          if (componentName != null)
@@ -978,7 +943,7 @@
 
    /**
     * Merge the runtime props and ops
-    * TODO: need a plugin to access the ManagedObject impl
+    * TODO: need a plugin to access the ManagedObject impl, JBMAN-23
     * @param mo
     * @param runtimeMO
     */
@@ -1066,7 +1031,7 @@
 
       // Create the ManagedOperation proxies
       HashSet<ManagedOperation> opProxies = new HashSet<ManagedOperation>();
-      Class[] ifaces = {ManagedOperation.class};
+      Class<?>[] ifaces = {ManagedOperation.class};
       for (ManagedOperation op : ops)
       {
          // This is just a unique name registered with the dispatcher and remoting layers

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2008-09-11 22:46:07 UTC (rev 78470)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2008-09-11 23:52:51 UTC (rev 78471)
@@ -594,8 +594,8 @@
 
       addCommonDsProperties(propValues, jndiName, "jboss-xa-jdbc.rar", "javax.sql.DataSource");
 
-      propValues.put("xa-datasource-class", "org.hsqldb.jdbcDriver");
-      propValues.put("xa-resource-timeout", new Integer(256));
+      propValues.put("xa-datasource-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
+      propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
 
       HashMap<String, String> xaPropValues = new HashMap<String, String>();
       xaPropValues.put("URL", "jdbc:hsqldb");
@@ -640,8 +640,8 @@
 
       propValues.put("config-property", metaValue);
 
-      propValues.put("xa-transaction", Boolean.TRUE);
-      propValues.put("xa-resource-timeout", new Integer(256));
+      propValues.put("xa-transaction", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
 
       // todo: how to set the specific domain?
       //ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
@@ -730,13 +730,13 @@
    {
       addCommonDsProperties(propValues, jndiName, rarName, conDef);
 
-      propValues.put("transaction-isolation", "TRANSACTION_SERIALIZABLE");
-      propValues.put("user-name", "sa");
-      propValues.put("password", "");
+      propValues.put("transaction-isolation", SimpleValueSupport.wrap("TRANSACTION_SERIALIZABLE"));
+      propValues.put("user-name", SimpleValueSupport.wrap("sa"));
+      propValues.put("password", SimpleValueSupport.wrap(""));
 
       // non xa ds
-      propValues.put("driver-class", "org.hsqldb.jdbcDriver");
-      propValues.put("connection-url", "jdbc:hsqldb:.");
+      propValues.put("driver-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
+      propValues.put("connection-url", SimpleValueSupport.wrap("jdbc:hsqldb:."));
       // todo: connection-properties
    }
 
@@ -746,19 +746,19 @@
                                               String conDef)
    {
       addCommonCfProperties(propValues, jndiName, rarName, conDef);
-      propValues.put("new-connection-sql", "CALL ABS(2.0)");
-      propValues.put("check-valid-connection-sql", "CALL ABS(1.0)");
-      propValues.put("valid-connection-checker-class-name", "org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker");
-      propValues.put("exception-sorter-class-name", "org.jboss.resource.adapter.jdbc.vendor.DummyExceptionSorter");
-      propValues.put("stale-connection-checker-class-name", "org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker");
-      propValues.put("track-statements", "");
-      propValues.put("prepared-statement-cache-size", 12);
-      propValues.put("share-prepared-statements", Boolean.TRUE);
-      propValues.put("set-tx-query-timeout", Boolean.TRUE);
-      propValues.put("query-timeout", new Integer(100));
-      propValues.put("url-delimiter", "+");
-      propValues.put("url-selector-strategy-class-name", "org.jboss.test.jca.support.MyURLSelector");
-      propValues.put("use-try-lock", new Long(5000));
+      propValues.put("new-connection-sql", SimpleValueSupport.wrap("CALL ABS(2.0)"));
+      propValues.put("check-valid-connection-sql", SimpleValueSupport.wrap("CALL ABS(1.0)"));
+      propValues.put("valid-connection-checker-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker"));
+      propValues.put("exception-sorter-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyExceptionSorter"));
+      propValues.put("stale-connection-checker-class-name", SimpleValueSupport.wrap("org.jboss.resource.adapter.jdbc.vendor.DummyValidConnectionChecker"));
+      propValues.put("track-statements", SimpleValueSupport.wrap(""));
+      propValues.put("prepared-statement-cache-size", SimpleValueSupport.wrap(12));
+      propValues.put("share-prepared-statements", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("set-tx-query-timeout", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("query-timeout", SimpleValueSupport.wrap(new Integer(100)));
+      propValues.put("url-delimiter", SimpleValueSupport.wrap("+"));
+      propValues.put("url-selector-strategy-class-name", SimpleValueSupport.wrap("org.jboss.test.jca.support.MyURLSelector"));
+      propValues.put("use-try-lock", SimpleValueSupport.wrap(new Long(5000)));
    }
 
    private void addCommonCfProperties(Map<String, Serializable> propValues,
@@ -766,25 +766,25 @@
                                     String rarName,
                                     String conDef)
    {
-      propValues.put("jndi-name", jndiName);
-      propValues.put("rar-name", rarName);
-      propValues.put("use-java-context", Boolean.TRUE);
-      propValues.put("connection-definition", conDef);
-      //propValues.put("jmx-invoker-name", "jboss:service=invoker,type=jrmp");
-      propValues.put("min-pool-size", new Integer(0));
-      propValues.put("max-pool-size", new Integer(11));
-      propValues.put("blocking-timeout-millis", new Long(15000));
-      propValues.put("idle-timeout-minutes", new Integer(111));
-      propValues.put("prefill", Boolean.TRUE);
-      propValues.put("background-validation", Boolean.TRUE);
-      propValues.put("background-validation-millis", new Long(5000));
-      propValues.put("validate-on-match", Boolean.FALSE);
-      propValues.put("use-strict-min", Boolean.TRUE);
-      propValues.put("no-tx-separate-pools", Boolean.TRUE);
-      propValues.put("statistics-formatter", "org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter");
-      propValues.put("isSameRM-override-value", Boolean.FALSE);
-      propValues.put("track-connection-by-tx", Boolean.TRUE);
-      propValues.put("type-mapping", "Hypersonic SQL");
+      propValues.put("jndi-name", SimpleValueSupport.wrap(jndiName));
+      propValues.put("rar-name", SimpleValueSupport.wrap(rarName));
+      propValues.put("use-java-context", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("connection-definition", SimpleValueSupport.wrap(conDef));
+      //propValues.put("jmx-invoker-name", SimpleValueSupport.wrap("jboss:service=invoker,type=jrmp"));
+      propValues.put("min-pool-size", SimpleValueSupport.wrap(new Integer(0)));
+      propValues.put("max-pool-size", SimpleValueSupport.wrap(new Integer(11)));
+      propValues.put("blocking-timeout-millis", SimpleValueSupport.wrap(new Long(15000)));
+      propValues.put("idle-timeout-minutes", SimpleValueSupport.wrap(new Integer(111)));
+      propValues.put("prefill", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("background-validation", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("background-validation-millis", SimpleValueSupport.wrap(new Long(5000)));
+      propValues.put("validate-on-match", SimpleValueSupport.wrap(Boolean.FALSE));
+      propValues.put("use-strict-min", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("no-tx-separate-pools", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("statistics-formatter", SimpleValueSupport.wrap("org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter"));
+      propValues.put("isSameRM-override-value", SimpleValueSupport.wrap(Boolean.FALSE));
+      propValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("type-mapping", SimpleValueSupport.wrap("Hypersonic SQL"));
       // todo: config-property
       // todo: security-domain
       // todo: depends
@@ -829,12 +829,10 @@
          Object expectedValue = propValues.get(propName);
          if(propValue instanceof MetaValue)
          {
-            // Compare simple types to the java expected type
-            if(prop.getMetaType().isSimple())
-               assertEquals(prop.getName(), expectedValue, ((SimpleValue)propValue).getValue());
-            else if (prop.getMetaType().isComposite())
+            if (prop.getMetaType().isComposite())
             {
-               // TODO / FIXME - compare composits
+               // TODO / FIXME - compare composites
+               log.warn("Not checking composite: "+propValue);
             }
             else
             {




More information about the jboss-cvs-commits mailing list