activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r930206 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: store/jdbc/Statements.java store/jdbc/adapter/DefaultJDBCAdapter.java util/GenerateJDBCStatements.java
Date Fri, 02 Apr 2010 09:38:47 GMT
Author: dejanb
Date: Fri Apr  2 09:38:46 2010
New Revision: 930206

URL: http://svn.apache.org/viewvc?rev=930206&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2681 - typo fixed and generate jdbc statements
class

Added:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java?rev=930206&r1=930205&r2=930206&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
Fri Apr  2 09:38:46 2010
@@ -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) {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java?rev=930206&r1=930205&r2=930206&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java
Fri Apr  2 09:38:46 2010
@@ -298,7 +298,7 @@ public class DefaultJDBCAdapter implemen
         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);
                 }

Added: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java?rev=930206&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java
(added)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java
Fri Apr  2 09:38:46 2010
@@ -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("<", "&lt;").replace(">", "&gt;");
+    	
+    }
+	/**
+	 * @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>");
+    	
+
+	}
+
+}



Mime
View raw message