[jboss-cvs] JBossAS SVN: r104598 - in projects/jboss-jca/trunk/codegenerator/src/main: resources and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 10 02:34:12 EDT 2010
Author: jeff.zhang
Date: 2010-05-10 02:34:12 -0400 (Mon, 10 May 2010)
New Revision: 104598
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/PropsCodeGen.java
projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
Log:
[JBJCA-316] config-properties in hashCode/equals
Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java 2010-05-10 05:43:44 UTC (rev 104597)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java 2010-05-10 06:34:12 UTC (rev 104598)
@@ -41,8 +41,20 @@
{
private static final int OTHER = 2;
+ private enum PropsType
+ {
+ String,
+ Boolean,
+ Integer,
+ Double,
+ Byte,
+ Short,
+ Long,
+ Float,
+ Character
+ }
/**
- * Code generator standalone tool
+ * Code generator stand alone tool
*
* @param args command line arguments
*/
@@ -92,23 +104,7 @@
def.setRaPackage(packageName);
def.setRaClass(raClassName);
- List<ConfigPropType> raProps = new ArrayList<ConfigPropType>();
- while (true)
- {
- System.out.println(dbconf.getString("ra.config.properties"));
- System.out.print(" " + dbconf.getString("config.properties.name"));
- String name = in.readLine();
- if (name == null || name.equals(""))
- break;
- System.out.print(" " + dbconf.getString("config.properties.type"));
- String type = in.readLine();
- System.out.print(" " + dbconf.getString("config.properties.value"));
- String value = in.readLine();
- System.out.println();
-
- ConfigPropType config = new ConfigPropType(name, type, value);
- raProps.add(config);
- }
+ List<ConfigPropType> raProps = inputProperties("ra", dbconf, in);
def.setRaConfigProps(raProps);
System.out.print(dbconf.getString("mcf.class.name"));
@@ -117,28 +113,17 @@
System.out.print(dbconf.getString("mcf.impl.raa"));
String raAssociation = in.readLine();
- if (raAssociation.equals("Y") || raAssociation.equals("y") || raAssociation.equals("Yes"))
- def.setImplRaAssociation(true);
+ if (raAssociation == null)
+ def.setImplRaAssociation(false);
else
- def.setImplRaAssociation(false);
-
- List<ConfigPropType> mcfProps = new ArrayList<ConfigPropType>();
- while (true)
{
- System.out.println(dbconf.getString("mcf.config.properties"));
- System.out.print(" " + dbconf.getString("config.properties.name"));
- String name = in.readLine();
- if (name == null || name.equals(""))
- break;
- System.out.print(" " + dbconf.getString("config.properties.type"));
- String type = in.readLine();
- System.out.print(" " + dbconf.getString("config.properties.value"));
- String value = in.readLine();
- System.out.println();
-
- ConfigPropType config = new ConfigPropType(name, type, value);
- mcfProps.add(config);
+ if (raAssociation.equals("Y") || raAssociation.equals("y") || raAssociation.equals("Yes"))
+ def.setImplRaAssociation(true);
+ else
+ def.setImplRaAssociation(false);
}
+
+ List<ConfigPropType> mcfProps = inputProperties("mcf", dbconf, in);
def.setMcfConfigProps(mcfProps);
System.out.print(dbconf.getString("mc.class.name"));
@@ -167,6 +152,57 @@
}
/**
+ * Input Properties
+ * @param classname belong to which java class
+ * @param dbconf ResourceBundle
+ * @param in BufferedReader
+ * @return List<ConfigPropType> list of properties
+ * @throws IOException ioException
+ */
+ private static List<ConfigPropType> inputProperties(String classname, ResourceBundle dbconf, BufferedReader in)
+ throws IOException
+ {
+ List<ConfigPropType> props = new ArrayList<ConfigPropType>();
+ while (true)
+ {
+ System.out.println(dbconf.getString(classname + ".config.properties"));
+ System.out.print(" " + dbconf.getString("config.properties.name"));
+ String name = in.readLine();
+ if (name == null || name.equals(""))
+ break;
+ System.out.print(" " + dbconf.getString("config.properties.type"));
+ String type = in.readLine();
+ boolean correctType = false;
+ for (PropsType pt : PropsType.values())
+ {
+ if (type.equals(pt.toString()))
+ {
+ correctType = true;
+ break;
+ }
+ }
+ if (!correctType)
+ {
+ System.out.print(dbconf.getString("config.properties.type.tip") + " [");
+ for (PropsType pt : PropsType.values())
+ {
+ System.out.print(pt.toString());
+ System.out.print(", ");
+ }
+ System.out.println("]");
+ continue;
+ }
+ System.out.print(" " + dbconf.getString("config.properties.value"));
+ String value = in.readLine();
+ System.out.println();
+
+ ConfigPropType config = new ConfigPropType(name, type, value);
+ props.add(config);
+ }
+ return props;
+ }
+
+ /**
* generateAnt build.xml
* @param outputDir output directory
*/
Modified: 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-05-10 05:43:44 UTC (rev 104597)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/PropsCodeGen.java 2010-05-10 06:34:12 UTC (rev 104598)
@@ -116,39 +116,8 @@
for (int i = 0; i < getConfigProps(def).size(); i++)
{
writeIndent(out, indent + 1);
- String type = getConfigProps(def).get(i).getType();
- if (type.equals("int"))
- {
- out.write("result = 31 * result + " + getConfigProps(def).get(i).getName() + ";");
- }
- else if (type.equals("short") || type.equals("char") || type.equals("byte"))
- {
- out.write("result = 31 * result + (int)" + getConfigProps(def).get(i).getName() + ";");
- }
- else if (type.equals("boolean"))
- {
- out.write("result = 31 * result + (" + getConfigProps(def).get(i).getName() + " ? 0 : 1);");
- }
- else if (type.equals("long"))
- {
- out.write("result = 31 * result + (int)(" + getConfigProps(def).get(i).getName() +
- " ^ (" + getConfigProps(def).get(i).getName() + " >>> 32));");
- }
- else if (type.equals("float"))
- {
- out.write("result = 31 * result + Float.floatToIntBits(" + getConfigProps(def).get(i).getName() + ");");
- }
- else if (type.equals("double"))
- {
- out.write("long tolong = Double.doubleToLongBits(" + getConfigProps(def).get(i).getName() + ");");
- writeEol(out);
- writeIndent(out, indent + 1);
- out.write("result = 31 * result + (int)(tolong ^ (tolong >>> 32));");
- }
- else
- {
- out.write("result = 31 * result + " + getConfigProps(def).get(i).getName() + ".hashCode();");
- }
+ out.write("result = 31 * result + " + getConfigProps(def).get(i).getName() + ".hashCode();");
+
writeEol(out);
}
writeIndent(out, indent + 1);
@@ -209,7 +178,7 @@
writeIndent(out, indent + 2);
out.write("&& ");
}
- out.write(getConfigProps(def).get(i).getName() + " == obj." + getConfigProps(def).get(i).getName());
+ out.write(getConfigProps(def).get(i).getName() + ".equals(obj." + getConfigProps(def).get(i).getName() + ")");
}
out.write(";");
writeRightCurlyBracket(out, indent);
Modified: projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties 2010-05-10 05:43:44 UTC (rev 104597)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties 2010-05-10 06:34:12 UTC (rev 104598)
@@ -8,6 +8,7 @@
config.properties.name=Name:
config.properties.type=Type:
config.properties.value=Value:
+config.properties.type.tip=Input right type:
mcf.config.properties=Managed connection factory config properties [enter to quit]:
mcf.impl.raa=Use ResourceAdapterAssociation: [Y/N/Yes/No]
output.dir=Output directory:
More information about the jboss-cvs-commits
mailing list