mirror of https://github.com/apache/activemq.git
https://issues.apache.org/activemq/browse/AMQ-2681 - typo fixed and generate jdbc statements class
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@930206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
03d355e97e
commit
d22e841db9
|
@ -38,7 +38,7 @@ public class Statements {
|
|||
private String tablePrefix = "";
|
||||
private String addMessageStatement;
|
||||
private String updateMessageStatement;
|
||||
private String removeMessageStatment;
|
||||
private String removeMessageStatement;
|
||||
private String findMessageSequenceIdStatement;
|
||||
private String findMessageStatement;
|
||||
private String findMessageByIdStatement;
|
||||
|
@ -118,11 +118,11 @@ public class Statements {
|
|||
return updateMessageStatement;
|
||||
}
|
||||
|
||||
public String getRemoveMessageStatment() {
|
||||
if (removeMessageStatment == null) {
|
||||
removeMessageStatment = "DELETE FROM " + getFullMessageTableName() + " WHERE ID=?";
|
||||
public String getRemoveMessageStatement() {
|
||||
if (removeMessageStatement == null) {
|
||||
removeMessageStatement = "DELETE FROM " + getFullMessageTableName() + " WHERE ID=?";
|
||||
}
|
||||
return removeMessageStatment;
|
||||
return removeMessageStatement;
|
||||
}
|
||||
|
||||
public String getFindMessageSequenceIdStatement() {
|
||||
|
@ -584,8 +584,8 @@ public class Statements {
|
|||
this.removeAllSubscriptionsStatement = removeAllSubscriptionsStatment;
|
||||
}
|
||||
|
||||
public void setRemoveMessageStatment(String removeMessageStatment) {
|
||||
this.removeMessageStatment = removeMessageStatment;
|
||||
public void setRemoveMessageStatment(String removeMessageStatement) {
|
||||
this.removeMessageStatement = removeMessageStatement;
|
||||
}
|
||||
|
||||
public void setUpdateLastAckOfDurableSubStatement(String updateLastAckOfDurableSub) {
|
||||
|
|
|
@ -298,7 +298,7 @@ public class DefaultJDBCAdapter implements JDBCAdapter {
|
|||
PreparedStatement s = c.getRemovedMessageStatement();
|
||||
try {
|
||||
if (s == null) {
|
||||
s = c.getConnection().prepareStatement(this.statements.getRemoveMessageStatment());
|
||||
s = c.getConnection().prepareStatement(this.statements.getRemoveMessageStatement());
|
||||
if (this.batchStatments) {
|
||||
c.setRemovedMessageStatement(s);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package org.apache.activemq.util;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.activemq.store.jdbc.Statements;
|
||||
|
||||
|
||||
public class GenerateJDBCStatements {
|
||||
public static String returnStatement(Object statement){
|
||||
return ((String)statement).replace("<", "<").replace(">", ">");
|
||||
|
||||
}
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) throws Exception{
|
||||
Statements s=new Statements();
|
||||
s.setTablePrefix("ACTIVEMQ.");
|
||||
String[] stats=s.getCreateSchemaStatements();
|
||||
System.out.println("<bean id=\"statements\" class=\"org.apache.activemq.store.jdbc.Statements\">");
|
||||
System.out.println("<property name=\"createSchemaStatements\">");
|
||||
System.out.println("<list>");
|
||||
for(int i=0; i<stats.length;i++){
|
||||
System.out.println("<value>"+stats[i]+"</value>");
|
||||
}
|
||||
System.out.println("</list>");
|
||||
System.out.println("</property>");
|
||||
|
||||
|
||||
Method[] methods=Statements.class.getMethods();
|
||||
Pattern sPattern= Pattern.compile("get.*Statement$");
|
||||
Pattern setPattern= Pattern.compile("set.*Statement$");
|
||||
ArrayList<String> setMethods=new ArrayList<String>();
|
||||
for(int i=0; i<methods.length;i++){
|
||||
if(setPattern.matcher(methods[i].getName()).find()){
|
||||
setMethods.add(methods[i].getName());
|
||||
}
|
||||
}
|
||||
for(int i=0; i<methods.length;i++){
|
||||
if(sPattern.matcher(methods[i].getName()).find()&&setMethods.contains(methods[i].getName().replace("get","set"))){
|
||||
System.out.println("<property name=\""+methods[i].getName().substring(3,4).toLowerCase()+methods[i].getName().substring(4)+"\" value=\""+returnStatement(methods[i].invoke(s, null))+"\" />");
|
||||
}
|
||||
}
|
||||
//for a typo is not needed if removeMessageStatment typo is corrected
|
||||
Pattern sPattern2= Pattern.compile("get.*Statment$");
|
||||
for(int i=0; i<methods.length;i++){
|
||||
if(sPattern2.matcher(methods[i].getName()).find()){
|
||||
System.out.println("<property name=\""+methods[i].getName().substring(3,4).toLowerCase()+methods[i].getName().substring(4)+"\" value=\""+returnStatement(methods[i].invoke(s, null))+"\" />");
|
||||
}
|
||||
}
|
||||
//end of generating because of typo
|
||||
|
||||
String[] statsDrop=s.getDropSchemaStatements();
|
||||
System.out.println("<property name=\"dropSchemaStatements\">");
|
||||
System.out.println("<list>");
|
||||
for(int i=0; i<statsDrop.length;i++){
|
||||
System.out.println("<value>"+statsDrop[i]+"</value>");
|
||||
}
|
||||
System.out.println("</list>");
|
||||
System.out.println("</property>");
|
||||
System.out.println("</bean>");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue