[jboss-cvs] JBossAS SVN: r110430 - in projects/jboss-jca/trunk/codegenerator/src/main: java/org/jboss/jca/codegenerator/code and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Jan 22 21:04:27 EST 2011


Author: jeff.zhang
Date: 2011-01-22 21:04:26 -0500 (Sat, 22 Jan 2011)
New Revision: 110430

Added:
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AdminObjectType.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AoImplCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AoInterfaceCodeGen.java
Modified:
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BaseProfile.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/java/org/jboss/jca/codegenerator/code/RaCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/IronjacamarXmlGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
   projects/jboss-jca/trunk/codegenerator/src/main/resources/ironjacamar.xml.template
Log:
[JBJCA-460] admin object generation support

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AdminObjectType.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AdminObjectType.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AdminObjectType.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.codegenerator;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * An AdminObjectType.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+public class AdminObjectType
+{
+   /** define admin object interface */
+   @XmlElement(name = "AdminObjectInterface") 
+   private String adminObjectInterface;
+
+   /** define admin object class */
+   @XmlElement(name = "AdminObjectClass") 
+   private String adminObjectClass;
+
+   /** admin object configuration properties */
+   @XmlElement(name = "AoConfigProp") 
+   private List<ConfigPropType> aoConfigProps;
+   
+   /**
+    * Set the adminObjectInterface.
+    * 
+    * @param adminObjectInterface The adminObjectInterface to set.
+    */
+   public void setAdminObjectInterface(String adminObjectInterface)
+   {
+      this.adminObjectInterface = adminObjectInterface;
+   }
+
+   /**
+    * Get the adminObjectInterface.
+    * 
+    * @return the adminObjectInterface.
+    */
+   public String getAdminObjectInterface()
+   {
+      return adminObjectInterface;
+   }
+
+   /**
+    * Set the adminObjectClass.
+    * 
+    * @param adminObjectClass The adminObjectClass to set.
+    */
+   public void setAdminObjectClass(String adminObjectClass)
+   {
+      this.adminObjectClass = adminObjectClass;
+   }
+
+   /**
+    * Get the adminObjectClass.
+    * 
+    * @return the adminObjectClass.
+    */
+   public String getAdminObjectClass()
+   {
+      return adminObjectClass;
+   }
+   
+   /**
+    * Set the aoConfigProps.
+    * 
+    * @param aoConfigProps The aoConfigProps to set.
+    */
+   public void setAoConfigProps(List<ConfigPropType> aoConfigProps)
+   {
+      this.aoConfigProps = aoConfigProps;
+   }
+
+   /**
+    * Get the aoConfigProps.
+    * 
+    * @return the aoConfigProps.
+    */
+   public List<ConfigPropType> getAoConfigProps()
+   {
+      return aoConfigProps;
+   }
+
+}

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BaseProfile.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BaseProfile.java	2011-01-22 21:32:09 UTC (rev 110429)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BaseProfile.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -22,6 +22,8 @@
 package org.jboss.jca.codegenerator;
 
 import org.jboss.jca.codegenerator.code.AbstractCodeGen;
+import org.jboss.jca.codegenerator.code.AoImplCodeGen;
+import org.jboss.jca.codegenerator.code.AoInterfaceCodeGen;
 import org.jboss.jca.codegenerator.xml.BuildIvyXmlGen;
 import org.jboss.jca.codegenerator.xml.BuildXmlGen;
 import org.jboss.jca.codegenerator.xml.IronjacamarXmlGen;
@@ -95,6 +97,14 @@
       {
          generateClassCode(def, "Ra");
       }
