[jboss-cvs] JBossAS SVN: r105828 - in projects/jboss-jca/trunk/codegenerator/src/main: java/org/jboss/jca/codegenerator/xml and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 8 20:47:23 EDT 2010


Author: jeff.zhang
Date: 2010-06-08 20:47:22 -0400 (Tue, 08 Jun 2010)
New Revision: 105828

Added:
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA10Profile.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/Ra10XmlGen.java
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/xml/RaXmlGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
Log:
JBJCA-349] Profile 1.0 code generation

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA10Profile.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA10Profile.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA10Profile.java	2010-06-09 00:47:22 UTC (rev 105828)
@@ -0,0 +1,68 @@
+/*
+ * 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 org.jboss.jca.codegenerator.xml.Ra10XmlGen;
+import org.jboss.jca.codegenerator.xml.RaXmlGen;
+
+/**
+ * A JCA10Profile.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class JCA10Profile extends BaseProfile
+{
+
+   /**
+    * JCA10Profile
+    */
+   public JCA10Profile()
+   {
+   }
+   
+  
+   /**
+    * generate code
+    * @param def Definition 
+    */
+   @Override
+   public void generate(Definition def)
+   {
+      generateOutboundCode(def);
+
+      generateAntXml(def.getOutputDir());
+      generateRaXml(def, def.getOutputDir());
+   }
+
+
+   /**
+    * get right profile ra xmlGen
+    * @param def Definition
+    * @return RaXmlGen profile ra xmlGen
+    */
+   @Override
+   RaXmlGen getRaXmlGen(Definition def)
+   {
+      return new Ra10XmlGen();
+   }
+}

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-06-09 00:00:10 UTC (rev 105827)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java	2010-06-09 00:47:22 UTC (rev 105828)
@@ -102,31 +102,32 @@
             if (version == null || version.equals(""))
                version = "1.6";
          }
-         while (!(version.equals("1.6") || version.equals("1.5")));
+         while (!(version.equals("1.6") || version.equals("1.5") || version.equals("1.0")));
          
+         //by default, support outbound, but not inbound
+         def.setSupportOutbound(true);
+         def.setSupportInbound(false);
+         
          //bound
-         System.out.print(dbconf.getString("support.bound"));
-         String bound = in.readLine();
-         if (bound == null || bound.equals("") || bound.equals("O") || bound.equals("o") || bound.equals("Outbound"))
+         if (!version.equals("1.0"))
          {
-            def.setSupportOutbound(true);
-            def.setSupportInbound(false);
+            System.out.print(dbconf.getString("support.bound"));
+            String bound = in.readLine();
+            if (bound == null || bound.equals("") || bound.equals("O") || bound.equals("o") || bound.equals("Outbound"))
+            {
+               //keep default bound 
+            }
+            else if (bound.equals("I") || bound.equals("i") || bound.equals("Inbound"))
+            {
+               def.setSupportOutbound(false);
+               def.setSupportInbound(true);
+            }
+            else if (bound.equals("B") || bound.equals("b") || bound.equals("Bidirectional"))
+            {
+               def.setSupportOutbound(true);
+               def.setSupportInbound(true);
+            }
          }
-         else if (bound.equals("I") || bound.equals("i") || bound.equals("Inbound"))
-         {
-            def.setSupportOutbound(false);
-            def.setSupportInbound(true);
-         }
-         else if (bound.equals("B") || bound.equals("b") || bound.equals("Bidirectional"))
-         {
-            def.setSupportOutbound(true);
-            def.setSupportInbound(true);
-         }
-         else
-         {
-            def.setSupportOutbound(true);
-            def.setSupportInbound(false);
-         }
          
          //package name
          System.out.print(dbconf.getString("package.name"));
@@ -168,6 +169,10 @@
                   def.setUseRa(true);
             }
          }
+         else if (version.equals("1.0"))
+         {
+            def.setUseRa(false);
+         }
          else
          {
             def.setUseRa(true);
@@ -264,10 +269,14 @@
          {
             profile = new JCA16Profile();
          }
-         else
+         else if (version.equals("1.5"))
          {
             profile = new JCA15Profile();
          }
+         else
+         {
+            profile = new JCA10Profile();
+         }
          profile.generate(def);
          
          System.out.println(dbconf.getString("code.wrote"));

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/Ra10XmlGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/Ra10XmlGen.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/Ra10XmlGen.java	2010-06-09 00:47:22 UTC (rev 105828)
@@ -0,0 +1,164 @@
+/*
+ * 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.xml;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A Ra Xml Gen.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class Ra10XmlGen extends RaXmlGen
+{
+   /**
+    * Output xml
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
+   @Override
+   public void writeXmlBody(Definition def, Writer out) throws IOException
+   {
+      writeConnectorVersion(out);
+      
+      int indent = 1;
+      writeIndent(out, indent);
+      out.write("<display-name>Display Name</display-name>");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("<vendor-name>Red Hat Middleware LLC</vendor-name>");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("<spec-version>1.0</spec-version>");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("<eis-type>Test RA</eis-type>");
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("<version>0.1</version>");
+      writeEol(out);
+
+      writeIndent(out, indent);
+      out.write("<resourceadapter>");
+      writeEol(out);
+
+      writeOutbound(def, out, indent + 1);
+      
+      writeIndent(out, indent);
+      out.write("</resourceadapter>");
+      writeEol(out);
+      out.write("</connector>");
+      writeEol(out);
+   }
+   
+   /**
+    * write Connector Version
+    * 
+    * @param out output writer
+    * @throws IOException io exception
+    */
+   @Override
+   void writeConnectorVersion(Writer out) throws IOException
+   {
+      out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+      writeEol(out);
+      writeEol(out);
+      out.write("<!DOCTYPE connector PUBLIC");
+      writeEol(out);
+      out.write(" \"-//Sun Microsystems, Inc.//DTD Connector 1.0//EN\"");
+      writeEol(out);
+      out.write(" \"http://java.sun.com/dtd/connector_1_0.dtd\">");
+      writeEol(out);
+      writeEol(out);
+      out.write("<connector>");
+      writeEol(out);
+   }
+   
+   /**
+    * Output outbound xml part
+    * @param def definition
+    * @param out Writer
+    * @param indent space number
+    * @throws IOException ioException
+    */
+   private void writeOutbound(Definition def, Writer out, int indent) throws IOException
+   {
+      writeIndent(out, indent);
+      out.write("<managedconnectionfactory-class>" + def.getRaPackage() + "." + 
+         def.getMcfClass() + "</managedconnectionfactory-class>");
+      writeEol(out);
+      writeEol(out);
+
+      if (!def.isUseCciConnection())
+      {
+         writeIndent(out, indent);
+         out.write("<connectionfactory-interface>" + def.getRaPackage() + "." + 
+            def.getCfInterfaceClass() + "</connectionfactory-interface>");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." + 
+            def.getCfClass() + "</connectionfactory-impl-class>");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write("<connection-interface>" + def.getRaPackage() + "." + 
+            def.getConnInterfaceClass() + "</connection-interface>");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write("<connection-impl-class>" + def.getRaPackage() + "." + 
+            def.getConnImplClass() + "</connection-impl-class>");
+         writeEol(out);
+      }
+      else
+      {
+         writeIndent(out, indent);
+         out.write("<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." + 
+            def.getCciConnFactoryClass() + "</connectionfactory-impl-class>");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write("<connection-interface>javax.resource.cci.Connection</connection-interface>");
+         writeEol(out);
+         writeIndent(out, indent);
+         out.write("<connection-impl-class>" + def.getRaPackage() + "." + 
+            def.getCciConnClass() + "</connection-impl-class>");
+         writeEol(out);
+      }
+
+      writeEol(out);
+      writeIndent(out, indent);
+      out.write("<transaction-support>NoTransaction</transaction-support>");
+      writeEol(out);
+      
+      writeConfigPropsXml(def.getMcfConfigProps(), out, indent, false);
+      
+      writeIndent(out, indent);
+      out.write("<reauthentication-support>false</reauthentication-support>");
+      writeEol(out);
+   }
+}

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	2010-06-09 00:00:10 UTC (rev 105827)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java	2010-06-09 00:47:22 UTC (rev 105828)
@@ -36,6 +36,12 @@
  */
 public abstract class RaXmlGen extends AbstractXmlGen
 {
+   /**
+    * Output xml
+    * @param def definition
+    * @param out Writer
+    * @throws IOException ioException
+    */
    @Override
    public void writeXmlBody(Definition def, Writer out) throws IOException
    {
@@ -96,7 +102,7 @@
     * @param required support required
     * @throws IOException ioException
     */
-   private void writeConfigPropsXml(List<ConfigPropType> props, 
+   void writeConfigPropsXml(List<ConfigPropType> props, 
       Writer out, int indent, boolean required) throws IOException
    {
       if (props == null || props.size() == 0)

Modified: projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties	2010-06-09 00:00:10 UTC (rev 105827)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties	2010-06-09 00:47:22 UTC (rev 105828)
@@ -1,4 +1,4 @@
-profile.version=Profile version: [1.6/1.5] 
+profile.version=Profile version: [1.6/1.5/1.0] 
 support.bound=Support directional: [O/I/B/Outbound/Inbound/Bidirectional]: 
 use.annotation=Use annotation: [Y/N/Yes/No] 
 use.ra=Include a ResourceAdapter [Y/Yes/N/No]: 



More information about the jboss-cvs-commits mailing list