1 18 package org.apache.activemq.maven; 19 20 import org.apache.activemq.tool.JmsConsumerSystem; 21 import org.apache.maven.plugin.AbstractMojo; 22 import org.apache.maven.plugin.MojoExecutionException; 23 24 import java.util.Properties ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import java.util.ArrayList ; 28 import java.util.Set ; 29 import java.util.HashSet ; 30 31 37 public class ConsumerMojo extends AbstractMojo { 38 39 private String [] validPrefix = { 40 "sysTest.", 41 "factory.", 42 "consumer.", 43 "tpSampler.", 44 "cpuSampler." 45 }; 46 47 public void execute() throws MojoExecutionException { 48 JmsConsumerSystem.main(createArgument()); 49 } 50 51 protected String [] createArgument() { 52 List args = new ArrayList (); 53 Properties sysProps = System.getProperties(); 54 Set keys = new HashSet (sysProps.keySet()); 55 56 for (Iterator i=keys.iterator(); i.hasNext();) { 57 String key = (String )i.next(); 58 if (isRecognizedProperty(key)) { 59 args.add(key + "=" + sysProps.remove(key)); 60 } 61 } 62 return (String [])args.toArray(new String [0]); 63 } 64 65 protected boolean isRecognizedProperty(String key) { 66 for (int j=0; j<validPrefix.length; j++) { 67 if (key.startsWith(validPrefix[j])) { 68 return true; 69 } 70 } 71 return false; 72 } 73 } 74 | Popular Tags |