[jboss-cvs] JBossAS SVN: r105403 - in projects/jboss-jca/trunk/codegenerator/src/main: resources and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun May 30 21:20:22 EDT 2010


Author: jeff.zhang
Date: 2010-05-30 21:20:21 -0400 (Sun, 30 May 2010)
New Revision: 105403

Modified:
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AsCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConfigPropType.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java
   projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
Log:
[JBJCA-337] ActivationSpec CodeGen support configuration properties

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AsCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AsCodeGen.java	2010-05-30 20:25:28 UTC (rev 105402)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AsCodeGen.java	2010-05-31 01:20:21 UTC (rev 105403)
@@ -23,6 +23,7 @@
 
 import java.io.IOException;
 import java.io.Writer;
+import java.util.List;
 
 /**
  * A ActivationSpec CodeGen.
@@ -30,7 +31,7 @@
  * @author Jeff Zhang
  * @version $Revision: $
  */
-public class AsCodeGen extends AbstractCodeGen
+public class AsCodeGen extends PropsCodeGen
 {
 
    /**
@@ -59,9 +60,18 @@
       out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
       writeEol(out);
       writeEol(out);
+      
+      writeIndent(out, indent);
+      out.write("/** The resource adapter */");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("private ResourceAdapter ra;");
+      writeEol(out);
+      writeEol(out);
 
       writeDefaultConstructor(def, out, indent);
       
+      writeConfigProps(def, out, indent);
       writeValidate(def, out, indent);
       writeResourceAdapter(def, out, indent);
       
@@ -89,6 +99,13 @@
       writeEol(out);
       out.write("import javax.resource.spi.ActivationSpec;");
       writeEol(out);
+      if (def.isUseAnnotation())
+      {
+         out.write("import javax.resource.spi.ConfigProperty;");
+         writeEol(out);
+         out.write("import javax.resource.spi.Connector;");
+         writeEol(out);
+      }
       out.write("import javax.resource.spi.InvalidPropertyException;");
       writeEol(out);
       out.write("import javax.resource.spi.ResourceAdapter;");
@@ -111,6 +128,17 @@
    }
    
    /**
+    * get list of ConfigPropType
+    * @param def definition
+    * @return List<ConfigPropType> List of ConfigPropType
+    */
+   @Override
+   public List<ConfigPropType> getConfigProps(Definition def)
+   {
+      return def.getAsConfigProps();
+   }
+   
+   /**
     * Output validate method
     * @param def definition
     * @param out Writer
@@ -180,7 +208,7 @@
       out.write("log.debug(\"call getResourceAdapter\");");
       writeEol(out);
       writeIndent(out, indent + 1);
-      out.write("return null;");
+      out.write("return ra;");
       writeRightCurlyBracket(out, indent);
       writeEol(out);
       
@@ -205,6 +233,9 @@
       writeLeftCurlyBracket(out, indent);
       writeIndent(out, indent + 1);
       out.write("log.debug(\"call setResourceAdapter\");");
+      writeEol(out);
+      writeIndent(out, indent + 1);
+      out.write("this.ra = ra;");
       writeRightCurlyBracket(out, indent);
       writeEol(out);
    }

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConfigPropType.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConfigPropType.java	2010-05-30 20:25:28 UTC (rev 105402)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConfigPropType.java	2010-05-31 01:20:21 UTC (rev 105403)
@@ -35,6 +35,8 @@
    private String type;
    /** value */
    private String value;
+   /** required */
+   private boolean required;
 
    /**
     * Set the name.
@@ -42,13 +44,15 @@
     * @param name The name to set.
     * @param type The type to set.
     * @param value The value to set.
+    * @param required The required to set.
     */
-   public ConfigPropType(String name, String type, String value)
+   public ConfigPropType(String name, String type, String value, boolean required)
    {
    
       this.name = name;
       this.type = type;
       this.value = value;
+      this.required = required;
    }
    
    /**
@@ -110,4 +114,24 @@
    {
       return value;
    }
+
+   /**
+    * Set the required.
+    * 
+    * @param required The required to set.
+    */
+   public void setRequired(boolean required)
+   {
+      this.required = required;
+   }
+
+   /**
+    * Get the required.
+    * 
+    * @return the required.
+    */
+   public boolean isRequired()
+   {
+      return required;
+   }
 }

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java	2010-05-30 20:25:28 UTC (rev 105402)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java	2010-05-31 01:20:21 UTC (rev 105403)
@@ -84,8 +84,10 @@
    private boolean supportInbound;
    /** connection metadata class name */
    private String mlClass;
-   /** connection spec class name */
+   /** ActivationSpec class name */
    private String asClass;