+      if (def.isGenAdminObject())
+      {
+         for (int i = 0; i < def.getAdminObjects().size(); i++)
+         {
+            generateMultiAdminObjectClassCode(def, "AoImpl", i);
+            generateMultiAdminObjectClassCode(def, "AoInterface", i);
+         }
+      }
    }
 
    /**
@@ -209,6 +219,52 @@
    }
    
    /**
+    * generate multi admin object class code
+    * @param def Definition 
+    * @param className class name 
+    * @param num number of order
+    */
+   void generateMultiAdminObjectClassCode(Definition def, String className, int num)
+   {
+      if (className == null || className.equals(""))
+         return;
+      
+      try
+      {
+         String clazzName = this.getClass().getPackage().getName() + ".code." + className + "CodeGen";
+
+         Class<?> clazz = Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader());
+         AbstractCodeGen codeGen = (AbstractCodeGen)clazz.newInstance();
+         
+         String javaFile = "";
+         if (codeGen instanceof AoImplCodeGen)
+         {
+            ((AoImplCodeGen)codeGen).setNumOfAo(num);
+            javaFile = def.getAdminObjects().get(num).getAdminObjectClass() + ".java";
+         }
+         else if (codeGen instanceof AoInterfaceCodeGen)
+         {
+            ((AoInterfaceCodeGen)codeGen).setNumOfAo(num);
+            javaFile = def.getAdminObjects().get(num).getAdminObjectInterface() + ".java";
+         }
+         
+         FileWriter fw = Utils.createSrcFile(javaFile, def.getRaPackage(), def.getOutputDir());
+         codeGen.generate(def, fw);
+
+         fw.flush();
+         fw.close();
+      }
+      catch (IOException ioe)
+      {
+         ioe.printStackTrace();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+   
+   /**
     * generate ant build.xml
     * @param def Definition
     * @param outputDir output directory

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	2011-01-22 21:32:09 UTC (rev 110429)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -120,7 +120,7 @@
    private String connMetaClass;
    /** connection spec class name */
    private String connSpecClass;
-   /** resource adapater metadata class name */
+   /** resource adapter metadata class name */
    private String raMetaClass;
 
    /** support outbound  */
@@ -163,6 +163,13 @@
    @XmlElement(name = "GenMBean")
    private boolean genMbean = true;
 
+   /** generate admin object or not  */
+   @XmlElement(name = "GenAdminObject")
+   private boolean genAdminObject = false;
+   /** list of admin object  */
+   @XmlElement(name = "AdminObject")
+   private List<AdminObjectType> adminObjects;
+   
    /**
     * Set the version.
     * 
@@ -1004,4 +1011,44 @@
    {
       this.genMbean = genMbean;
    }
+
+   /**
+    * Set the adminObjects.
+    * 
+    * @param adminObjects The adminObjects to set.
+    */
+   public void setAdminObjects(List<AdminObjectType> adminObjects)
+   {
+      this.adminObjects = adminObjects;
+   }
+
+   /**
+    * Get the adminObjects.
+    * 
+    * @return the adminObjects.
+    */
+   public List<AdminObjectType> getAdminObjects()
+   {
+      return adminObjects;
+   }
+
+   /**
+    * Set the genAdminObject.
+    * 
+    * @param genAdminObject The genAdminObject to set.
+    */
+   public void setGenAdminObject(boolean genAdminObject)
+   {
+      this.genAdminObject = genAdminObject;
+   }
+
+   /**
+    * Get the genAdminObject.
+    * 
+    * @return the genAdminObject.
+    */
+   public boolean isGenAdminObject()
+   {
+      return genAdminObject;
+   }
 }

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	2011-01-22 21:32:09 UTC (rev 110429)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -419,6 +419,68 @@
             def.setActivationClass(actiClassName);
       }
       
