[jboss-cvs] JBossAS SVN: r104594 - projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 10 00:00:04 EDT 2010


Author: jeff.zhang
Date: 2010-05-10 00:00:03 -0400 (Mon, 10 May 2010)
New Revision: 104594

Added:
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnFactoryCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CmCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McMetaCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ReferenceCodeGen.java
Modified:
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnImplCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnInterfaceCodeGen.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/JCA16AnnoProfile.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McfCodeGen.java
Log:
[JBJCA-307] Generate java files of rar package

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnCodeGen.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -0,0 +1,205 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.io.IOException;
+import java.io.Writer;
+
+/**
+ * A cci connection class CodeGen.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class CciConnCodeGen extends AbstractCodeGen
+{
+   /**
+    * Output ResourceAdapater class
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeClassBody(Definition def, Writer out) throws IOException
+   {
+
+      out.write("public class " + getClassName(def) + " implements Connection");
+      writeLeftCurlyBracket(out, 0);
+      int indent = 1;
+
+      writeClose(def, out, indent);
+      writeInteraction(def, out, indent);
+      writeLocalTransaction (def, out, indent);
+      writeMetaData(def, out, indent);
+      writeResultSetInfo(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);
+      out.write("import javax.resource.ResourceException;");
+      writeEol(out);
+      writeEol(out);
+      out.write("import javax.resource.cci.Connection;");
+      writeEol(out);
+      out.write("import javax.resource.cci.ConnectionMetaData;");
+      writeEol(out);
+      out.write("import javax.resource.cci.Interaction;");
+      writeEol(out);
+      out.write("import javax.resource.cci.LocalTransaction;");
+      writeEol(out);
+      out.write("import javax.resource.cci.ResultSetInfo;");
+      writeEol(out);
+      writeEol(out);
+   }
+   
+   /**
+    * get this class name
+    * @param def definition
+    * @return String class name
+    */
+   @Override
+   public String getClassName(Definition def)
+   {
+      return def.getCciConnClass();
+   }
+   
+   /**
+    * Output close method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeClose(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public void close() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+
+   /**
+    * Output Interaction method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeInteraction(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public Interaction createInteraction() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return null;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+   
+   /**
+    * Output LocalTransaction method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeLocalTransaction(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public LocalTransaction getLocalTransaction() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return null;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+   
+   /**
+    * Output MetaData method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeMetaData(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public ConnectionMetaData getMetaData() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return null;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+   
+   
+   /**
+    * Output ResultSetInfo method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeResultSetInfo(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public ResultSetInfo getResultSetInfo() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return null;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+}

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnFactoryCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnFactoryCodeGen.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnFactoryCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -0,0 +1,219 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.io.IOException;
+import java.io.Writer;
+
+/**
+ * A Cci connection factory class CodeGen.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class CciConnFactoryCodeGen extends AbstractCodeGen
+{
+   /**
+    * Output class code
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeClassBody(Definition def, Writer out) throws IOException
+   {
+
+      out.write("public class " + getClassName(def) + " implements ConnectionFactory");
+      writeLeftCurlyBracket(out, 0);
+      int indent = 1;
+      writeIndent(out, indent);
+      out.write("private Reference reference;");
+      writeEol(out);
+      writeEol(out);
+
+      writeConnection(def, out, indent);
+      writeMetaData(def, out, indent);
+      writeRecordFactory(def, out, indent);
+      writeReference(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);
+      out.write("import javax.naming.NamingException;");
+      writeEol(out);
+      out.write("import javax.naming.Reference;");
+      writeEol(out);
+      writeEol(out);
+      out.write("import javax.resource.ResourceException;");
+      writeEol(out);
+      out.write("import javax.resource.cci.Connection;");
+      writeEol(out);
+      out.write("import javax.resource.cci.ConnectionFactory;");
+      writeEol(out);
+      out.write("import javax.resource.cci.ConnectionSpec;");
+      writeEol(out);
+      out.write("import javax.resource.cci.RecordFactory;");
+      writeEol(out);
+      out.write("import javax.resource.cci.ResourceAdapterMetaData;");
+      writeEol(out);
+      writeEol(out);
+   }
+   
+   /**
+    * get this class name
+    * @param def definition
+    * @return String class name
+    */
+   @Override
+   public String getClassName(Definition def)
+   {
+      return def.getCciConnFactoryClass();
+   }
+   
+   /**
+    * Output Connection method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeConnection(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public Connection getConnection() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return new MyCciConnection();");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+      
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public Connection getConnection(ConnectionSpec properties) throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return new MyCciConnection();");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+
+   /**
+    * Output MetaData method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeMetaData(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public ResourceAdapterMetaData getMetaData() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return null;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+   
+   /**
+    * Output RecordFactory method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeRecordFactory(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public RecordFactory getRecordFactory() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return null;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+   
+   /**
+    * Output Reference method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeReference(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public Reference getReference() throws NamingException");
+      writeEol(out);
+      writeLeftCurlyBracket(out, indent);
+      writeIndent(out, indent + 1);
+      out.write("if (reference == null)");
+      writeEol(out);
+      writeIndent(out, indent + 2);
+      out.write("reference = new MyReference(this.getClass().getName());");
+      writeEol(out);
+      writeIndent(out, indent + 1);
+      out.write("return reference;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public void setReference(Reference reference)");
+      writeLeftCurlyBracket(out, indent);
+      writeIndent(out, indent + 1);
+      out.write("this.reference = reference;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+}

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CmCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CmCodeGen.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CmCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.io.IOException;
+import java.io.Writer;
+
+/**
+ * A connection impl class CodeGen.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class CmCodeGen extends AbstractCodeGen
+{
+
+   /**
+    * Output ResourceAdapater class
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeClassBody(Definition def, Writer out) throws IOException
+   {
+
+      out.write("public class " + getClassName(def) + " implements ConnectionManager");
+      writeLeftCurlyBracket(out, 0);
+      int indent = 1;
+      
+      //constructor
+      writeIndent(out, indent);
+      out.write("public " + getClassName(def) + "()");
+      writeLeftCurlyBracket(out, indent);
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+      
+      writeAllocateConn(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);
+      out.write("import javax.resource.ResourceException;");
+      writeEol(out);
+      out.write("import javax.resource.spi.ConnectionManager;");
+      writeEol(out);
+      out.write("import javax.resource.spi.ConnectionRequestInfo;");
+      writeEol(out);
+      out.write("import javax.resource.spi.ManagedConnectionFactory;");
+      writeEol(out);
+      writeEol(out);
+   }
+   
+   /**
+    * get this class name
+    * @param def definition
+    * @return String class name
+    */
+   @Override
+   public String getClassName(Definition def)
+   {
+      return def.getCmClass();
+   }
+   
+   /**
+    * Output allocateConnection method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeAllocateConn(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public Object allocateConnection(ManagedConnectionFactory mcf," +
+         "ConnectionRequestInfo cri) throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+      writeIndent(out, indent + 1);
+      out.write("return null;");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+}

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnImplCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnImplCodeGen.java	2010-05-10 03:51:31 UTC (rev 104593)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnImplCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -34,7 +34,7 @@
 {
 
    /**
-    * Output ResourceAdapater class
+    * Output class
     * @param def definition
     * @param out Writer
     * @throws IOException ioException

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnInterfaceCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnInterfaceCodeGen.java	2010-05-10 03:51:31 UTC (rev 104593)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnInterfaceCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -34,7 +34,7 @@
 {
 
    /**
-    * Output ResourceAdapater class
+    * Output class
     * @param def definition
     * @param out Writer
     * @throws IOException ioException

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-10 03:51:31 UTC (rev 104593)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -54,6 +54,17 @@
    
    /** ResourceAdapterAssociation optional  */
    private boolean implRaAssociation;