+   /** ActivationSpec configuration properties */
+   private List<ConfigPropType> asConfigProps;
    
    /**
     * Set the outputDir.
@@ -580,4 +582,24 @@
    {
       return asClass;
    }
+
+   /**
+    * Set the asConfigProps.
+    * 
+    * @param asConfigProps The asConfigProps to set.
+    */
+   public void setAsConfigProps(List<ConfigPropType> asConfigProps)
+   {
+      this.asConfigProps = asConfigProps;
+   }
+
+   /**
+    * Get the asConfigProps.
+    * 
+    * @return the asConfigProps.
+    */
+   public List<ConfigPropType> getAsConfigProps()
+   {
+      return asConfigProps;
+   }
 }

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java	2010-05-30 20:25:28 UTC (rev 105402)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java	2010-05-31 01:20:21 UTC (rev 105403)
@@ -120,14 +120,14 @@
          def.setRaPackage(packageName);
          def.setRaClass(raClassName);
          
-         List<ConfigPropType> raProps = inputProperties("ra", dbconf, in);
+         List<ConfigPropType> raProps = inputProperties("ra", dbconf, in, false);
          def.setRaConfigProps(raProps);
          
          System.out.print(dbconf.getString("mcf.class.name"));
          String mcfClassName = in.readLine();
          def.setMcfClass(mcfClassName);
 
-         List<ConfigPropType> mcfProps = inputProperties("mcf", dbconf, in);
+         List<ConfigPropType> mcfProps = inputProperties("mcf", dbconf, in, false);
          def.setMcfConfigProps(mcfProps);
 
          System.out.print(dbconf.getString("mcf.impl.raa"));
@@ -195,6 +195,8 @@
             System.out.print(dbconf.getString("as.class.name"));
             String asClassName = in.readLine();
             def.setAsClass(asClassName);
+            List<ConfigPropType> asProps = inputProperties("as", dbconf, in, true);
+            def.setAsConfigProps(asProps);
          }
          
          def.setOutputDir(outputDir);
@@ -309,10 +311,12 @@
     * @param classname belong to which java class
     * @param dbconf ResourceBundle
     * @param in BufferedReader
+    * @param supportRequired need input required property
     * @return List<ConfigPropType> list of properties
     * @throws IOException ioException
     */
-   private static List<ConfigPropType> inputProperties(String classname, ResourceBundle dbconf, BufferedReader in) 
+   private static List<ConfigPropType> inputProperties(String classname, 
+      ResourceBundle dbconf, BufferedReader in, boolean supportRequired) 
       throws IOException
    {
       List<ConfigPropType> props = new ArrayList<ConfigPropType>();
@@ -347,9 +351,24 @@
          }
          System.out.print("    " + dbconf.getString("config.properties.value"));
          String value = in.readLine();
+         boolean required = false;
+         if (supportRequired)
+         {
+            System.out.print("    " + dbconf.getString("config.properties.required"));
+            String propRequired = in.readLine();
+            if (propRequired == null)
+               required = false;
+            else
+            {
+               if (propRequired.equals("Y") || propRequired.equals("y") || propRequired.equals("Yes"))
+                  required = true;
+               else
+                  required = false;
+            }
+         }
          System.out.println();
          
-         ConfigPropType config = new ConfigPropType(name, type, value);
+         ConfigPropType config = new ConfigPropType(name, type, value, required);
          props.add(config);
       }
       return props;

Modified: projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties	2010-05-30 20:25:28 UTC (rev 105402)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties	2010-05-31 01:20:21 UTC (rev 105403)
@@ -10,8 +10,9 @@
 ra.config.properties=Resource adapter config properties [enter to quit]: 
 config.properties.name=Name: 
 config.properties.type=Type: 
+config.properties.type.tip=Input right type: 
 config.properties.value=Value: 
-config.properties.type.tip=Input right type: 
+config.properties.required=Required [Y/N/Yes/No]: 
 mcf.config.properties=Managed connection factory config properties [enter to quit]: 
 mcf.impl.raa=Use ResourceAdapterAssociation: [Y/N/Yes/No] 
 mcf.use.cci=Use CCI: [Y/N/Yes/No] 
@@ -19,4 +20,5 @@
 code.wrote=Code generated
 support.inbound=Support inbound: [Y/N/Yes/No] 
 ml.interface.name=MessageListener interface name: 
-as.class.name=ActivationSpec class name: 
\ No newline at end of file
+as.class.name=ActivationSpec class name: 
+as.config.properties=ActivationSpec config properties [enter to quit]: 
\ No newline at end of file




More information about the jboss-cvs-commits mailing list