+      //admin object
+      System.out.print(rb.getString("gen.adminobject") + "[N]: ");
+      String genAo = in.readLine();
+      if (genAo == null)
+         def.setGenAdminObject(false);
+      else
+      {
+         if (genAo.equals("Y") || genAo.equals("y") || genAo.equals("Yes"))
+            def.setGenAdminObject(true);
+         else
+            def.setGenAdminObject(false);
+      }
+      
+      int numOfAo = 0;
+      while (numOfAo >= 0 && def.isGenAdminObject())
+      {
+         String strOrder = numOfAo > 0 ? new Integer(numOfAo).toString() : "";
+         AdminObjectType aoType = new AdminObjectType();
+         System.out.print(rb.getString("adminobject.interface.name"));
+         System.out.print("[" + def.getDefaultValue() + strOrder + "AdminObjectInterface]: ");
+         String aoInterfaceName = in.readLine();
+         if (aoInterfaceName != null && !aoInterfaceName.equals(""))
+         {
+            aoType.setAdminObjectInterface(aoInterfaceName);
+         }
+         else
+         {
+            aoType.setAdminObjectInterface(def.getDefaultValue() + strOrder + "AdminObjectInterface");
+         }
+         
+         System.out.print(rb.getString("adminobject.class.name"));
+         System.out.print("[" + def.getDefaultValue() + strOrder + "AdminObjectImpl]: ");
+         String aoClassName = in.readLine();
+         if (aoClassName != null && !aoClassName.equals(""))
+         {
+            aoType.setAdminObjectClass(aoClassName);
+         }
+         else
+         {
+            aoType.setAdminObjectClass(def.getDefaultValue() + strOrder + "AdminObjectImpl");
+         }
+   
+         List<ConfigPropType> aoProps = inputProperties("adminobject", in, false);
+         aoType.setAoConfigProps(aoProps);
+         
+         if (def.getAdminObjects() == null)
+            def.setAdminObjects(new ArrayList<AdminObjectType>());
+         def.getAdminObjects().add(aoType);
+         
+         System.out.print(rb.getString("gen.adminobject.other") + "[N]: ");
+         String genAoAgain = in.readLine();
+         if (genAoAgain == null)
+            numOfAo = -1;
+         else
+         {
+            if (genAoAgain.equals("Y") || genAoAgain.equals("y") || genAoAgain.equals("Yes"))
+               numOfAo++;
+            else
+               numOfAo = -1;
+         }
+      }
+      
       if (!def.isUseCciConnection())
       {
          //generate mbean classes

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AoImplCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AoImplCodeGen.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AoImplCodeGen.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.codegenerator.code;
+
+import org.jboss.jca.codegenerator.ConfigPropType;
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+/**
+ * An admin object class CodeGen.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class AoImplCodeGen extends PropsCodeGen
+{
+   /** admin object order */
+   int numOfAo = 0;
+
+   /**
+    * constructor 
+    */
+   public AoImplCodeGen()
+   {
+   }
+   /**
+    * constructor 
+    * @param num admin object order
+    */
+   public AoImplCodeGen(int num)
+   {
+      numOfAo = num;
+   }
+   
+   /**
+    * Get the numOfAo.
+    * 
+    * @return the numOfAo.
+    */
+   public int getNumOfAo()
+   {
+      return numOfAo;
+   }
+
+   /**
+    * Set the numOfAo.
+    * 
+    * @param numOfAo The numOfAo to set.
+    */
+   public void setNumOfAo(int numOfAo)
+   {
+      this.numOfAo = numOfAo;
+   }
+
+   /**
+    * Output class
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeClassBody(Definition def, Writer out) throws IOException
+   {
+      if (def.isUseAnnotation())
+      {
+         out.write("@AdministeredObject");
+         writeEol(out);
+      }
+      out.write("public class " + getClassName(def) + " implements " + 
+         def.getAdminObjects().get(numOfAo).getAdminObjectInterface());
+      writeLeftCurlyBracket(out, 0);
+      writeEol(out);
+
+      int indent = 1;
+
+      writeDefaultConstructor(def, out, indent);
+      
+      writeConfigProps(def, out, indent);
+
+      writeRightCurlyBracket(out, 0);
+   }
+   
+   /**
+    * Output class import
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeImport(Definition def, Writer out) throws IOException
+   {
+      out.write("package " + def.getRaPackage() + ";");
+      writeEol(out);
+      writeEol(out);
+      if (def.isUseAnnotation())
+      {
+         out.write("import javax.resource.spi.AdministeredObject;");
+         writeEol(out);
+         out.write("import javax.resource.spi.ConfigProperty;");
+         writeEol(out);
+         out.write("import javax.resource.spi.Connector;");
+         writeEol(out);
+      }
+      writeEol(out);
+   }
+   
+   /**
+    * get this class name
+    * @param def definition
+    * @return String class name
+    */
+   @Override
+   public String getClassName(Definition def)
+   {
+      return def.getAdminObjects().get(numOfAo).getAdminObjectClass();
+   }
+   
+   /**
+    * get list of ConfigPropType
+    * @param def definition
+    * @return List<ConfigPropType> List of ConfigPropType
+    */
+   @Override
+   public List<ConfigPropType> getConfigProps(Definition def)
+   {
+      return def.getAdminObjects().get(numOfAo).getAoConfigProps();
+   }
+
+}

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AoInterfaceCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AoInterfaceCodeGen.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AoInterfaceCodeGen.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -0,0 +1,192 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jca.codegenerator.code;
+
+import org.jboss.jca.codegenerator.ConfigPropType;
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+/**
+ * An admin object interface CodeGen.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class AoInterfaceCodeGen extends AbstractCodeGen
+{
+   /** admin object order */
+   int numOfAo = 0;
+
+   /**
+    * constructor 
+    */
+   public AoInterfaceCodeGen()
+   {
+   }
+   /**
+    * constructor 
+    * @param num admin object order
+    */
+   public AoInterfaceCodeGen(int num)
+   {
+      numOfAo = num;
+   }
+   
+   /**
+    * Get the numOfAo.
+    * 
+    * @return the numOfAo.
+    */
+   public int getNumOfAo()
+   {
+      return numOfAo;
+   }
+
+   /**
+    * Set the numOfAo.
+    * 
+    * @param numOfAo The numOfAo to set.
+    */
+   public void setNumOfAo(int numOfAo)
+   {
+      this.numOfAo = numOfAo;
+   }
+
+   /**
+    * Output class
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeClassBody(Definition def, Writer out) throws IOException
+   {
+      out.write("public interface " + getClassName(def));
+      writeLeftCurlyBracket(out, 0);
+      writeEol(out);
+
+      int indent = 1;
+      writeConfigProps(def, out, indent);
+      writeRightCurlyBracket(out, 0);
+   }
+   
+   /**
+    * Output class import
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeImport(Definition def, Writer out) throws IOException
+   {
+      out.write("package " + def.getRaPackage() + ";");
+      writeEol(out);
+      writeEol(out);
+   }
+   
+   /**
+    * get this class name
+    * @param def definition
+    * @return String class name
+    */
+   @Override
+   public String getClassName(Definition def)
+   {
+      return def.getAdminObjects().get(numOfAo).getAdminObjectInterface();
+   }
+   
+   /**
+    * Output validate method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeConfigProps(Definition def, Writer out, int indent) throws IOException
+   {
+      for (int i = 0; i < getConfigProps(def).size(); i++)
+      {
+         String name = getConfigProps(def).get(i).getName();
+         String upcaseName = upcaseFirst(name);
+         //set
+         writeIndent(out, indent);
+         out.write("/** ");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write(" * Set " + name);
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write(" * @param " + name + " The value");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write(" */");
+         writeEol(out);
+         
+         writeIndent(out, indent);
+         out.write("public void set" + 
+                   upcaseName +
+                   "(" +
+                   getConfigProps(def).get(i).getType() +
+                   " " +
+                   name +
+                   ");");
+         writeEol(out);
+         writeEol(out);
+         
+         //get
+         writeIndent(out, indent);
+         out.write("/** ");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write(" * Get " + name);
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write(" * @return The value");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write(" */");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write("public " + 
+                   getConfigProps(def).get(i).getType() +
+                   " get" +
+                   upcaseName +
+                   "();");
+         writeEol(out);
+         writeEol(out);
+      }
+   }
+   
+   /**
+    * get list of ConfigPropType
+    * @param def definition
+    * @return List<ConfigPropType> List of ConfigPropType
+    */
+   public List<ConfigPropType> getConfigProps(Definition def)
+   {
+      return def.getAdminObjects().get(numOfAo).getAoConfigProps();
+   }
+
+}

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java	2011-01-22 21:32:09 UTC (rev 110429)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -98,6 +98,21 @@
                def.getSupportTransaction() + ")");
          }
          writeEol(out);
+         if (def.isGenAdminObject() && def.getAdminObjects().size() > 0)
+         {
+            out.write("@AdministeredObject(adminObjectInterfaces = { ");
+            writeEol(out);
+            for (int i = 0; i < def.getAdminObjects().size(); i++)
+            {
+               writeIndent(out, 1);
+               out.write(def.getAdminObjects().get(i).getAdminObjectClass() + ".class");
+               if (i < def.getAdminObjects().size() - 1)
+                  out.write(",");
+               writeEol(out);
+            }
+            out.write("})");
+            writeEol(out);
+         }
       }
       out.write("public class " + getClassName(def) + " implements ResourceAdapter");
       writeLeftCurlyBracket(out, 0);
@@ -213,6 +228,12 @@
       out.write("import javax.resource.spi.ActivationSpec;");
       writeEol(out);
       if (def.isUseAnnotation() && 
+         def.isGenAdminObject() && def.getAdminObjects().size() > 0)
+      {
+         out.write("import javax.resource.spi.AdministeredObject;");
+         writeEol(out);
+      }
+      if (def.isUseAnnotation() && 
          def.getAuthenMechanisms() != null && def.getAuthenMechanisms().size() > 0)
       {
          out.write("import javax.resource.spi.AuthenticationMechanism;");

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/IronjacamarXmlGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/IronjacamarXmlGen.java	2011-01-22 21:32:09 UTC (rev 110429)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/IronjacamarXmlGen.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -63,6 +63,25 @@
       List<ConfigPropType> mcfPropsList = def.getMcfConfigProps();
       getPropsString(strMcfProps, mcfPropsList, 6);
       
+      StringBuilder strAo = new StringBuilder();
+      if (def.isGenAdminObject())
+      {
+         strAo.append("  <admin-objects>\n");
+         for (int i = 0; i < def.getAdminObjects().size(); i++)
+         {
+            strAo.append("    <admin-object class-name=\"");
+            strAo.append(def.getRaPackage());
+            strAo.append(".");
+            strAo.append(def.getAdminObjects().get(i).getAdminObjectClass());
+            strAo.append("\" jndi-name=\"java:/");
+            strAo.append(def.getAdminObjects().get(i).getAdminObjectClass());
+            strAo.append("\">\n");
+            getPropsString(strAo, def.getAdminObjects().get(i).getAoConfigProps(), 6);
+            strAo.append("    </admin-object>\n");
+         }
+         strAo.append("  </admin-objects>\n");
+      }
+      
       Map<String, String> map = new HashMap<String, String>();
       map.put("ra.props", strRaProps.toString());
       map.put("transaction", def.getSupportTransaction());
@@ -70,6 +89,7 @@
       map.put("jndi.name", "java:/eis/" + def.getDefaultValue());
       map.put("pool.name", def.getDefaultValue());
       map.put("mcf.props", strMcfProps.toString());
+      map.put("adminobjects", strAo.toString());
       Template template = new SimpleTemplate(buildString);
       template.process(map, out);
    }
@@ -83,14 +103,14 @@
     */
    private void getPropsString(StringBuilder strProps, List<ConfigPropType> propsList, int indent)
    {
-      for (ConfigPropType raProps : propsList)
+      for (ConfigPropType props : propsList)
       {
          for (int i = 0; i < indent; i++)
             strProps.append(" ");
          strProps.append("<config-property name=\"");
-         strProps.append(raProps.getName());
+         strProps.append(props.getName());
          strProps.append("\">");
-         strProps.append(raProps.getValue());
+         strProps.append(props.getValue());
          strProps.append("</config-property>");
          strProps.append("\n");
       }

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java	2011-01-22 21:32:09 UTC (rev 110429)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java	2011-01-23 02:04:26 UTC (rev 110430)
@@ -79,6 +79,28 @@
          writeInbound(def, out, indent + 1);
       }
 
+      if (def.isGenAdminObject() && def.getAdminObjects().size() > 0)
+      {
+         for (int i = 0; i < def.getAdminObjects().size(); i++)
+         {
+            writeIndent(out, indent + 1);
+            out.write("<adminobject>");
+            writeEol(out);
+            writeIndent(out, indent + 2);
+            out.write("<adminobject-interface>" + def.getRaPackage() + "." + 
+               def.getAdminObjects().get(i).getAdminObjectInterface() + "</adminobject-interface>");
+            writeEol(out);
+            writeIndent(out, indent + 2);
+            out.write("<adminobject-class>" + def.getRaPackage() + "." + 
+               def.getAdminObjects().get(i).getAdminObjectClass() + "</adminobject-class>");
+            writeEol(out);
+            writeConfigPropsXml(def.getAdminObjects().get(i).getAoConfigProps(), out, indent + 2, false);
+            writeIndent(out, indent + 1);
+            out.write("</adminobject>");
+            writeEol(out);
+         }
+      }
+      
       if (def.getSecurityPermissions() != null && def.getSecurityPermissions().size() > 0)
       {
          for (int i = 0; i < def.getSecurityPermissions().size(); i++)

Modified: projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties	2011-01-22 21:32:09 UTC (rev 110429)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties	2011-01-23 02:04:26 UTC (rev 110430)
@@ -31,6 +31,11 @@
 connection.method.param.type=Parameter type: 
 connection.method.exception=Exception type [enter to quit]: 
 output.dir=Output directory: 
-gen.mbean=Generate MBean test class (Y/Yes/N/No) 
+gen.mbean=Generate MBean class (Y/Yes/N/No) 
+gen.adminobject=Generate admin object (Y/Yes/N/No) 
+adminobject.interface.name=Admin object interface name 
+adminobject.class.name=Admin object class name 
+gen.adminobject.other=Generate other admin object (Y/Yes/N/No) 
+adminobject.config.properties=Admin object config properties [enter to quit]: 
 build.env=Build environment [A/Ant/I/Ant+Ivy/M/Maven] 
 code.wrote=Code generated 

Modified: projects/jboss-jca/trunk/codegenerator/src/main/resources/ironjacamar.xml.template
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/ironjacamar.xml.template	2011-01-22 21:32:09 UTC (rev 110429)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/ironjacamar.xml.template	2011-01-23 02:04:26 UTC (rev 110430)
@@ -12,5 +12,5 @@
 ${mcf.props}
     </connection-definition>
   </connection-definitions>
-
+${adminobjects}
 </ironjacamar>



More information about the jboss-cvs-commits mailing list