+
+   /** cci connection factory class name */
+   private String cciConnFactoryClass;
+   /** cci connection class name */
+   private String cciConnClass;
+   /** managed connection metadata class name */
+   private String mcMetaClass;
+   /** connection manage class name */
+   private String cmClass;
+   /** reference class name */
+   private String referenceClass;
    
    /**
     * Set the outputDir.
@@ -255,4 +266,114 @@
       return implRaAssociation;
    }
 
+   /**
+    * Set the cciConnFactoryClass.
+    * 
+    * @param cciConnFactoryClass The cciConnFactoryClass to set.
+    */
+   public void setCciConnFactoryClass(String cciConnFactoryClass)
+   {
+      this.cciConnFactoryClass = cciConnFactoryClass;
+   }
+
+   /**
+    * Get the cciConnFactoryClass.
+    * 
+    * @return the cciConnFactoryClass.
+    */
+   public String getCciConnFactoryClass()
+   {
+      if (cciConnFactoryClass == null || cciConnFactoryClass.equals(""))
+         cciConnFactoryClass = "MyCciConnectionFactory";
+      return cciConnFactoryClass;
+   }
+
+   /**
+    * Set the cciConnClass.
+    * 
+    * @param cciConnClass The cciConnClass to set.
+    */
+   public void setCciConnClass(String cciConnClass)
+   {
+      this.cciConnClass = cciConnClass;
+   }
+
+   /**
+    * Get the cciConnClass.
+    * 
+    * @return the cciConnClass.
+    */
+   public String getCciConnClass()
+   {
+      if (cciConnClass == null || cciConnClass.equals(""))
+         cciConnClass = "MyCciConnection";
+      return cciConnClass;
+   }
+
+   /**
+    * Set the mcMetaClass.
+    * 
+    * @param mcMetaClass The mcMetaClass to set.
+    */
+   public void setMcMetaClass(String mcMetaClass)
+   {
+      this.mcMetaClass = mcMetaClass;
+   }
+
+   /**
+    * Get the mcMetaClass.
+    * 
+    * @return the mcMetaClass.
+    */
+   public String getMcMetaClass()
+   {
+      if (mcMetaClass == null || mcMetaClass.equals(""))
+         mcMetaClass = "MyConnectionMetaData";
+      return mcMetaClass;
+   }
+
+   /**
+    * Set the cmClass.
+    * 
+    * @param cmClass The cmClass to set.
+    */
+   public void setCmClass(String cmClass)
+   {
+      this.cmClass = cmClass;
+   }
+
+   /**
+    * Get the cmClass.
+    * 
+    * @return the cmClass.
+    */
+   public String getCmClass()
+   {
+      if (cmClass == null || cmClass.equals(""))
+         cmClass = "MyConnectionManager";
+      return cmClass;
+   }
+
+   /**
+    * Set the referenceClass.
+    * 
+    * @param referenceClass The referenceClass to set.
+    */
+   public void setReferenceClass(String referenceClass)
+   {
+      this.referenceClass = referenceClass;
+   }
+
+   /**
+    * Get the referenceClass.
+    * 
+    * @return the referenceClass.
+    */
+   public String getReferenceClass()
+   {
+      if (referenceClass == null || referenceClass.equals(""))
+         referenceClass = "MyReference";
+      return referenceClass;
+   }
+
 }

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16AnnoProfile.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16AnnoProfile.java	2010-05-10 03:51:31 UTC (rev 104593)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16AnnoProfile.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -54,6 +54,11 @@
       generateClassCode(def, "Mc");
       generateClassCode(def, "ConnInterface");
       generateClassCode(def, "ConnImpl");
