[jboss-cvs] JBossAS SVN: r105713 - 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
Fri Jun 4 05:53:35 EDT 2010
Author: jeff.zhang
Date: 2010-06-04 05:53:32 -0400 (Fri, 04 Jun 2010)
New Revision: 105713
Added:
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16Profile.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AbstractCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AsCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CciConnCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CciConnFactoryCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CfCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CfInterfaceCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CmCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnImplCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnInterfaceCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnMetaCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnSpecCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McMetaCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McfCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/MlCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/PropsCodeGen.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/code/RaMetaCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/package.html
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/AbstractXmlGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/BuildXmlGen.java
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/package.html
Removed:
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractXmlGen.java
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/BuildXmlGen.java
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/CfCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfInterfaceCodeGen.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/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/ConnMetaCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnSpecCodeGen.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/McMetaCodeGen.java
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/MlCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaMetaCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaXmlGen.java
Modified:
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BaseGen.java
projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java
projects/jboss-jca/trunk/codegenerator/src/test/java/org/jboss/jca/codegenerator/JCA16AnnoProfileTestCase.java
Log:
[JBJCA-309] refactor for different profile
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,244 +0,0 @@
-/*
- * 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;
-import java.util.Locale;
-
-/**
- * Abstract CodeGenerator.
- *
- * @author Jeff Zhang
- * @version $Revision:$
- */
-public abstract class AbstractCodeGen extends BaseGen
-{
- /**
- * generate code
- * @param def Definition
- * @param out Writer
- * @throws IOException ioException
- */
- public void generate(Definition def, Writer out) throws IOException
- {
- writeheader(def, out);
- writeImport(def, out);
- writeClassComment(def, out);
- writeClassBody(def, out);
- }
-
-
- /**
- * Output class comment
- * @param def definition
- * @param out Writer
- * @throws IOException ioException
- */
- void writeClassComment(Definition def, Writer out) throws IOException
- {
- out.write("/**");
- writeEol(out);
- out.write(" * " + getClassName(def));
- writeEol(out);
- out.write(" *");
- writeEol(out);
- out.write(" * @version $Revision: $");
- writeEol(out);
- out.write(" */");
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- public abstract String getClassName(Definition def);
-
- /**
- * Output class import
- * @param def definition
- * @param out Writer
- * @throws IOException ioException
- */
- public abstract void writeImport(Definition def, Writer out) throws IOException;
-
-
- /**
- * Output class
- * @param def definition
- * @param out Writer
- * @throws IOException ioException
- */
- public abstract void writeClassBody(Definition def, Writer out) throws IOException;
-
- /**
- * Output left curly bracket
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- void writeLeftCurlyBracket(Writer out, int indent) throws IOException
- {
- writeEol(out);
- writeIndent(out, indent);
- out.write("{");
- writeEol(out);
- }
-
- /**
- * Output right curly bracket
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- void writeRightCurlyBracket(Writer out, int indent) throws IOException
- {
- writeEol(out);
- writeIndent(out, indent);
- out.write("}");
- writeEol(out);
- }
-
- /**
- * Output Default Constructor
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- void writeDefaultConstructor(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * default constructor");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- //constructor
- writeIndent(out, indent);
- out.write("public " + getClassName(def) + "()");
- writeLeftCurlyBracket(out, indent);
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Upcase first letter
- * @param name string
- * @return String name string
- */
- String upcaseFirst(String name)
- {
- StringBuilder sb = new StringBuilder();
- sb.append(name.substring(0, 1).toUpperCase(Locale.ENGLISH));
- sb.append(name.substring(1));
- return sb.toString();
- }
-
-
- /**
- * Output hashCode method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- void writeHashCode(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/** ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns a hash code value for the object.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return a hash code value for this object.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public int hashCode()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return 42;");
-
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
-
- /**
- * Output equals method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- void writeEquals(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/** ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Indicates whether some other object is equal to this one.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param other the reference object with which to compare.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return true if this object is the same as the obj argument; false otherwise.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public boolean equals(Object other)");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("if (other == null)");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("return false;");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return getClass().equals(other.getClass());");
-
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractXmlGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractXmlGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractXmlGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,53 +0,0 @@
-/*
- * 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 AbstractXmlGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public abstract class AbstractXmlGen extends BaseGen
-{
- /**
- * generate code
- * @param def Definition
- * @param out Writer
- * @throws IOException ioException
- */
- public void generate(Definition def, Writer out) throws IOException
- {
- writeXmlBody(def, out);
- }
-
- /**
- * Output xml
- * @param def definition
- * @param out Writer
- * @throws IOException ioException
- */
- public abstract void writeXmlBody(Definition def, Writer out) throws IOException;
-}
Deleted: 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-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AsCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,242 +0,0 @@
-/*
- * 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;
-import java.util.List;
-
-/**
- * A ActivationSpec CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class AsCodeGen extends PropsCodeGen
-{
-
- /**
- * 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("@Activation(messageListeners = {" + def.getRaPackage() + "." + def.getMlClass() + ".class})");
- writeEol(out);
- }
- out.write("public class " + getClassName(def) + " implements ActivationSpec");
- writeLeftCurlyBracket(out, 0);
- writeEol(out);
-
- int indent = 1;
- writeIndent(out, indent);
- out.write("/** The logger */");
- writeEol(out);
- writeIndent(out, indent);
- 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);
-
- 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 java.io.PrintWriter;");
- writeEol(out);
- writeEol(out);
- out.write("import javax.resource.ResourceException;");
- writeEol(out);
- out.write("import javax.resource.spi.Activation;");
- 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;");
- writeEol(out);
- writeEol(out);
- out.write("import org.jboss.logging.Logger;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getAsClass();
- }
-
- /**
- * 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
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeValidate(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * This method may be called by a deployment tool to validate the overall");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * activation configuration information provided by the endpoint deployer.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws InvalidPropertyException indicates invalid onfiguration property settings.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void validate() throws InvalidPropertyException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call validate\");");
-
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output ResourceAdapter method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeResourceAdapter(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Get the resource adapter");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return The handle");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public ResourceAdapter getResourceAdapter()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getResourceAdapter\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return ra;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Set the resource adapter");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param ra The handle");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void setResourceAdapter(ResourceAdapter ra)");
- 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/BaseGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BaseGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BaseGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -38,7 +38,7 @@
* @param out Writer
* @throws IOException ioException
*/
- void writeEol(Writer out) throws IOException
+ public void writeEol(Writer out) throws IOException
{
out.write("\n");
}
@@ -49,7 +49,7 @@
* @param indent space number
* @throws IOException ioException
*/
- void writeIndent(Writer out, int indent) throws IOException
+ public void writeIndent(Writer out, int indent) throws IOException
{
for (int i = 0; i < indent; i++)
out.write(" ");
@@ -61,7 +61,7 @@
* @param out Writer
* @throws IOException ioException
*/
- void writeheader(Definition def, Writer out) throws IOException
+ public void writeheader(Definition def, Writer out) throws IOException
{
URL headerFile = BaseGen.class.getResource("/header.template");
String headerString = Utils.readFileIntoString(headerFile);
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BuildXmlGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BuildXmlGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BuildXmlGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,50 +0,0 @@
-/*
- * 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;
-import java.net.URL;
-
-/**
- * A BuildXmlGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class BuildXmlGen extends AbstractXmlGen
-{
- @Override
- public void writeXmlBody(Definition def, Writer out) throws IOException
- {
- out.write("<!--");
- writeEol(out);
- writeheader(def, out);
- out.write("-->");
- writeEol(out);
- writeEol(out);
-
- URL buildFile = BuildXmlGen.class.getResource("/build.xml.template");
- String buildString = Utils.readFileIntoString(buildFile);
- out.write(buildString);
- }
-}
Deleted: 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 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,334 +0,0 @@
-/*
- * 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;
-
- writeDefaultConstructor(def, out, indent);
-
- //constructor
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * default constructor");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param connSpec ConnectionSpec");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public " + getClassName(def) + "(ConnectionSpec connSpec)");
- writeLeftCurlyBracket(out, indent);
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- 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.ConnectionSpec;");
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Initiates close of the connection handle at the application level.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Exception thrown if close on a connection handle fails.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Creates an Interaction associated with this Connection. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Interaction instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to create an Interaction");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns an LocalTransaction instance that enables a component to ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * demarcate resource manager local transactions on the Connection.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return LocalTransaction instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to return a LocalTransaction");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws javax.resource.NotSupportedException Demarcation of Resource manager ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets the information on the underlying EIS instance represented through an active connection.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return ConnectionMetaData instance representing information about the EIS instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to get information about the connected EIS instance. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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 new " + def.getConnMetaClass() + "();");
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets the information on the ResultSet functionality supported by ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * a connected EIS instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return ResultSetInfo instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to get ResultSet related information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws javax.resource.NotSupportedException ResultSet functionality is not supported");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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);
- }
-}
Deleted: 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 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CciConnFactoryCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,352 +0,0 @@
-/*
- * 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);
-
- writeDefaultConstructor(def, out, indent);
-
- //constructor
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * default constructor");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param cxManager ConnectionManager");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public " + getClassName(def) + "(ConnectionManager cxManager)");
- writeLeftCurlyBracket(out, indent);
- writeRightCurlyBracket(out, indent);
- 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);
- out.write("import javax.resource.spi.ConnectionManager;");
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets a connection to an EIS instance. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Connection instance the EIS instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to get a connection to");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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 " + def.getCciConnClass() + "(new " + def.getConnSpecClass() + "());");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets a connection to an EIS instance. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param connSpec Connection parameters and security information specified as " +
- "ConnectionSpec instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Connection instance the EIS instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to get a connection to");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public Connection getConnection(ConnectionSpec connSpec) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
-
- writeIndent(out, indent + 1);
- out.write("return new " + def.getCciConnClass() + "(connSpec);");
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets metadata for the Resource Adapter. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return ResourceAdapterMetaData instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to get metadata information ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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 new " + def.getRaMetaClass() + "();");
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets a RecordFactory instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return RecordFactory instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to create a RecordFactory");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws javax.resource.NotSupportedException Operation not supported");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Get the Reference instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Reference instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public Reference getReference() throws NamingException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return reference;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Set the Reference instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param reference A Reference instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- 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);
- }
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,222 +0,0 @@
-/*
- * 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 factory class CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class CfCodeGen 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 " + def.getCfInterfaceClass());
- writeLeftCurlyBracket(out, 0);
- int indent = 1;
-
- writeIndent(out, indent);
- out.write("private Reference reference;");
- writeEol(out);
- writeEol(out);
-
- writeDefaultConstructor(def, out, indent);
-
- //constructor
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * default constructor");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param cxManager ConnectionManager");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public " + getClassName(def) + "(ConnectionManager cxManager)");
- writeLeftCurlyBracket(out, indent);
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeConnection(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 java.io.Serializable;");
- 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.Referenceable;");
- writeEol(out);
- out.write("import javax.resource.ResourceException;");
- writeEol(out);
- out.write("import javax.resource.spi.ConnectionManager;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getCfClass();
- }
-
- /**
- * 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("/** ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * get connection from factory");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return " + def.getConnInterfaceClass() + " instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public " + def.getConnInterfaceClass() + " getConnection() throws ResourceException");
- writeLeftCurlyBracket(out, indent);
-
- writeIndent(out, indent + 1);
- out.write("return new " + def.getConnImplClass() + "();");
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Get the Reference instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Reference instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public Reference getReference() throws NamingException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return reference;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Set the Reference instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param reference A Reference instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- 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);
- }
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfInterfaceCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfInterfaceCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfInterfaceCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,115 +0,0 @@
-/*
- * 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 factory interface CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class CfInterfaceCodeGen 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 interface " + getClassName(def) + " extends Serializable, Referenceable");
- writeLeftCurlyBracket(out, 0);
- int indent = 1;
-
- writeConnection(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 java.io.Serializable;");
- writeEol(out);
- writeEol(out);
- out.write("import javax.resource.Referenceable;");
- writeEol(out);
- out.write("import javax.resource.ResourceException;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getCfInterfaceClass();
- }
-
- /**
- * 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("/** ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * get connection from factory");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return " + def.getConnInterfaceClass() + " instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public " + def.getConnInterfaceClass() + " getConnection() throws ResourceException;");
- writeEol(out);
- }
-}
Deleted: 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 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CmCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,136 +0,0 @@
-/*
- * 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;
-
- writeDefaultConstructor(def, out, indent);
-
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Allocate a connection");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param mcf The managed connection factory");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param cri The connection request information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Object The connection");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @exception ResourceException Thrown if an error occurs");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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);
- }
-}
Deleted: 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-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnImplCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,106 +0,0 @@
-/*
- * 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 ConnImplCodeGen extends AbstractCodeGen
-{
-
- /**
- * Output 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 " + def.getConnInterfaceClass());
- writeLeftCurlyBracket(out, 0);
- int indent = 1;
- writeIndent(out, indent);
- out.write("/** The logger */");
- writeEol(out);
- writeIndent(out, indent);
- out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
- writeEol(out);
- writeEol(out);
-
- writeDefaultConstructor(def, out, indent);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * call me");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void callMe()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call callMe\");");
-
- 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 org.jboss.logging.Logger;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getConnImplClass();
- }
-}
Deleted: 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-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnInterfaceCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,90 +0,0 @@
-/*
- * 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 interface CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class ConnInterfaceCodeGen extends AbstractCodeGen
-{
-
- /**
- * Output class
- * @param def definition
- * @param out Writer
- * @throws IOException ioException
- */
- @Override
- public void writeClassBody(Definition def, Writer out) throws IOException
- {
- int indent = 1;
-
- out.write("public interface " + getClassName(def));
- writeLeftCurlyBracket(out, 0);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * call me");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void callMe();");
-
- 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.getConnInterfaceClass();
- }
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnMetaCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnMetaCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnMetaCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,198 +0,0 @@
-/*
- * 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 MetaData class CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class ConnMetaCodeGen extends AbstractCodeGen
-{
- /**
- * Output Metadata 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 ConnectionMetaData");
- writeLeftCurlyBracket(out, 0);
- int indent = 1;
-
- writeDefaultConstructor(def, out, indent);
-
- writeEIS(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.cci.ConnectionMetaData;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getConnMetaClass();
- }
-
- /**
- * Output eis info 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns product name of the underlying EIS instance connected");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Product name of the EIS instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to get the information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns product version of the underlying EIS instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Product version of the EIS instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to get the information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- 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 username 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns the user name for an active connection as known to the underlying EIS instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return String representing the user name");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Failed to get the information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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);
- }
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnSpecCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnSpecCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnSpecCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,82 +0,0 @@
-/*
- * 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 Spec class CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class ConnSpecCodeGen extends AbstractCodeGen
-{
- /**
- * Output connection Spec 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 ConnectionSpec");
- writeLeftCurlyBracket(out, 0);
- int indent = 1;
-
- writeDefaultConstructor(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.cci.ConnectionSpec ;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getConnSpecClass();
- }
-
-}
Deleted: 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-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16AnnoProfile.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,116 +0,0 @@
-/*
- * 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.FileWriter;
-import java.io.IOException;
-
-/**
- * A JCA16AnnoProfile.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class JCA16AnnoProfile implements Profile
-{
-
- /**
- * JCA16AnnoProfile
- */
- public JCA16AnnoProfile()
- {
- }
-
-
- /**
- * generate code
- * @param def Definition
- * @param packageName the writer to output the text to.
- */
- @Override
- public void generate(Definition def, String packageName)
- {
- generateClassCode(def, "Ra");
- generateClassCode(def, "Mcf");
- generateClassCode(def, "Mc");
- generateClassCode(def, "McMeta");
- generateClassCode(def, "Cm");
-
- if (!def.isUseCciConnection())
- {
- generateClassCode(def, "CfInterface");
- generateClassCode(def, "Cf");
- generateClassCode(def, "ConnInterface");
- generateClassCode(def, "ConnImpl");
- }
- else
- {
- generateClassCode(def, "CciConn");
- generateClassCode(def, "CciConnFactory");
- generateClassCode(def, "ConnMeta");
- generateClassCode(def, "RaMeta");
- generateClassCode(def, "ConnSpec");
- }
-
- if (def.isSupportInbound())
- {
- generateClassCode(def, "Ml");
- generateClassCode(def, "As");
- }
- }
-
- /**
- * generate ResourceAdapater code
- * @param def Definition
- * @param packageName the writer to output the text to.
- */
- private void generateClassCode(Definition def, String className)
- {
- if (className == null || className.equals(""))
- return;
-
- try
- {
-
- String clazzName = this.getClass().getPackage().getName() + "." + className + "CodeGen";
- String javaFile = (String)Definition.class.getMethod(
- "get" + className + "Class").invoke(def, (Object[])null) + ".java";
- FileWriter fw = Utils.createSrcFile(javaFile, def.getRaPackage(), def.getOutputDir());
-
- Class<?> clazz = Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader());
- AbstractCodeGen codeGen = (AbstractCodeGen)clazz.newInstance();
-
- codeGen.generate(def, fw);
-
- fw.flush();
- fw.close();
- }
- catch (IOException ioe)
- {
- ioe.printStackTrace();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16Profile.java (from rev 105690, 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/JCA16Profile.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/JCA16Profile.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,166 @@
+/*
+ * 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.code.AbstractCodeGen;
+import org.jboss.jca.codegenerator.xml.BuildXmlGen;
+import org.jboss.jca.codegenerator.xml.RaXmlGen;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * A JCA16Profile.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class JCA16Profile implements Profile
+{
+
+ /**
+ * JCA16Profile
+ */
+ public JCA16Profile()
+ {
+ }
+
+
+ /**
+ * generate code
+ * @param def Definition
+ * @param packageName the writer to output the text to.
+ */
+ @Override
+ public void generate(Definition def, String packageName)
+ {
+ generateClassCode(def, "Ra");
+ generateClassCode(def, "Mcf");
+ generateClassCode(def, "Mc");
+ generateClassCode(def, "McMeta");
+ generateClassCode(def, "Cm");
+
+ if (!def.isUseCciConnection())
+ {
+ generateClassCode(def, "CfInterface");
+ generateClassCode(def, "Cf");
+ generateClassCode(def, "ConnInterface");
+ generateClassCode(def, "ConnImpl");
+ }
+ else
+ {
+ generateClassCode(def, "CciConn");
+ generateClassCode(def, "CciConnFactory");
+ generateClassCode(def, "ConnMeta");
+ generateClassCode(def, "RaMeta");
+ generateClassCode(def, "ConnSpec");
+ }
+
+ if (def.isSupportInbound())
+ {
+ generateClassCode(def, "Ml");
+ generateClassCode(def, "As");
+ }
+
+ generateAntXml(def.getOutputDir());
+
+ if (!def.isUseAnnotation())
+ generateRaXml(def, def.getOutputDir());
+ }
+
+ /**
+ * generate ResourceAdapater code
+ * @param def Definition
+ * @param packageName the writer to output the text to.
+ */
+ private void generateClassCode(Definition def, String className)
+ {
+ if (className == null || className.equals(""))
+ return;
+
+ try
+ {
+
+ String clazzName = this.getClass().getPackage().getName() + ".code." + className + "CodeGen";
+ String javaFile = (String)Definition.class.getMethod(
+ "get" + className + "Class").invoke(def, (Object[])null) + ".java";
+ FileWriter fw = Utils.createSrcFile(javaFile, def.getRaPackage(), def.getOutputDir());
+
+ Class<?> clazz = Class.forName(clazzName, true, Thread.currentThread().getContextClassLoader());
+ AbstractCodeGen codeGen = (AbstractCodeGen)clazz.newInstance();
+
+ codeGen.generate(def, fw);
+
+ fw.flush();
+ fw.close();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * generate ant build.xml
+ * @param outputDir output directory
+ */
+ private void generateAntXml(String outputDir)
+ {
+ try
+ {
+ //ant build.xml
+ FileWriter antfw = Utils.createFile("build.xml", outputDir);
+ BuildXmlGen bxGen = new BuildXmlGen();
+ bxGen.generate(null, antfw);
+ antfw.close();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+
+ /**
+ * generate ra.xml
+ * @param def Definition
+ * @param outputDir output directory
+ */
+ private void generateRaXml(Definition def, String outputDir)
+ {
+ try
+ {
+ FileWriter rafw = Utils.createFile("ra.xml", outputDir + File.separatorChar + "META-INF");
+ RaXmlGen raGen = new RaXmlGen();
+ raGen.generate(def, rafw);
+ rafw.close();
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+}
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-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -22,8 +22,6 @@
package org.jboss.jca.codegenerator;
import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
@@ -113,7 +111,7 @@
String raClassName = in.readLine();
- Profile profile = new JCA16AnnoProfile();
+ Profile profile = new JCA16Profile();
def.setRaPackage(packageName);
def.setRaClass(raClassName);
@@ -200,11 +198,6 @@
profile.generate(def, packageName);
- generateAntXml(outputDir);
-
- if (!def.isUseAnnotation())
- generateRaXml(def, outputDir);
-
System.out.println(dbconf.getString("code.wrote"));
}
catch (IOException e)
@@ -282,34 +275,6 @@
}
/**
- * generate ant build.xml
- * @param outputDir output directory
- * @throws IOException ioException
- */
- private static void generateAntXml(String outputDir) throws IOException
- {
- //ant build.xml
- FileWriter antfw = Utils.createFile("build.xml", outputDir);
- BuildXmlGen bxGen = new BuildXmlGen();
- bxGen.generate(null, antfw);
- antfw.close();
- }
-
- /**
- * generate ra.xml
- * @param def Definition
- * @param outputDir output directory
- * @throws IOException ioException
- */
- private static void generateRaXml(Definition def, String outputDir) throws IOException
- {
- FileWriter rafw = Utils.createFile("ra.xml", outputDir + File.separatorChar + "META-INF");
- RaXmlGen raGen = new RaXmlGen();
- raGen.generate(def, rafw);
- rafw.close();
- }
-
- /**
* Tool usage
*/
private static void usage()
Deleted: 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-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,498 +0,0 @@
-/*
- * 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 CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class McCodeGen extends AbstractCodeGen
-{
-
- /**
- * Output class
- * @param def definition
- * @param out Writer
- * @throws IOException ioException
- */
- @Override
- public void writeClassBody(Definition def, Writer out) throws IOException
- {
- int indent = 1;
- out.write("public class " + getClassName(def) + " implements ManagedConnection");
- writeLeftCurlyBracket(out, 0);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/** The logger */");
- writeEol(out);
- writeIndent(out, indent);
- out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
- writeEol(out);
- writeEol(out);
-
- writeDefaultConstructor(def, out, indent);
-
- writeConnection(def, out, indent);
- writeLifecycle(def, out, indent);
- writeConnectionEventListener(def, out, indent);
- writeLogWriter(def, out, indent);
- writeTransaction(def, out, indent);
- writeMetaData(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 java.io.PrintWriter;");
- writeEol(out);
- writeEol(out);
- out.write("import javax.resource.ResourceException;");
- writeEol(out);
- out.write("import javax.resource.spi.ConnectionEventListener;");
- writeEol(out);
- out.write("import javax.resource.spi.ConnectionDefinition;");
- writeEol(out);
- out.write("import javax.resource.spi.ConnectionRequestInfo;");
- writeEol(out);
- out.write("import javax.resource.spi.LocalTransaction;");
- writeEol(out);
- out.write("import javax.resource.spi.ManagedConnection;");
- writeEol(out);
- out.write("import javax.resource.spi.ManagedConnectionMetaData;");
- writeEol(out);
- writeEol(out);
- out.write("import javax.security.auth.Subject;");
- writeEol(out);
- out.write("import javax.transaction.xa.XAResource;");
- writeEol(out);
- writeEol(out);
- out.write("import org.jboss.logging.Logger;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getMcClass();
- }
-
- /**
- * 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Creates a new connection handle for the underlying physical connection ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * represented by the ManagedConnection instance. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param subject security context as JAAS subject");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param cxRequestInfo ConnectionRequestInfo instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return generic Object instance representing the connection handle. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public Object getConnection(Subject subject,");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("ConnectionRequestInfo cxRequestInfo) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getConnection\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return null;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Used by the container to change the association of an ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * application-level connection handle with a ManagedConneciton instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param connection Application-level connection handle");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void associateConnection(Object connection) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call associateConnection\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output Lifecycle method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeLifecycle(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Application server calls this method to force any cleanup on the ManagedConnection instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void cleanup() throws ResourceException");
- writeEol(out);
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call cleanup\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Destroys the physical connection to the underlying resource manager.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void destroy() throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call destroy\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output ConnectionEventListener method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeConnectionEventListener(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Adds a connection event listener to the ManagedConnection instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param listener a new ConnectionEventListener to be registered");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void addConnectionEventListener(ConnectionEventListener listener)");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call addConnectionEventListener\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Removes an already registered connection event listener from the ManagedConnection instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param listener already registered connection event listener to be removed");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void removeConnectionEventListener(ConnectionEventListener listener)");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call removeConnectionEventListener\");");
-
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
- /**
- * Output LogWriter method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeLogWriter(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets the log writer for this ManagedConnection instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Character ourput stream associated with this Managed-Connection instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public PrintWriter getLogWriter() throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getLogWriter\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return null;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Sets the log writer for this ManagedConnection instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param out Character Output stream to be associated");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void setLogWriter(PrintWriter out) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call setLogWriter\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output Transaction method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeTransaction(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns an <code>javax.resource.spi.LocalTransaction</code> instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return LocalTransaction instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public LocalTransaction getLocalTransaction() throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getLocalTransaction\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return null;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns an <code>javax.transaction.xa.XAresource</code> instance. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return XAResource instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public XAResource getXAResource() throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getXAResource\");");
- writeEol(out);
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets the metadata information for this connection's underlying EIS resource manager instance. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return ManagedConnectionMetaData instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception if operation fails");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public ManagedConnectionMetaData getMetaData() throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getMetaData\");");
- writeEol(out);
-
- writeIndent(out, indent + 1);
- out.write("return new " + def.getMcMetaClass() + "();");
-
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-}
Deleted: 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 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McMetaCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,240 +0,0 @@
-/*
- * 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 Metadata 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;
-
- writeDefaultConstructor(def, out, indent);
-
- 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 eis info 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns Product name of the underlying EIS instance connected through the ManagedConnection.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Product name of the EIS instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Thrown if an error occurs");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns Product version of the underlying EIS instance connected through the ManagedConnection.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Product version of the EIS instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Thrown if an error occurs");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- 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 max connection 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns maximum limit on number of active concurrent connections ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Maximum limit for number of active concurrent connections");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Thrown if an error occurs");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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 username 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("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns name of the user associated with the ManagedConnection instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return name of the user");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Thrown if an error occurs");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- 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);
- }
-}
Deleted: 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-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/McfCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,550 +0,0 @@
-/*
- * 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;
-import java.util.List;
-
-/**
- * A McfCodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class McfCodeGen extends PropsCodeGen
-{
-
- /**
- * Output class
- * @param def definition
- * @param out Writer
- * @throws IOException ioException
- */
- @Override
- public void writeClassBody(Definition def, Writer out) throws IOException
- {
- int indent = 1;
- if (def.isUseAnnotation())
- {
- if (!def.isUseCciConnection())
- {
- out.write("@ConnectionDefinition(connectionFactory = " + def.getCfInterfaceClass() + ".class,");
- writeEol(out);
- writeIndent(out, indent);
- out.write("connectionFactoryImpl = " + def.getCfClass() + ".class,");
- writeEol(out);
- writeIndent(out, indent);
- out.write("connection = " + def.getConnInterfaceClass() + ".class,");
- writeEol(out);
- writeIndent(out, indent);
- out.write("connectionImpl = " + def.getConnImplClass() + ".class)");
- writeEol(out);
- }
- else
- {
- out.write("@ConnectionDefinition(connectionFactory = ConnectionFactory.class,");
- writeEol(out);
- writeIndent(out, indent);
- out.write("connectionFactoryImpl = " + def.getCciConnFactoryClass() + ".class,");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("connection = Connection.class,");
- writeEol(out);
- writeIndent(out, indent);
- out.write("connectionImpl = " + def.getCciConnClass() + ".class)");
- writeEol(out);
- }
- }
-
- out.write("public class " + getClassName(def) + " implements ManagedConnectionFactory");
- if (def.isImplRaAssociation())
- {
- out.write(", ResourceAdapterAssociation");
- }
- writeLeftCurlyBracket(out, 0);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/** The logger */");
- writeEol(out);
- writeIndent(out, indent);
- out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
- writeEol(out);
- writeEol(out);
- if (def.isImplRaAssociation())
- {
- writeIndent(out, indent);
- out.write("/** The resource adapter */");
- writeEol(out);
- writeIndent(out, indent);
- out.write("private ResourceAdapter ra;");
- writeEol(out);
- writeEol(out);
- }
-
- writeIndent(out, indent);
- out.write("/** The logwriter */");
- writeEol(out);
- writeIndent(out, indent);
- out.write("private PrintWriter logwriter;");
- writeEol(out);
- writeEol(out);
-
-
- writeDefaultConstructor(def, out, indent);
-
- writeConfigProps(def, out, indent);
- writeConnectionFactory(def, out, indent);
- writeManagedConnection(def, out, indent);
- writeLogWriter(def, out, indent);
- if (def.isImplRaAssociation())
- {
- writeResourceAdapter(def, out, indent);
- }
-
- writeHashCode(def, out, indent);
- writeEquals(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 java.io.PrintWriter;");
- writeEol(out);
- out.write("import java.util.Set;");
- writeEol(out);
- writeEol(out);
- out.write("import javax.resource.ResourceException;");
- writeEol(out);
-
- if (def.isUseCciConnection())
- {
- out.write("import javax.resource.cci.Connection;");
- writeEol(out);
- out.write("import javax.resource.cci.ConnectionFactory;");
- writeEol(out);
- }
-
- if (def.isUseAnnotation())
- {
- out.write("import javax.resource.spi.ConfigProperty;");
- writeEol(out);
- out.write("import javax.resource.spi.ConnectionDefinition;");
- 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.ManagedConnection;");
- writeEol(out);
- out.write("import javax.resource.spi.ManagedConnectionFactory;");
- writeEol(out);
- out.write("import javax.resource.spi.ResourceAdapter;");
- writeEol(out);
- out.write("import javax.resource.spi.ResourceAdapterAssociation;");
- writeEol(out);
- writeEol(out);
- out.write("import javax.security.auth.Subject;");
- writeEol(out);
- writeEol(out);
- out.write("import org.jboss.logging.Logger;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getMcfClass();
- }
-
- /**
- * get list of ConfigPropType
- * @param def definition
- * @return List<ConfigPropType> List of ConfigPropType
- */
- @Override
- public List<ConfigPropType> getConfigProps(Definition def)
- {
- return def.getMcfConfigProps();
- }
-
- /**
- * Output ConnectionFactory method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeConnectionFactory(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Creates a Connection Factory instance. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param cxManager ConnectionManager to be " +
- "associated with created EIS connection factory instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return EIS-specific Connection Factory instance or " +
- "javax.resource.cci.ConnectionFactory instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Generic exception");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- if (def.isImplRaAssociation())
- {
- writeIfRaNull(out, indent);
- }
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call createConnectionFactory\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- if (def.isUseCciConnection())
- out.write("return new " + def.getCciConnFactoryClass() + "(cxManager);");
- else
- out.write("return new " + def.getCfClass() + "(cxManager);");
-
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Creates a Connection Factory instance. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return EIS-specific Connection Factory instance or " +
- "javax.resource.cci.ConnectionFactory instance");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException Generic exception");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public Object createConnectionFactory() throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- if (def.isImplRaAssociation())
- {
- writeIfRaNull(out, indent);
- }
-
- writeIndent(out, indent + 1);
- if (def.isUseCciConnection())
- out.write("return new " + def.getCciConnFactoryClass() + "(new " + def.getCmClass() + "());");
- else
- {
- out.write("return new " + def.getCfClass() + "(new " + def.getCmClass() + "());");
- }
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output if (ra == null)
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeIfRaNull(Writer out, int indent) throws IOException
- {
- writeIndent(out, indent + 1);
- out.write("if (ra == null)");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("throw new IllegalStateException(\"RA is null\");");
- writeEol(out);
- }
-
- /**
- * Output ConnectionFactory method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeManagedConnection(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Creates a new physical connection to the underlying EIS resource manager.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param subject Caller's security information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param cxRequestInfo Additional resource adapter " +
- "specific connection request information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return ManagedConnection instance ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public ManagedConnection createManagedConnection(Subject subject,");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("ConnectionRequestInfo cxRequestInfo) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- if (def.isImplRaAssociation())
- {
- writeIfRaNull(out, indent);
- }
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call createManagedConnection\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return null;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns a matched connection from the candidate set of connections. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param connectionSet candidate connection set");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param subject Caller's security information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param cxRequestInfo Additional resource adapter " +
- "specific connection request information");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return ManagedConnection if resource adapter finds an acceptable match otherwise null ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public ManagedConnection matchManagedConnections(Set connectionSet,");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- if (def.isImplRaAssociation())
- {
- writeIfRaNull(out, indent);
- }
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call matchManagedConnections\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return null;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
- /**
- * Output LogWriter method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeLogWriter(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Get the log writer for this ManagedConnectionFactory instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return PrintWriter");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public PrintWriter getLogWriter() throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getLogWriter\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return logwriter;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Set the log writer for this ManagedConnectionFactory instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param out PrintWriter - an out stream for error logging and tracing");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void setLogWriter(PrintWriter out) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call setLogWriter\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("logwriter = out;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output ResourceAdapter method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeResourceAdapter(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Get the resource adapter");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return The handle");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public ResourceAdapter getResourceAdapter()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getResourceAdapter\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return ra;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Set the resource adapter");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param ra The handle");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void setResourceAdapter(ResourceAdapter ra)");
- 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);
- }
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/MlCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/MlCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/MlCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,91 +0,0 @@
-/*
- * 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 message listener CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class MlCodeGen extends AbstractCodeGen
-{
-
- /**
- * Output class
- * @param def definition
- * @param out Writer
- * @throws IOException ioException
- */
- @Override
- public void writeClassBody(Definition def, Writer out) throws IOException
- {
- int indent = 1;
- out.write("public interface " + getClassName(def));
- writeLeftCurlyBracket(out, 0);
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * receive message");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param msg String.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void onMessage(String msg);");
-
- 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.getMlClass();
- }
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,274 +0,0 @@
-/*
- * 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;
-import java.util.List;
-
-/**
- * A properties code generator
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public abstract class PropsCodeGen extends AbstractCodeGen
-{
- /**
- * Output Configuration Properties
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- void writeConfigProps(Definition def, Writer out, int indent) throws IOException
- {
- if (getConfigProps(def) == null)
- return;
-
- for (int i = 0; i < getConfigProps(def).size(); i++)
- {
- writeIndent(out, indent);
- out.write("/** " + getConfigProps(def).get(i).getName() + " */");
- writeEol(out);
-
- if (def.isUseAnnotation())
- {
- writeIndent(out, indent);
- out.write("@ConfigProperty(defaultValue=\"" + getConfigProps(def).get(i).getValue() + "\")");
- writeEol(out);
- }
- writeIndent(out, indent);
- out.write("private " +
- getConfigProps(def).get(i).getType() +
- " " +
- getConfigProps(def).get(i).getName() +
- ";");
- writeEol(out);
- writeEol(out);
- }
-
- 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 +
- ")");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("this." + name + " = " + name + ";");
- writeRightCurlyBracket(out, indent);
- 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 +
- "()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return " + name + ";");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
- }
-
- /**
- * Output hashCode method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- @Override
- void writeHashCode(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/** ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns a hash code value for the object.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return a hash code value for this object.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public int hashCode()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("int result = 17;");
- writeEol(out);
- for (int i = 0; i < getConfigProps(def).size(); i++)
- {
- writeIndent(out, indent + 1);
- out.write("if (" + getConfigProps(def).get(i).getName() + " != null)");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("result += 31 * result + 7 * " + getConfigProps(def).get(i).getName() + ".hashCode();");
- writeEol(out);
- writeIndent(out, indent + 1);
-
- out.write("else");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("result += 31 * result + 7;");
- writeEol(out);
- }
- writeIndent(out, indent + 1);
- out.write("return result;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
-
- /**
- * Output equals method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- @Override
- void writeEquals(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/** ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Indicates whether some other object is equal to this one.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param other the reference object with which to compare.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return true if this object is the same as the obj argument; false otherwise.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public boolean equals(Object other)");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("if (other == null)");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("return false;");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("if (other == this)");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("return true;");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("if (!(other instanceof " + getClassName(def) + "))");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("return false;");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write(getClassName(def) + " obj = (" + getClassName(def) + ")other;");
- writeEol(out);
-
- writeIndent(out, indent + 1);
- out.write("boolean result = true; ");
- writeEol(out);
-
- for (int i = 0; i < getConfigProps(def).size(); i++)
- {
- writeIndent(out, indent + 1);
- out.write("if (result)");
- writeLeftCurlyBracket(out, indent + 1);
- writeIndent(out, indent + 2);
- out.write("if (" + getConfigProps(def).get(i).getName() + " == null)");
- writeEol(out);
- writeIndent(out, indent + 3);
- out.write("result = obj.get" + upcaseFirst(getConfigProps(def).get(i).getName()) + "() == null;");
- writeEol(out);
-
- writeIndent(out, indent + 2);
- out.write("else");
- writeEol(out);
- writeIndent(out, indent + 3);
- out.write("result = " + getConfigProps(def).get(i).getName() + ".equals(obj.get" +
- upcaseFirst(getConfigProps(def).get(i).getName()) + "());");
- writeRightCurlyBracket(out, indent + 1);
- }
- writeIndent(out, indent + 1);
- out.write("return result;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * get list of ConfigPropType
- * @param def TODO
- * @return List<ConfigPropType> List of ConfigPropType
- */
- public abstract List<ConfigPropType> getConfigProps(Definition def);
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,317 +0,0 @@
-/*
- * 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;
-import java.util.List;
-
-/**
- * A resource adapter code generator
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class RaCodeGen extends PropsCodeGen
-{
- /**
- * Output ResourceAdapater 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("@Connector");
- writeEol(out);
- }
- out.write("public class " + getClassName(def) + " implements ResourceAdapter");
- writeLeftCurlyBracket(out, 0);
- writeEol(out);
-
- int indent = 1;
- writeIndent(out, indent);
- out.write("/** The logger */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
- writeEol(out);
- writeEol(out);
-
- writeDefaultConstructor(def, out, indent);
-
- writeConfigProps(def, out, indent);
- writeEndpointLifecycle(def, out, indent);
- writeLifecycle(def, out, indent);
- writeXAResource(def, out, indent);
- writeHashCode(def, out, indent);
- writeEquals(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.ActivationSpec;");
- writeEol(out);
- out.write("import javax.resource.spi.BootstrapContext;");
- 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.ResourceAdapter;");
- writeEol(out);
- out.write("import javax.resource.spi.ResourceAdapterInternalException;");
- writeEol(out);
- out.write("import javax.resource.spi.endpoint.MessageEndpointFactory;");
- writeEol(out);
- writeEol(out);
- out.write("import javax.transaction.xa.XAResource;");
- writeEol(out);
- writeEol(out);
- out.write("import org.jboss.logging.Logger;");
- writeEol(out);
- writeEol(out);
- }
-
- /**
- * Output getXAResources method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeXAResource(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * This method is called by the application server during crash recovery.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param specs an array of ActivationSpec JavaBeans ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return an array of XAResource objects");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public XAResource[] getXAResources(ActivationSpec[] specs)");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call getXAResources\");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("return null;");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output Lifecycle method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeLifecycle(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * This is called when a resource adapter instance is bootstrapped.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param ctx a bootstrap context containing references ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceAdapterInternalException indicates bootstrap failure.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void start(BootstrapContext ctx)");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("throws ResourceAdapterInternalException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call start\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * This is called when a resource adapter instance is undeployed or");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * during application server shutdown. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void stop()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call stop\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output EndpointLifecycle method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeEndpointLifecycle(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * This is called during the activation of a message endpoint.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param endpointFactory a message endpoint factory instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param spec an activation spec JavaBean instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @throws ResourceException generic exception ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void endpointActivation(MessageEndpointFactory endpointFactory,");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("ActivationSpec spec) throws ResourceException");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call endpointActivation\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * This is called when a message endpoint is deactivated. ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param endpointFactory a message endpoint factory instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @param spec an activation spec JavaBean instance.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("public void endpointDeactivation(MessageEndpointFactory endpointFactory,");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("ActivationSpec spec)");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("log.debug(\"call endpointDeactivation\");");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * get this class name
- * @param def definition
- * @return String class name
- */
- @Override
- public String getClassName(Definition def)
- {
- return def.getRaClass();
- }
-
- /**
- * get list of ConfigPropType
- * @param def definition
- * @return List<ConfigPropType> List of ConfigPropType
- */
- @Override
- public List<ConfigPropType> getConfigProps(Definition def)
- {
- return def.getRaConfigProps();
- }
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaMetaCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaMetaCodeGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaMetaCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,347 +0,0 @@
-/*
- * 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 resource adapter MetaData class CodeGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class RaMetaCodeGen extends AbstractCodeGen
-{
- /**
- * Output Metadata 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 ResourceAdapterMetaData");
- writeLeftCurlyBracket(out, 0);
- int indent = 1;
-
- writeDefaultConstructor(def, out, indent);
-
- writeInfo(def, out, indent);
- writeSupport (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.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.getRaMetaClass();
- }
-
- /**
- * Output info method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeInfo(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets the version of the resource adapter.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return String representing version of the resource adapter");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public String getAdapterVersion()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return null; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets the name of the vendor that has provided the resource adapter.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return String representing name of the vendor ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public String getAdapterVendorName()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return null; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets a tool displayable name of the resource adapter.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return String representing the name of the resource adapter");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public String getAdapterName()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return null; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Gets a tool displayable short desription of the resource adapter.");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return String describing the resource adapter");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public String getAdapterShortDescription()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return null; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns a string representation of the version");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return String representing the supported version of the connector architecture");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public String getSpecVersion()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return null; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-
- /**
- * Output support method
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeSupport(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns an array of fully-qualified names of InteractionSpec");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return Array of fully-qualified class names of InteractionSpec classes");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public String[] getInteractionSpecsSupported()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return null; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns true if the implementation class for the Interaction");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return boolean depending on method support");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public boolean supportsExecuteWithInputAndOutputRecord()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return false; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns true if the implementation class for the Interaction");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return boolean depending on method support");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public boolean supportsExecuteWithInputRecordOnly()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return false; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("/**");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * Returns true if the resource adapter implements the LocalTransaction");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" *");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" * @return true if resource adapter supports resource manager local transaction demarcation ");
- writeEol(out);
- writeIndent(out, indent);
- out.write(" */");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("@Override");
- writeEol(out);
- writeIndent(out, indent);
- out.write("public boolean supportsLocalTransactionDemarcation()");
- writeLeftCurlyBracket(out, indent);
- writeIndent(out, indent + 1);
- out.write("return false; //TODO");
- writeRightCurlyBracket(out, indent);
- writeEol(out);
- }
-}
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaXmlGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaXmlGen.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaXmlGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -1,256 +0,0 @@
-/*
- * 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;
-import java.util.List;
-
-/**
- * A BuildXmlGen.
- *
- * @author Jeff Zhang
- * @version $Revision: $
- */
-public class RaXmlGen extends AbstractXmlGen
-{
- @Override
- public void writeXmlBody(Definition def, Writer out) throws IOException
- {
- out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- writeEol(out);
- writeEol(out);
- out.write("<connector xmlns=\"http://java.sun.com/xml/ns/javaee\"");
- writeEol(out);
- out.write(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
- writeEol(out);
- out.write(" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee");
- writeEol(out);
- out.write(" http://java.sun.com/xml/ns/j2ee/connector_1_6.xsd\"");
- writeEol(out);
- out.write(" version=\"1.6\" metadata-complete=\"true\">");
- writeEol(out);
- writeEol(out);
- int indent = 1;
- writeIndent(out, indent);
- out.write("<vendor-name>Red Hat Middleware LLC</vendor-name>");
- writeEol(out);
- writeIndent(out, indent);
- out.write("<eis-type>Test RA</eis-type>");
- writeEol(out);
- writeIndent(out, indent);
- out.write("<resourceadapter-version>0.1</resourceadapter-version>");
- writeEol(out);
- writeIndent(out, indent);
- out.write("<resourceadapter>");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("<resourceadapter-class>" + def.getRaPackage() + "." + def.getRaClass() + "</resourceadapter-class>");
- writeEol(out);
-
- writeConfigPropsXml(def.getRaConfigProps(), out, indent + 1, false);
- writeOutbound(def, out, indent + 1);
- if (def.isSupportInbound())
- writeInbound(def, out, indent + 1);
-
- writeIndent(out, indent);
- out.write("</resourceadapter>");
- writeEol(out);
- out.write("</connector>");
- writeEol(out);
- }
-
- /**
- * Output config props xml part
- * @param props config properties
- * @param out Writer
- * @param indent space number
- * @param required support required
- * @throws IOException ioException
- */
- private void writeConfigPropsXml(List<ConfigPropType> props,
- Writer out, int indent, boolean required) throws IOException
- {
- if (props == null || props.size() == 0)
- return;
- if (required)
- {
- for (ConfigPropType prop : props)
- {
- if (prop.isRequired())
- {
- writeIndent(out, indent);
- out.write("<required-config-property>");
- writeEol(out);
-
- writeIndent(out, indent + 1);
- out.write("<config-property-name>" + prop.getName() + "</config-property-name>");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("</required-config-property>");
- writeEol(out);
- }
- }
- writeEol(out);
- }
- else
- {
- for (ConfigPropType prop : props)
- {
- writeIndent(out, indent);
- out.write("<config-property>");
- writeEol(out);
-
- writeIndent(out, indent + 1);
- out.write("<config-property-name>" + prop.getName() + "</config-property-name>");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("<config-property-type>java.lang." + prop.getType() + "</config-property-type>");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("<config-property-value>" + prop.getValue() + "</config-property-value>");
- writeEol(out);
-
- writeIndent(out, indent);
- out.write("</config-property>");
- writeEol(out);
- writeEol(out);
- }
- }
- }
-
- /**
- * Output inbound xml part
- * @param def definition
- * @param out Writer
- * @param indent space number
- * @throws IOException ioException
- */
- private void writeInbound(Definition def, Writer out, int indent) throws IOException
- {
- writeIndent(out, indent);
- out.write("<inbound-resourceadapter>");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("<messageadapter>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("<messagelistener>");
- writeEol(out);
- writeIndent(out, indent + 3);
- out.write("<messagelistener-type>" + def.getRaPackage() + "." + def.getMlClass() + "</messagelistener-type>");
- writeEol(out);
- writeIndent(out, indent + 3);
- out.write("<activationspec>");
- writeEol(out);
- writeIndent(out, indent + 4);
- out.write("<activationspec-class>" + def.getRaPackage() + "." + def.getAsClass() + "</activationspec-class>");
- writeEol(out);
-
- writeConfigPropsXml(def.getAsConfigProps(), out, indent + 4, true);
- writeIndent(out, indent + 3);
- out.write("</activationspec>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("</messagelistener>");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("</messageadapter>");
- writeEol(out);
- writeIndent(out, indent);
- out.write("</inbound-resourceadapter>");
- 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("<outbound-resourceadapter>");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("<connection-definition>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("<managedconnectionfactory-class>" + def.getRaPackage() + "." +
- def.getMcfClass() + "</managedconnectionfactory-class>");
- writeEol(out);
- writeConfigPropsXml(def.getMcfConfigProps(), out, indent + 2, false);
-
- if (!def.isUseCciConnection())
- {
- writeIndent(out, indent + 2);
- out.write("<connectionfactory-interface>" + def.getRaPackage() + "." +
- def.getCfInterfaceClass() + "</connectionfactory-interface>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." +
- def.getCfClass() + "</connectionfactory-impl-class>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("<connection-interface>" + def.getRaPackage() + "." +
- def.getConnInterfaceClass() + "</connection-interface>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("<connection-impl-class>" + def.getRaPackage() + "." +
- def.getConnImplClass() + "</connection-impl-class>");
- writeEol(out);
- }
- else
- {
- writeIndent(out, indent + 2);
- out.write("<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." +
- def.getCciConnFactoryClass() + "</connectionfactory-impl-class>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("<connection-interface>javax.resource.cci.Connection</connection-interface>");
- writeEol(out);
- writeIndent(out, indent + 2);
- out.write("<connection-impl-class>" + def.getRaPackage() + "." +
- def.getCciConnClass() + "</connection-impl-class>");
- writeEol(out);
- }
- writeIndent(out, indent + 1);
- out.write("</connection-definition>");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("<transaction-support>NoTransaction</transaction-support>");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("<reauthentication-support>false</reauthentication-support>");
- writeEol(out);
- writeIndent(out, indent);
- out.write("</outbound-resourceadapter>");
- writeEol(out);
- }
-}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AbstractCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AbstractCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AbstractCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,247 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.BaseGen;
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+
+/**
+ * Abstract CodeGenerator.
+ *
+ * @author Jeff Zhang
+ * @version $Revision:$
+ */
+public abstract class AbstractCodeGen extends BaseGen
+{
+ /**
+ * generate code
+ * @param def Definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ public void generate(Definition def, Writer out) throws IOException
+ {
+ writeheader(def, out);
+ writeImport(def, out);
+ writeClassComment(def, out);
+ writeClassBody(def, out);
+ }
+
+
+ /**
+ * Output class comment
+ * @param def definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ void writeClassComment(Definition def, Writer out) throws IOException
+ {
+ out.write("/**");
+ writeEol(out);
+ out.write(" * " + getClassName(def));
+ writeEol(out);
+ out.write(" *");
+ writeEol(out);
+ out.write(" * @version $Revision: $");
+ writeEol(out);
+ out.write(" */");
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ public abstract String getClassName(Definition def);
+
+ /**
+ * Output class import
+ * @param def definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ public abstract void writeImport(Definition def, Writer out) throws IOException;
+
+
+ /**
+ * Output class
+ * @param def definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ public abstract void writeClassBody(Definition def, Writer out) throws IOException;
+
+ /**
+ * Output left curly bracket
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ void writeLeftCurlyBracket(Writer out, int indent) throws IOException
+ {
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("{");
+ writeEol(out);
+ }
+
+ /**
+ * Output right curly bracket
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ void writeRightCurlyBracket(Writer out, int indent) throws IOException
+ {
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("}");
+ writeEol(out);
+ }
+
+ /**
+ * Output Default Constructor
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ void writeDefaultConstructor(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * default constructor");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ //constructor
+ writeIndent(out, indent);
+ out.write("public " + getClassName(def) + "()");
+ writeLeftCurlyBracket(out, indent);
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Upcase first letter
+ * @param name string
+ * @return String name string
+ */
+ String upcaseFirst(String name)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(name.substring(0, 1).toUpperCase(Locale.ENGLISH));
+ sb.append(name.substring(1));
+ return sb.toString();
+ }
+
+
+ /**
+ * Output hashCode method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ void writeHashCode(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/** ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns a hash code value for the object.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return a hash code value for this object.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public int hashCode()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return 42;");
+
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+
+ /**
+ * Output equals method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ void writeEquals(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/** ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Indicates whether some other object is equal to this one.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param other the reference object with which to compare.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return true if this object is the same as the obj argument; false otherwise.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public boolean equals(Object other)");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("if (other == null)");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("return false;");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return getClass().equals(other.getClass());");
+
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AsCodeGen.java (from rev 105690, 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/code/AsCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/AsCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,245 @@
+/*
+ * 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.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;
+
+/**
+ * A ActivationSpec CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class AsCodeGen extends PropsCodeGen
+{
+
+ /**
+ * 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("@Activation(messageListeners = {" + def.getRaPackage() + "." + def.getMlClass() + ".class})");
+ writeEol(out);
+ }
+ out.write("public class " + getClassName(def) + " implements ActivationSpec");
+ writeLeftCurlyBracket(out, 0);
+ writeEol(out);
+
+ int indent = 1;
+ writeIndent(out, indent);
+ out.write("/** The logger */");
+ writeEol(out);
+ writeIndent(out, indent);
+ 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);
+
+ 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 java.io.PrintWriter;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import javax.resource.ResourceException;");
+ writeEol(out);
+ out.write("import javax.resource.spi.Activation;");
+ 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;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import org.jboss.logging.Logger;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getAsClass();
+ }
+
+ /**
+ * 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
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeValidate(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * This method may be called by a deployment tool to validate the overall");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * activation configuration information provided by the endpoint deployer.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws InvalidPropertyException indicates invalid onfiguration property settings.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void validate() throws InvalidPropertyException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call validate\");");
+
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output ResourceAdapter method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeResourceAdapter(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Get the resource adapter");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return The handle");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public ResourceAdapter getResourceAdapter()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getResourceAdapter\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return ra;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Set the resource adapter");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param ra The handle");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void setResourceAdapter(ResourceAdapter ra)");
+ 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);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CciConnCodeGen.java (from rev 105690, 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/code/CciConnCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CciConnCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,336 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+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;
+
+ writeDefaultConstructor(def, out, indent);
+
+ //constructor
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * default constructor");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param connSpec ConnectionSpec");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public " + getClassName(def) + "(ConnectionSpec connSpec)");
+ writeLeftCurlyBracket(out, indent);
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ 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.ConnectionSpec;");
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Initiates close of the connection handle at the application level.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Exception thrown if close on a connection handle fails.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Creates an Interaction associated with this Connection. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Interaction instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to create an Interaction");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns an LocalTransaction instance that enables a component to ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * demarcate resource manager local transactions on the Connection.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return LocalTransaction instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to return a LocalTransaction");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws javax.resource.NotSupportedException Demarcation of Resource manager ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets the information on the underlying EIS instance represented through an active connection.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return ConnectionMetaData instance representing information about the EIS instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to get information about the connected EIS instance. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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 new " + def.getConnMetaClass() + "();");
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets the information on the ResultSet functionality supported by ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * a connected EIS instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return ResultSetInfo instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to get ResultSet related information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws javax.resource.NotSupportedException ResultSet functionality is not supported");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CciConnFactoryCodeGen.java (from rev 105690, 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/code/CciConnFactoryCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CciConnFactoryCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,354 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+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);
+
+ writeDefaultConstructor(def, out, indent);
+
+ //constructor
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * default constructor");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param cxManager ConnectionManager");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public " + getClassName(def) + "(ConnectionManager cxManager)");
+ writeLeftCurlyBracket(out, indent);
+ writeRightCurlyBracket(out, indent);
+ 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);
+ out.write("import javax.resource.spi.ConnectionManager;");
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets a connection to an EIS instance. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Connection instance the EIS instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to get a connection to");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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 " + def.getCciConnClass() + "(new " + def.getConnSpecClass() + "());");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets a connection to an EIS instance. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param connSpec Connection parameters and security information specified as " +
+ "ConnectionSpec instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Connection instance the EIS instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to get a connection to");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public Connection getConnection(ConnectionSpec connSpec) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+
+ writeIndent(out, indent + 1);
+ out.write("return new " + def.getCciConnClass() + "(connSpec);");
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets metadata for the Resource Adapter. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return ResourceAdapterMetaData instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to get metadata information ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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 new " + def.getRaMetaClass() + "();");
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets a RecordFactory instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return RecordFactory instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to create a RecordFactory");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws javax.resource.NotSupportedException Operation not supported");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Get the Reference instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Reference instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public Reference getReference() throws NamingException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return reference;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Set the Reference instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param reference A Reference instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ 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);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CfCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CfCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CfCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,224 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A connection factory class CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class CfCodeGen 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 " + def.getCfInterfaceClass());
+ writeLeftCurlyBracket(out, 0);
+ int indent = 1;
+
+ writeIndent(out, indent);
+ out.write("private Reference reference;");
+ writeEol(out);
+ writeEol(out);
+
+ writeDefaultConstructor(def, out, indent);
+
+ //constructor
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * default constructor");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param cxManager ConnectionManager");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public " + getClassName(def) + "(ConnectionManager cxManager)");
+ writeLeftCurlyBracket(out, indent);
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeConnection(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 java.io.Serializable;");
+ 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.Referenceable;");
+ writeEol(out);
+ out.write("import javax.resource.ResourceException;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ConnectionManager;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getCfClass();
+ }
+
+ /**
+ * 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("/** ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * get connection from factory");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return " + def.getConnInterfaceClass() + " instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public " + def.getConnInterfaceClass() + " getConnection() throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+
+ writeIndent(out, indent + 1);
+ out.write("return new " + def.getConnImplClass() + "();");
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Get the Reference instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Reference instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public Reference getReference() throws NamingException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return reference;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Set the Reference instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param reference A Reference instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ 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);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CfInterfaceCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/CfInterfaceCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CfInterfaceCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CfInterfaceCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,117 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A connection factory interface CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class CfInterfaceCodeGen 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 interface " + getClassName(def) + " extends Serializable, Referenceable");
+ writeLeftCurlyBracket(out, 0);
+ int indent = 1;
+
+ writeConnection(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 java.io.Serializable;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import javax.resource.Referenceable;");
+ writeEol(out);
+ out.write("import javax.resource.ResourceException;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getCfInterfaceClass();
+ }
+
+ /**
+ * 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("/** ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * get connection from factory");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return " + def.getConnInterfaceClass() + " instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public " + def.getConnInterfaceClass() + " getConnection() throws ResourceException;");
+ writeEol(out);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CmCodeGen.java (from rev 105690, 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/code/CmCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/CmCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,138 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+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;
+
+ writeDefaultConstructor(def, out, indent);
+
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Allocate a connection");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param mcf The managed connection factory");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param cri The connection request information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Object The connection");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @exception ResourceException Thrown if an error occurs");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnImplCodeGen.java (from rev 105690, 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/code/ConnImplCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnImplCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,108 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A connection impl class CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class ConnImplCodeGen extends AbstractCodeGen
+{
+
+ /**
+ * Output 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 " + def.getConnInterfaceClass());
+ writeLeftCurlyBracket(out, 0);
+ int indent = 1;
+ writeIndent(out, indent);
+ out.write("/** The logger */");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
+ writeEol(out);
+ writeEol(out);
+
+ writeDefaultConstructor(def, out, indent);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * call me");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void callMe()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call callMe\");");
+
+ 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 org.jboss.logging.Logger;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getConnImplClass();
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnInterfaceCodeGen.java (from rev 105690, 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/code/ConnInterfaceCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnInterfaceCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,92 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A connection interface CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class ConnInterfaceCodeGen extends AbstractCodeGen
+{
+
+ /**
+ * Output class
+ * @param def definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ @Override
+ public void writeClassBody(Definition def, Writer out) throws IOException
+ {
+ int indent = 1;
+
+ out.write("public interface " + getClassName(def));
+ writeLeftCurlyBracket(out, 0);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * call me");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void callMe();");
+
+ 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.getConnInterfaceClass();
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnMetaCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnMetaCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnMetaCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnMetaCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,200 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A connection MetaData class CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class ConnMetaCodeGen extends AbstractCodeGen
+{
+ /**
+ * Output Metadata 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 ConnectionMetaData");
+ writeLeftCurlyBracket(out, 0);
+ int indent = 1;
+
+ writeDefaultConstructor(def, out, indent);
+
+ writeEIS(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.cci.ConnectionMetaData;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getConnMetaClass();
+ }
+
+ /**
+ * Output eis info 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns product name of the underlying EIS instance connected");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Product name of the EIS instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to get the information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns product version of the underlying EIS instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Product version of the EIS instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to get the information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ 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 username 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns the user name for an active connection as known to the underlying EIS instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return String representing the user name");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Failed to get the information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnSpecCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/ConnSpecCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnSpecCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/ConnSpecCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,84 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A connection Spec class CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class ConnSpecCodeGen extends AbstractCodeGen
+{
+ /**
+ * Output connection Spec 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 ConnectionSpec");
+ writeLeftCurlyBracket(out, 0);
+ int indent = 1;
+
+ writeDefaultConstructor(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.cci.ConnectionSpec ;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getConnSpecClass();
+ }
+
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McCodeGen.java (from rev 105690, 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/code/McCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,500 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A managed connection CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class McCodeGen extends AbstractCodeGen
+{
+
+ /**
+ * Output class
+ * @param def definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ @Override
+ public void writeClassBody(Definition def, Writer out) throws IOException
+ {
+ int indent = 1;
+ out.write("public class " + getClassName(def) + " implements ManagedConnection");
+ writeLeftCurlyBracket(out, 0);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/** The logger */");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
+ writeEol(out);
+ writeEol(out);
+
+ writeDefaultConstructor(def, out, indent);
+
+ writeConnection(def, out, indent);
+ writeLifecycle(def, out, indent);
+ writeConnectionEventListener(def, out, indent);
+ writeLogWriter(def, out, indent);
+ writeTransaction(def, out, indent);
+ writeMetaData(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 java.io.PrintWriter;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import javax.resource.ResourceException;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ConnectionEventListener;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ConnectionDefinition;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ConnectionRequestInfo;");
+ writeEol(out);
+ out.write("import javax.resource.spi.LocalTransaction;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ManagedConnection;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ManagedConnectionMetaData;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import javax.security.auth.Subject;");
+ writeEol(out);
+ out.write("import javax.transaction.xa.XAResource;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import org.jboss.logging.Logger;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getMcClass();
+ }
+
+ /**
+ * 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Creates a new connection handle for the underlying physical connection ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * represented by the ManagedConnection instance. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param subject security context as JAAS subject");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param cxRequestInfo ConnectionRequestInfo instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return generic Object instance representing the connection handle. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public Object getConnection(Subject subject,");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("ConnectionRequestInfo cxRequestInfo) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getConnection\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return null;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Used by the container to change the association of an ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * application-level connection handle with a ManagedConneciton instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param connection Application-level connection handle");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void associateConnection(Object connection) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call associateConnection\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output Lifecycle method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeLifecycle(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Application server calls this method to force any cleanup on the ManagedConnection instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void cleanup() throws ResourceException");
+ writeEol(out);
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call cleanup\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Destroys the physical connection to the underlying resource manager.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void destroy() throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call destroy\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output ConnectionEventListener method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeConnectionEventListener(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Adds a connection event listener to the ManagedConnection instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param listener a new ConnectionEventListener to be registered");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void addConnectionEventListener(ConnectionEventListener listener)");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call addConnectionEventListener\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Removes an already registered connection event listener from the ManagedConnection instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param listener already registered connection event listener to be removed");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void removeConnectionEventListener(ConnectionEventListener listener)");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call removeConnectionEventListener\");");
+
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+ /**
+ * Output LogWriter method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeLogWriter(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets the log writer for this ManagedConnection instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Character ourput stream associated with this Managed-Connection instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public PrintWriter getLogWriter() throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getLogWriter\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return null;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Sets the log writer for this ManagedConnection instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param out Character Output stream to be associated");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void setLogWriter(PrintWriter out) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call setLogWriter\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output Transaction method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeTransaction(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns an <code>javax.resource.spi.LocalTransaction</code> instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return LocalTransaction instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public LocalTransaction getLocalTransaction() throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getLocalTransaction\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return null;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns an <code>javax.transaction.xa.XAresource</code> instance. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return XAResource instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public XAResource getXAResource() throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getXAResource\");");
+ writeEol(out);
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets the metadata information for this connection's underlying EIS resource manager instance. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return ManagedConnectionMetaData instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception if operation fails");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public ManagedConnectionMetaData getMetaData() throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getMetaData\");");
+ writeEol(out);
+
+ writeIndent(out, indent + 1);
+ out.write("return new " + def.getMcMetaClass() + "();");
+
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McMetaCodeGen.java (from rev 105690, 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/code/McMetaCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McMetaCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,242 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+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 Metadata 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;
+
+ writeDefaultConstructor(def, out, indent);
+
+ 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 eis info 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns Product name of the underlying EIS instance connected through the ManagedConnection.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Product name of the EIS instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Thrown if an error occurs");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns Product version of the underlying EIS instance connected through the ManagedConnection.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Product version of the EIS instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Thrown if an error occurs");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ 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 max connection 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns maximum limit on number of active concurrent connections ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Maximum limit for number of active concurrent connections");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Thrown if an error occurs");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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 username 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("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns name of the user associated with the ManagedConnection instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return name of the user");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Thrown if an error occurs");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ 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);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McfCodeGen.java (from rev 105690, 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/code/McfCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/McfCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,553 @@
+/*
+ * 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.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;
+
+/**
+ * A McfCodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class McfCodeGen extends PropsCodeGen
+{
+
+ /**
+ * Output class
+ * @param def definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ @Override
+ public void writeClassBody(Definition def, Writer out) throws IOException
+ {
+ int indent = 1;
+ if (def.isUseAnnotation())
+ {
+ if (!def.isUseCciConnection())
+ {
+ out.write("@ConnectionDefinition(connectionFactory = " + def.getCfInterfaceClass() + ".class,");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("connectionFactoryImpl = " + def.getCfClass() + ".class,");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("connection = " + def.getConnInterfaceClass() + ".class,");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("connectionImpl = " + def.getConnImplClass() + ".class)");
+ writeEol(out);
+ }
+ else
+ {
+ out.write("@ConnectionDefinition(connectionFactory = ConnectionFactory.class,");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("connectionFactoryImpl = " + def.getCciConnFactoryClass() + ".class,");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("connection = Connection.class,");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("connectionImpl = " + def.getCciConnClass() + ".class)");
+ writeEol(out);
+ }
+ }
+
+ out.write("public class " + getClassName(def) + " implements ManagedConnectionFactory");
+ if (def.isImplRaAssociation())
+ {
+ out.write(", ResourceAdapterAssociation");
+ }
+ writeLeftCurlyBracket(out, 0);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/** The logger */");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
+ writeEol(out);
+ writeEol(out);
+ if (def.isImplRaAssociation())
+ {
+ writeIndent(out, indent);
+ out.write("/** The resource adapter */");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("private ResourceAdapter ra;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ writeIndent(out, indent);
+ out.write("/** The logwriter */");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("private PrintWriter logwriter;");
+ writeEol(out);
+ writeEol(out);
+
+
+ writeDefaultConstructor(def, out, indent);
+
+ writeConfigProps(def, out, indent);
+ writeConnectionFactory(def, out, indent);
+ writeManagedConnection(def, out, indent);
+ writeLogWriter(def, out, indent);
+ if (def.isImplRaAssociation())
+ {
+ writeResourceAdapter(def, out, indent);
+ }
+
+ writeHashCode(def, out, indent);
+ writeEquals(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 java.io.PrintWriter;");
+ writeEol(out);
+ out.write("import java.util.Set;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import javax.resource.ResourceException;");
+ writeEol(out);
+
+ if (def.isUseCciConnection())
+ {
+ out.write("import javax.resource.cci.Connection;");
+ writeEol(out);
+ out.write("import javax.resource.cci.ConnectionFactory;");
+ writeEol(out);
+ }
+
+ if (def.isUseAnnotation())
+ {
+ out.write("import javax.resource.spi.ConfigProperty;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ConnectionDefinition;");
+ 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.ManagedConnection;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ManagedConnectionFactory;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ResourceAdapter;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ResourceAdapterAssociation;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import javax.security.auth.Subject;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import org.jboss.logging.Logger;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getMcfClass();
+ }
+
+ /**
+ * get list of ConfigPropType
+ * @param def definition
+ * @return List<ConfigPropType> List of ConfigPropType
+ */
+ @Override
+ public List<ConfigPropType> getConfigProps(Definition def)
+ {
+ return def.getMcfConfigProps();
+ }
+
+ /**
+ * Output ConnectionFactory method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeConnectionFactory(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Creates a Connection Factory instance. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param cxManager ConnectionManager to be " +
+ "associated with created EIS connection factory instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return EIS-specific Connection Factory instance or " +
+ "javax.resource.cci.ConnectionFactory instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Generic exception");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ if (def.isImplRaAssociation())
+ {
+ writeIfRaNull(out, indent);
+ }
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call createConnectionFactory\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ if (def.isUseCciConnection())
+ out.write("return new " + def.getCciConnFactoryClass() + "(cxManager);");
+ else
+ out.write("return new " + def.getCfClass() + "(cxManager);");
+
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Creates a Connection Factory instance. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return EIS-specific Connection Factory instance or " +
+ "javax.resource.cci.ConnectionFactory instance");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException Generic exception");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public Object createConnectionFactory() throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ if (def.isImplRaAssociation())
+ {
+ writeIfRaNull(out, indent);
+ }
+
+ writeIndent(out, indent + 1);
+ if (def.isUseCciConnection())
+ out.write("return new " + def.getCciConnFactoryClass() + "(new " + def.getCmClass() + "());");
+ else
+ {
+ out.write("return new " + def.getCfClass() + "(new " + def.getCmClass() + "());");
+ }
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output if (ra == null)
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeIfRaNull(Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent + 1);
+ out.write("if (ra == null)");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("throw new IllegalStateException(\"RA is null\");");
+ writeEol(out);
+ }
+
+ /**
+ * Output ConnectionFactory method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeManagedConnection(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Creates a new physical connection to the underlying EIS resource manager.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param subject Caller's security information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param cxRequestInfo Additional resource adapter " +
+ "specific connection request information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return ManagedConnection instance ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public ManagedConnection createManagedConnection(Subject subject,");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("ConnectionRequestInfo cxRequestInfo) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ if (def.isImplRaAssociation())
+ {
+ writeIfRaNull(out, indent);
+ }
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call createManagedConnection\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return null;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns a matched connection from the candidate set of connections. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param connectionSet candidate connection set");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param subject Caller's security information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param cxRequestInfo Additional resource adapter " +
+ "specific connection request information");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return ManagedConnection if resource adapter finds an acceptable match otherwise null ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public ManagedConnection matchManagedConnections(Set connectionSet,");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ if (def.isImplRaAssociation())
+ {
+ writeIfRaNull(out, indent);
+ }
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call matchManagedConnections\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return null;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+ /**
+ * Output LogWriter method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeLogWriter(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Get the log writer for this ManagedConnectionFactory instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return PrintWriter");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public PrintWriter getLogWriter() throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getLogWriter\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return logwriter;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Set the log writer for this ManagedConnectionFactory instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param out PrintWriter - an out stream for error logging and tracing");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void setLogWriter(PrintWriter out) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call setLogWriter\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("logwriter = out;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output ResourceAdapter method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeResourceAdapter(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Get the resource adapter");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return The handle");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public ResourceAdapter getResourceAdapter()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getResourceAdapter\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return ra;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Set the resource adapter");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param ra The handle");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void setResourceAdapter(ResourceAdapter ra)");
+ 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);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/MlCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/MlCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/MlCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/MlCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,93 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A message listener CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class MlCodeGen extends AbstractCodeGen
+{
+
+ /**
+ * Output class
+ * @param def definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ @Override
+ public void writeClassBody(Definition def, Writer out) throws IOException
+ {
+ int indent = 1;
+ out.write("public interface " + getClassName(def));
+ writeLeftCurlyBracket(out, 0);
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * receive message");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param msg String.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void onMessage(String msg);");
+
+ 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.getMlClass();
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/PropsCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/PropsCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/PropsCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,277 @@
+/*
+ * 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.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;
+
+/**
+ * A properties code generator
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public abstract class PropsCodeGen extends AbstractCodeGen
+{
+ /**
+ * Output Configuration Properties
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ void writeConfigProps(Definition def, Writer out, int indent) throws IOException
+ {
+ if (getConfigProps(def) == null)
+ return;
+
+ for (int i = 0; i < getConfigProps(def).size(); i++)
+ {
+ writeIndent(out, indent);
+ out.write("/** " + getConfigProps(def).get(i).getName() + " */");
+ writeEol(out);
+
+ if (def.isUseAnnotation())
+ {
+ writeIndent(out, indent);
+ out.write("@ConfigProperty(defaultValue=\"" + getConfigProps(def).get(i).getValue() + "\")");
+ writeEol(out);
+ }
+ writeIndent(out, indent);
+ out.write("private " +
+ getConfigProps(def).get(i).getType() +
+ " " +
+ getConfigProps(def).get(i).getName() +
+ ";");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ 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 +
+ ")");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("this." + name + " = " + name + ";");
+ writeRightCurlyBracket(out, indent);
+ 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 +
+ "()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return " + name + ";");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+ }
+
+ /**
+ * Output hashCode method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ @Override
+ void writeHashCode(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/** ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns a hash code value for the object.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return a hash code value for this object.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public int hashCode()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("int result = 17;");
+ writeEol(out);
+ for (int i = 0; i < getConfigProps(def).size(); i++)
+ {
+ writeIndent(out, indent + 1);
+ out.write("if (" + getConfigProps(def).get(i).getName() + " != null)");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("result += 31 * result + 7 * " + getConfigProps(def).get(i).getName() + ".hashCode();");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+
+ out.write("else");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("result += 31 * result + 7;");
+ writeEol(out);
+ }
+ writeIndent(out, indent + 1);
+ out.write("return result;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+
+ /**
+ * Output equals method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ @Override
+ void writeEquals(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/** ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Indicates whether some other object is equal to this one.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param other the reference object with which to compare.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return true if this object is the same as the obj argument; false otherwise.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public boolean equals(Object other)");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("if (other == null)");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("return false;");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("if (other == this)");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("return true;");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("if (!(other instanceof " + getClassName(def) + "))");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("return false;");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write(getClassName(def) + " obj = (" + getClassName(def) + ")other;");
+ writeEol(out);
+
+ writeIndent(out, indent + 1);
+ out.write("boolean result = true; ");
+ writeEol(out);
+
+ for (int i = 0; i < getConfigProps(def).size(); i++)
+ {
+ writeIndent(out, indent + 1);
+ out.write("if (result)");
+ writeLeftCurlyBracket(out, indent + 1);
+ writeIndent(out, indent + 2);
+ out.write("if (" + getConfigProps(def).get(i).getName() + " == null)");
+ writeEol(out);
+ writeIndent(out, indent + 3);
+ out.write("result = obj.get" + upcaseFirst(getConfigProps(def).get(i).getName()) + "() == null;");
+ writeEol(out);
+
+ writeIndent(out, indent + 2);
+ out.write("else");
+ writeEol(out);
+ writeIndent(out, indent + 3);
+ out.write("result = " + getConfigProps(def).get(i).getName() + ".equals(obj.get" +
+ upcaseFirst(getConfigProps(def).get(i).getName()) + "());");
+ writeRightCurlyBracket(out, indent + 1);
+ }
+ writeIndent(out, indent + 1);
+ out.write("return result;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * get list of ConfigPropType
+ * @param def TODO
+ * @return List<ConfigPropType> List of ConfigPropType
+ */
+ public abstract List<ConfigPropType> getConfigProps(Definition def);
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,320 @@
+/*
+ * 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.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;
+
+/**
+ * A resource adapter code generator
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class RaCodeGen extends PropsCodeGen
+{
+ /**
+ * Output ResourceAdapater 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("@Connector");
+ writeEol(out);
+ }
+ out.write("public class " + getClassName(def) + " implements ResourceAdapter");
+ writeLeftCurlyBracket(out, 0);
+ writeEol(out);
+
+ int indent = 1;
+ writeIndent(out, indent);
+ out.write("/** The logger */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("private static Logger log = Logger.getLogger(" + getClassName(def) + ".class);");
+ writeEol(out);
+ writeEol(out);
+
+ writeDefaultConstructor(def, out, indent);
+
+ writeConfigProps(def, out, indent);
+ writeEndpointLifecycle(def, out, indent);
+ writeLifecycle(def, out, indent);
+ writeXAResource(def, out, indent);
+ writeHashCode(def, out, indent);
+ writeEquals(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.ActivationSpec;");
+ writeEol(out);
+ out.write("import javax.resource.spi.BootstrapContext;");
+ 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.ResourceAdapter;");
+ writeEol(out);
+ out.write("import javax.resource.spi.ResourceAdapterInternalException;");
+ writeEol(out);
+ out.write("import javax.resource.spi.endpoint.MessageEndpointFactory;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import javax.transaction.xa.XAResource;");
+ writeEol(out);
+ writeEol(out);
+ out.write("import org.jboss.logging.Logger;");
+ writeEol(out);
+ writeEol(out);
+ }
+
+ /**
+ * Output getXAResources method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeXAResource(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * This method is called by the application server during crash recovery.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param specs an array of ActivationSpec JavaBeans ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return an array of XAResource objects");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public XAResource[] getXAResources(ActivationSpec[] specs)");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call getXAResources\");");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("return null;");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output Lifecycle method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeLifecycle(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * This is called when a resource adapter instance is bootstrapped.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param ctx a bootstrap context containing references ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceAdapterInternalException indicates bootstrap failure.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void start(BootstrapContext ctx)");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("throws ResourceAdapterInternalException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call start\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * This is called when a resource adapter instance is undeployed or");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * during application server shutdown. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void stop()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call stop\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output EndpointLifecycle method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeEndpointLifecycle(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * This is called during the activation of a message endpoint.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param endpointFactory a message endpoint factory instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param spec an activation spec JavaBean instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @throws ResourceException generic exception ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void endpointActivation(MessageEndpointFactory endpointFactory,");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("ActivationSpec spec) throws ResourceException");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call endpointActivation\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * This is called when a message endpoint is deactivated. ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param endpointFactory a message endpoint factory instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @param spec an activation spec JavaBean instance.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("public void endpointDeactivation(MessageEndpointFactory endpointFactory,");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("ActivationSpec spec)");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("log.debug(\"call endpointDeactivation\");");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * get this class name
+ * @param def definition
+ * @return String class name
+ */
+ @Override
+ public String getClassName(Definition def)
+ {
+ return def.getRaClass();
+ }
+
+ /**
+ * get list of ConfigPropType
+ * @param def definition
+ * @return List<ConfigPropType> List of ConfigPropType
+ */
+ @Override
+ public List<ConfigPropType> getConfigProps(Definition def)
+ {
+ return def.getRaConfigProps();
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaMetaCodeGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaMetaCodeGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaMetaCodeGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaMetaCodeGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,349 @@
+/*
+ * 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.code;
+
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A resource adapter MetaData class CodeGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class RaMetaCodeGen extends AbstractCodeGen
+{
+ /**
+ * Output Metadata 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 ResourceAdapterMetaData");
+ writeLeftCurlyBracket(out, 0);
+ int indent = 1;
+
+ writeDefaultConstructor(def, out, indent);
+
+ writeInfo(def, out, indent);
+ writeSupport (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.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.getRaMetaClass();
+ }
+
+ /**
+ * Output info method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeInfo(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets the version of the resource adapter.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return String representing version of the resource adapter");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public String getAdapterVersion()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return null; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets the name of the vendor that has provided the resource adapter.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return String representing name of the vendor ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public String getAdapterVendorName()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return null; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets a tool displayable name of the resource adapter.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return String representing the name of the resource adapter");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public String getAdapterName()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return null; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Gets a tool displayable short desription of the resource adapter.");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return String describing the resource adapter");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public String getAdapterShortDescription()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return null; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns a string representation of the version");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return String representing the supported version of the connector architecture");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public String getSpecVersion()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return null; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+
+ /**
+ * Output support method
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeSupport(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns an array of fully-qualified names of InteractionSpec");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return Array of fully-qualified class names of InteractionSpec classes");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public String[] getInteractionSpecsSupported()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return null; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns true if the implementation class for the Interaction");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return boolean depending on method support");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public boolean supportsExecuteWithInputAndOutputRecord()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return false; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns true if the implementation class for the Interaction");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return boolean depending on method support");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public boolean supportsExecuteWithInputRecordOnly()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return false; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("/**");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * Returns true if the resource adapter implements the LocalTransaction");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" *");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" * @return true if resource adapter supports resource manager local transaction demarcation ");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write(" */");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("@Override");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("public boolean supportsLocalTransactionDemarcation()");
+ writeLeftCurlyBracket(out, indent);
+ writeIndent(out, indent + 1);
+ out.write("return false; //TODO");
+ writeRightCurlyBracket(out, indent);
+ writeEol(out);
+ }
+}
Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/package.html
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/package.html (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/package.html 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,3 @@
+<body>
+Code generator
+</body>
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/AbstractXmlGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AbstractXmlGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/AbstractXmlGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/AbstractXmlGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,56 @@
+/*
+ * 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.BaseGen;
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A AbstractXmlGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public abstract class AbstractXmlGen extends BaseGen
+{
+ /**
+ * generate code
+ * @param def Definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ public void generate(Definition def, Writer out) throws IOException
+ {
+ writeXmlBody(def, out);
+ }
+
+ /**
+ * Output xml
+ * @param def definition
+ * @param out Writer
+ * @throws IOException ioException
+ */
+ public abstract void writeXmlBody(Definition def, Writer out) throws IOException;
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/BuildXmlGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/BuildXmlGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/BuildXmlGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/BuildXmlGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,53 @@
+/*
+ * 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 org.jboss.jca.codegenerator.Utils;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.net.URL;
+
+/**
+ * A BuildXmlGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class BuildXmlGen extends AbstractXmlGen
+{
+ @Override
+ public void writeXmlBody(Definition def, Writer out) throws IOException
+ {
+ out.write("<!--");
+ writeEol(out);
+ writeheader(def, out);
+ out.write("-->");
+ writeEol(out);
+ writeEol(out);
+
+ URL buildFile = BuildXmlGen.class.getResource("/build.xml.template");
+ String buildString = Utils.readFileIntoString(buildFile);
+ out.write(buildString);
+ }
+}
Copied: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java (from rev 105690, projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/RaXmlGen.java)
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,259 @@
+/*
+ * 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.ConfigPropType;
+import org.jboss.jca.codegenerator.Definition;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.List;
+
+/**
+ * A BuildXmlGen.
+ *
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+public class RaXmlGen extends AbstractXmlGen
+{
+ @Override
+ public void writeXmlBody(Definition def, Writer out) throws IOException
+ {
+ out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ writeEol(out);
+ writeEol(out);
+ out.write("<connector xmlns=\"http://java.sun.com/xml/ns/javaee\"");
+ writeEol(out);
+ out.write(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
+ writeEol(out);
+ out.write(" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee");
+ writeEol(out);
+ out.write(" http://java.sun.com/xml/ns/j2ee/connector_1_6.xsd\"");
+ writeEol(out);
+ out.write(" version=\"1.6\" metadata-complete=\"true\">");
+ writeEol(out);
+ writeEol(out);
+ int indent = 1;
+ writeIndent(out, indent);
+ out.write("<vendor-name>Red Hat Middleware LLC</vendor-name>");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("<eis-type>Test RA</eis-type>");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("<resourceadapter-version>0.1</resourceadapter-version>");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("<resourceadapter>");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("<resourceadapter-class>" + def.getRaPackage() + "." + def.getRaClass() + "</resourceadapter-class>");
+ writeEol(out);
+
+ writeConfigPropsXml(def.getRaConfigProps(), out, indent + 1, false);
+ writeOutbound(def, out, indent + 1);
+ if (def.isSupportInbound())
+ writeInbound(def, out, indent + 1);
+
+ writeIndent(out, indent);
+ out.write("</resourceadapter>");
+ writeEol(out);
+ out.write("</connector>");
+ writeEol(out);
+ }
+
+ /**
+ * Output config props xml part
+ * @param props config properties
+ * @param out Writer
+ * @param indent space number
+ * @param required support required
+ * @throws IOException ioException
+ */
+ private void writeConfigPropsXml(List<ConfigPropType> props,
+ Writer out, int indent, boolean required) throws IOException
+ {
+ if (props == null || props.size() == 0)
+ return;
+ if (required)
+ {
+ for (ConfigPropType prop : props)
+ {
+ if (prop.isRequired())
+ {
+ writeIndent(out, indent);
+ out.write("<required-config-property>");
+ writeEol(out);
+
+ writeIndent(out, indent + 1);
+ out.write("<config-property-name>" + prop.getName() + "</config-property-name>");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("</required-config-property>");
+ writeEol(out);
+ }
+ }
+ writeEol(out);
+ }
+ else
+ {
+ for (ConfigPropType prop : props)
+ {
+ writeIndent(out, indent);
+ out.write("<config-property>");
+ writeEol(out);
+
+ writeIndent(out, indent + 1);
+ out.write("<config-property-name>" + prop.getName() + "</config-property-name>");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("<config-property-type>java.lang." + prop.getType() + "</config-property-type>");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("<config-property-value>" + prop.getValue() + "</config-property-value>");
+ writeEol(out);
+
+ writeIndent(out, indent);
+ out.write("</config-property>");
+ writeEol(out);
+ writeEol(out);
+ }
+ }
+ }
+
+ /**
+ * Output inbound xml part
+ * @param def definition
+ * @param out Writer
+ * @param indent space number
+ * @throws IOException ioException
+ */
+ private void writeInbound(Definition def, Writer out, int indent) throws IOException
+ {
+ writeIndent(out, indent);
+ out.write("<inbound-resourceadapter>");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("<messageadapter>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("<messagelistener>");
+ writeEol(out);
+ writeIndent(out, indent + 3);
+ out.write("<messagelistener-type>" + def.getRaPackage() + "." + def.getMlClass() + "</messagelistener-type>");
+ writeEol(out);
+ writeIndent(out, indent + 3);
+ out.write("<activationspec>");
+ writeEol(out);
+ writeIndent(out, indent + 4);
+ out.write("<activationspec-class>" + def.getRaPackage() + "." + def.getAsClass() + "</activationspec-class>");
+ writeEol(out);
+
+ writeConfigPropsXml(def.getAsConfigProps(), out, indent + 4, true);
+ writeIndent(out, indent + 3);
+ out.write("</activationspec>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("</messagelistener>");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("</messageadapter>");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("</inbound-resourceadapter>");
+ 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("<outbound-resourceadapter>");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("<connection-definition>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("<managedconnectionfactory-class>" + def.getRaPackage() + "." +
+ def.getMcfClass() + "</managedconnectionfactory-class>");
+ writeEol(out);
+ writeConfigPropsXml(def.getMcfConfigProps(), out, indent + 2, false);
+
+ if (!def.isUseCciConnection())
+ {
+ writeIndent(out, indent + 2);
+ out.write("<connectionfactory-interface>" + def.getRaPackage() + "." +
+ def.getCfInterfaceClass() + "</connectionfactory-interface>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." +
+ def.getCfClass() + "</connectionfactory-impl-class>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("<connection-interface>" + def.getRaPackage() + "." +
+ def.getConnInterfaceClass() + "</connection-interface>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("<connection-impl-class>" + def.getRaPackage() + "." +
+ def.getConnImplClass() + "</connection-impl-class>");
+ writeEol(out);
+ }
+ else
+ {
+ writeIndent(out, indent + 2);
+ out.write("<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("<connectionfactory-impl-class>" + def.getRaPackage() + "." +
+ def.getCciConnFactoryClass() + "</connectionfactory-impl-class>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("<connection-interface>javax.resource.cci.Connection</connection-interface>");
+ writeEol(out);
+ writeIndent(out, indent + 2);
+ out.write("<connection-impl-class>" + def.getRaPackage() + "." +
+ def.getCciConnClass() + "</connection-impl-class>");
+ writeEol(out);
+ }
+ writeIndent(out, indent + 1);
+ out.write("</connection-definition>");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("<transaction-support>NoTransaction</transaction-support>");
+ writeEol(out);
+ writeIndent(out, indent + 1);
+ out.write("<reauthentication-support>false</reauthentication-support>");
+ writeEol(out);
+ writeIndent(out, indent);
+ out.write("</outbound-resourceadapter>");
+ writeEol(out);
+ }
+}
Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/package.html
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/package.html (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/package.html 2010-06-04 09:53:32 UTC (rev 105713)
@@ -0,0 +1,3 @@
+<body>
+Code generator
+</body>
Modified: projects/jboss-jca/trunk/codegenerator/src/test/java/org/jboss/jca/codegenerator/JCA16AnnoProfileTestCase.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/test/java/org/jboss/jca/codegenerator/JCA16AnnoProfileTestCase.java 2010-06-04 09:45:48 UTC (rev 105712)
+++ projects/jboss-jca/trunk/codegenerator/src/test/java/org/jboss/jca/codegenerator/JCA16AnnoProfileTestCase.java 2010-06-04 09:53:32 UTC (rev 105713)
@@ -22,6 +22,8 @@
package org.jboss.jca.codegenerator;
+import org.jboss.jca.codegenerator.code.RaCodeGen;
+
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
More information about the jboss-cvs-commits
mailing list