activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tmie...@apache.org
Subject svn commit: r1234781 - /activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java
Date Mon, 23 Jan 2012 13:28:42 GMT
Author: tmielke
Date: Mon Jan 23 13:28:42 2012
New Revision: 1234781

URL: http://svn.apache.org/viewvc?rev=1234781&view=rev
Log:
AMQ-3665: Moved code for creating VelocityContext into its own method createVelocityContext().

Modified:
    activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java

Modified: activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java?rev=1234781&r1=1234780&r2=1234781&view=diff
==============================================================================
--- activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java
(original)
+++ activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/command/store/amq/AMQJournalTool.java
Mon Jan 23 13:28:42 2012
@@ -88,6 +88,30 @@ public class AMQJournalTool {
 		consumerTool.execute();
 	}
 
+	/**
+	 * Creates a new VelocityContext that is pre-populated with the JVMs
+	 * system properties. 
+	 * 
+	 * @return - the VelocityContext that got created.
+	 */
+	protected VelocityContext createVelocityContext() {
+		VelocityContext ctx = new VelocityContext();
+		List keys = Arrays.asList(ctx.getKeys());
+
+		for (Iterator iterator = System.getProperties().entrySet()
+				.iterator(); iterator.hasNext();) {
+			Map.Entry kv = (Map.Entry) iterator.next();
+			String name = (String) kv.getKey();
+			String value = (String) kv.getValue();
+
+			if (!keys.contains(name)) {
+				ctx.put(name, value);
+			}
+		}
+		return ctx;
+	}
+	
+	
 	public void execute() throws Exception {
 
 		if( help ) {
@@ -120,34 +144,20 @@ public class AMQJournalTool {
 			}
 		}
 		
-		
-		context = new VelocityContext();
-		List keys = Arrays.asList(context.getKeys());
-
-		for (Iterator iterator = System.getProperties().entrySet()
-				.iterator(); iterator.hasNext();) {
-			Map.Entry kv = (Map.Entry) iterator.next();
-			String name = (String) kv.getKey();
-			String value = (String) kv.getValue();
-
-			if (!keys.contains(name)) {
-				context.put(name, value);
-			}
-		}
+		context = createVelocityContext();
 		
 		velocity = new VelocityEngine();
 		velocity.setProperty(Velocity.RESOURCE_LOADER, "all");
 		velocity.setProperty("all.resource.loader.class", CustomResourceLoader.class.getName());
 		velocity.init();
 
-
 		resources.put("message", messageFormat);
 		resources.put("topicAck", topicAckFormat);
 		resources.put("queueAck", queueAckFormat);
 		resources.put("transaction", transactionFormat);
 		resources.put("trace", traceFormat);
 		resources.put("unknown", unknownFormat);
-
+		
 		Query query = null;
 		if (where != null) {
 			query = new Query();
@@ -171,7 +181,7 @@ public class AMQJournalTool {
 				entry.setQuery(query);
 				process(entry);
 
-				curr = manager.getNextLocation(curr);
+				curr = manager.getNextLocation(curr);		
 			}
 		} finally {
 			manager.close();
@@ -189,7 +199,6 @@ public class AMQJournalTool {
 
 	private void process(Entry entry) throws Exception {
 
-		Location location = entry.getLocation();
 		DataStructure record = entry.getRecord();
 
 		switch (record.getDataStructureType()) {



Mime
View raw message