[jboss-cvs] JBossAS SVN: r104192 - in projects/jboss-jca/trunk/codegenerator: src/main/java/org/jboss/jca/codegenerator and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Apr 23 07:14:44 EDT 2010
Author: jeff.zhang
Date: 2010-04-23 07:14:43 -0400 (Fri, 23 Apr 2010)
New Revision: 104192
Added:
projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator_zh_CN.properties
Removed:
projects/jboss-jca/trunk/codegenerator/src/main/resources/ResourceAdapter.template
projects/jboss-jca/trunk/codegenerator/src/test/resources/test.template
Modified:
projects/jboss-jca/trunk/codegenerator/build.xml
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/SimpleTemplateTestCase.java
Log:
[JBJCA-311] Move text strings in the tool to a resource bundle
Modified: projects/jboss-jca/trunk/codegenerator/build.xml
===================================================================
--- projects/jboss-jca/trunk/codegenerator/build.xml 2010-04-23 11:00:30 UTC (rev 104191)
+++ projects/jboss-jca/trunk/codegenerator/build.xml 2010-04-23 11:14:43 UTC (rev 104192)
@@ -61,7 +61,7 @@
<copy todir="${build.codegenerator.dir}/jars/codegenerator">
<fileset dir="src/main/resources/"
- includes="**/*.template"/>
+ includes="**/*.template **/*.properties"/>
</copy>
<jar destfile="${target.dir}/jboss-jca-codegenerator.jar"
@@ -76,7 +76,7 @@
<jar destfile="${target.dir}/jboss-jca-codegenerator-ant.jar"
manifest="src/main/resources/codegenerator-ant-manifest.mf"
basedir="${build.codegenerator.dir}/jars/codegenerator"
- includes="**/ant/**"/>
+ includes="**/ant/**"/>
-->
</target>
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-04-23 11:00:30 UTC (rev 104191)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Main.java 2010-04-23 11:14:43 UTC (rev 104192)
@@ -24,10 +24,11 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
-import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
/**
* Code generator main class
@@ -45,12 +46,16 @@
*/
public static void main(String[] args)
{
+ Locale locale = Locale.getDefault();
+
try
{
+ ResourceBundle dbconf = ResourceBundle.getBundle("codegenerator", locale);
+
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- System.out.print("Please input ResourceAdapter package name: ");
+ System.out.print(dbconf.getString("package.name"));
String packageName = in.readLine();
- System.out.print("Please input ResourceAdapter class name: ");
+ System.out.print(dbconf.getString("class.name"));
String className = in.readLine();
@@ -62,14 +67,14 @@
List<ConfigPropType> props = new ArrayList<ConfigPropType>();
while (true)
{
- System.out.println("Please input config properties [enter to quit]: ");
- System.out.print(" Name: ");
+ System.out.println(dbconf.getString("config.properties"));
+ System.out.print(" " + dbconf.getString("config.properties.name"));
String name = in.readLine();
if (name == null || name.equals(""))
break;
- System.out.print(" Type: ");
+ System.out.print(" " + dbconf.getString("config.properties.type"));
String type = in.readLine();
- System.out.print(" Value: ");
+ System.out.print(" " + dbconf.getString("config.properties.value"));
String value = in.readLine();
System.out.println();
@@ -78,21 +83,19 @@
}
def.setRaConfigProps(props);
- System.out.print("Please input output directory: ");
+ System.out.print(dbconf.getString("output.dir"));
String output = in.readLine();
+ if (output == null || output.equals(""))
+ output = ".";
File outDir = new File(output);
-
- if (!outDir.mkdirs())
- {
- throw new IOException(output + " can't be created");
- }
+ outDir.mkdirs();
File report = new File(outDir, className + ".java");
FileWriter fw = new FileWriter(report);
template.process(def, fw);
fw.close();
- System.out.println("Java file wrote");
+ System.out.println(dbconf.getString("java.wrote"));
}
catch (Exception e)
{
Deleted: projects/jboss-jca/trunk/codegenerator/src/main/resources/ResourceAdapter.template
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/ResourceAdapter.template 2010-04-23 11:00:30 UTC (rev 104191)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/ResourceAdapter.template 2010-04-23 11:14:43 UTC (rev 104192)
@@ -1,129 +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 ${package.name};
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ActivationSpec;
-import javax.resource.spi.BootstrapContext;
-import javax.resource.spi.ResourceAdapter;
-import javax.resource.spi.ResourceAdapterInternalException;
-import javax.resource.spi.endpoint.MessageEndpointFactory;
-import javax.transaction.xa.XAResource;
-
-import org.jboss.logging.Logger;
-
-/**
- * ${class.name}
- *
- * @version $Revision: $
- */
-public class ${class.name} implements ResourceAdapter
-{
- private static Logger log = Logger.getLogger(${class.name}.class);
-
- /**
- * This is called during the activation of a message endpoint.
- *
- * @param endpointFactory a message endpoint factory instance.
- * @param spec an activation spec JavaBean instance.
- * @throws ResourceException generic exception
- */
- public void endpointActivation(MessageEndpointFactory endpointFactory,
- ActivationSpec spec) throws ResourceException
- {
- log.debug("call endpointActivation");
-
- }
-
- /**
- * This is called when a message endpoint is deactivated.
- *
- * @param endpointFactory a message endpoint factory instance.
- * @param spec an activation spec JavaBean instance.
- */
- public void endpointDeactivation(MessageEndpointFactory endpointFactory,
- ActivationSpec spec)
- {
- log.debug("call endpointDeactivation");
-
- }
-
- /**
- * This method is called by the application server during crash recovery.
- *
- * @param specs an array of ActivationSpec JavaBeans
- * @throws ResourceException generic exception
- * @return an array of XAResource objects
- */
- public XAResource[] getXAResources(ActivationSpec[] specs)
- throws ResourceException
- {
- log.debug("call getXAResources");
- return null;
- }
-
- /**
- * This is called when a resource adapter instance is bootstrapped.
- *
- * @param ctx a bootstrap context containing references
- * @throws ResourceAdapterInternalException indicates bootstrap failure.
- */
- public void start(BootstrapContext ctx)
- throws ResourceAdapterInternalException
- {
- log.debug("call start");
-
- }
-
- /**
- * This is called when a resource adapter instance is undeployed or
- * during application server shutdown.
- */
- public void stop()
- {
- log.debug("call stop");
-
- }
-
- /**
- * Hash code
- * @return The hash
- */
- @Override
- public int hashCode()
- {
- return 42;
- }
-
- /**
- * Equals
- * @param other The other object
- * @return True if equal; otherwise false
- */
- public boolean equals(Object other)
- {
- if (other == null)
- return false;
-
- return getClass().equals(other.getClass());
- }
-}
Added: projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator.properties 2010-04-23 11:14:43 UTC (rev 104192)
@@ -0,0 +1,8 @@
+package.name=Please input ResourceAdapter package name:
+class.name=Please input ResourceAdapter class name:
+config.properties=Please input config properties [enter to quit]:
+config.properties.name=Name:
+config.properties.type=Type:
+config.properties.value=Value:
+output.dir=Please input output directory:
+java.wrote=Java file wrote
\ No newline at end of file
Added: projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator_zh_CN.properties
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator_zh_CN.properties (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/codegenerator_zh_CN.properties 2010-04-23 11:14:43 UTC (rev 104192)
@@ -0,0 +1,9 @@
+#zh_CN
+package.name=请输入ResourceAdapter包名:
+class.name=请输入ResourceAdapter 类名:
+config.properties=请输入 config properties [回车退出]:
+config.properties.name=名字:
+config.properties.type=类型:
+config.properties.value=赋值:
+output.dir=请输入代码生成目录:
+java.wrote=Java文件已经生成
Modified: projects/jboss-jca/trunk/codegenerator/src/test/java/org/jboss/jca/codegenerator/SimpleTemplateTestCase.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/test/java/org/jboss/jca/codegenerator/SimpleTemplateTestCase.java 2010-04-23 11:00:30 UTC (rev 104191)
+++ projects/jboss-jca/trunk/codegenerator/src/test/java/org/jboss/jca/codegenerator/SimpleTemplateTestCase.java 2010-04-23 11:14:43 UTC (rev 104192)
@@ -62,6 +62,6 @@
StringWriter writer = new StringWriter();
template.process(def, writer);
assertTrue(writer.toString().indexOf("org.jboss.jca.test") > 0);
- //System.out.println(writer.toString());
+ assertTrue(writer.toString().indexOf("getMyProp") > 0);
}
}
Deleted: projects/jboss-jca/trunk/codegenerator/src/test/resources/test.template
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/test/resources/test.template 2010-04-23 11:00:30 UTC (rev 104191)
+++ projects/jboss-jca/trunk/codegenerator/src/test/resources/test.template 2010-04-23 11:14:43 UTC (rev 104192)
@@ -1,10 +0,0 @@
-package ${package.name};
-import javax.resource.spi.ResourceAdapter;
-import org.jboss.logging.Logger;
-/**
- * ${class.name}
- */
-public class ${class.name} implements ResourceAdapter
-{
- private static Logger log = Logger.getLogger(${class.name}.class);
-}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list