+      generateClassCode(def, "CciConn");
+      generateClassCode(def, "CciConnFactory");
+      generateClassCode(def, "McMeta");
+      generateClassCode(def, "Cm");
+      generateClassCode(def, "Reference");
    }
 
    /**

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McCodeGen.java	2010-05-10 03:51:31 UTC (rev 104593)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -35,7 +35,7 @@
 {
 
    /**
-    * Output ResourceAdapater class
+    * Output class
     * @param def definition
     * @param out Writer
     * @throws IOException ioException
@@ -286,7 +286,7 @@
       out.write("log.debug(\"call getMetaData\");");
       writeEol(out);
       writeIndent(out, indent + 1);
-      out.write("return null;");
+      out.write("return new MyConnectionMetaData();");
       writeRightCurlyBracket(out, indent);
       writeEol(out);
    }

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McMetaCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McMetaCodeGen.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McMetaCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.io.IOException;
+import java.io.Writer;
+
+/**
+ * A managed connection MetaData class CodeGen.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class McMetaCodeGen extends AbstractCodeGen
+{
+   /**
+    * Output ResourceAdapater class
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeClassBody(Definition def, Writer out) throws IOException
+   {
+
+      out.write("public class " + getClassName(def) + " implements ManagedConnectionMetaData");
+      writeLeftCurlyBracket(out, 0);
+      int indent = 1;
+
+      writeEIS(def, out, indent);
+      writeMaxConnection(def, out, indent);
+      writeUsername (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);
+      out.write("import javax.resource.ResourceException;");
+      writeEol(out);
+      writeEol(out);
+      out.write("import javax.resource.spi.ManagedConnectionMetaData;");
+      writeEol(out);
+      writeEol(out);
+   }
+   
+   /**
+    * get this class name
+    * @param def definition
+    * @return String class name
+    */
+   @Override
+   public String getClassName(Definition def)
+   {
+      return def.getMcMetaClass();
+   }
+   
+   /**
+    * Output close method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeEIS(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public String getEISProductName() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+      writeIndent(out, indent + 1);
+      out.write("return null; //TODO");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+      
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public String getEISProductVersion() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+      writeIndent(out, indent + 1);
+      out.write("return null; //TODO");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+
+   /**
+    * Output Interaction method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeMaxConnection(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public int getMaxConnections() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return 0; //TODO");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+   
+   /**
+    * Output LocalTransaction method
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeUsername(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("@Override");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("public String getUserName() throws ResourceException");
+      writeLeftCurlyBracket(out, indent);
+
+      writeIndent(out, indent + 1);
+      out.write("return null; //TODO");
+      writeRightCurlyBracket(out, indent);
+      writeEol(out);
+   }
+}

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McfCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McfCodeGen.java	2010-05-10 03:51:31 UTC (rev 104593)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McfCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -35,7 +35,7 @@
 {
 
    /**
-    * Output ResourceAdapater class
+    * Output class
     * @param def definition
     * @param out Writer
     * @throws IOException ioException
@@ -187,7 +187,7 @@
       out.write("log.debug(\"call createConnectionFactory\");");
       writeEol(out);
       writeIndent(out, indent + 1);
-      out.write("return null;");
+      out.write("return new MyCciConnectionFactory();");
       writeRightCurlyBracket(out, indent);
       writeEol(out);
       
@@ -200,11 +200,9 @@
       writeIndent(out, indent + 2);
       out.write("throw new IllegalStateException(\"RA is null\");");
       writeEol(out);
+
       writeIndent(out, indent + 1);
-      out.write("log.debug(\"call createConnectionFactory\");");
-      writeEol(out);
-      writeIndent(out, indent + 1);
-      out.write("return null;");
+      out.write("return createConnectionFactory(new MyConnectionManager());");
       writeRightCurlyBracket(out, indent);
       writeEol(out);
    }

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ReferenceCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ReferenceCodeGen.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ReferenceCodeGen.java	2010-05-10 04:00:03 UTC (rev 104594)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.io.IOException;
+import java.io.Writer;
+
+/**
+ * A connection impl class CodeGen.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class ReferenceCodeGen extends AbstractCodeGen
+{
+
+   /**
+    * Output ResourceAdapater class
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeClassBody(Definition def, Writer out) throws IOException
+   {
+
+      out.write("public class " + getClassName(def) + " extends Reference");
+      writeLeftCurlyBracket(out, 0);
+      int indent = 1;
+      
+      //constructor
+      writeIndent(out, indent);
+      out.write("public " + getClassName(def) + "(String className)");
+      writeLeftCurlyBracket(out, indent);
+      writeIndent(out, indent + 1);
+      out.write("super(className);");
+      writeRightCurlyBracket(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);
+      out.write("import javax.naming.Reference;");
+      writeEol(out);
+      writeEol(out);
+   }
+   
+   /**
+    * get this class name
+    * @param def definition
+    * @return String class name
+    */
+   @Override
+   public String getClassName(Definition def)
+   {
+      return def.getReferenceClass();
+   }
+}




More information about the jboss-cvs-commits mailing list