diff --git a/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java b/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java index 3703cbe6c..08f9a1774 100644 --- a/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java +++ b/mq/main/mq-jmsra/jmsra-ra/src/main/java/com/sun/messaging/jms/blc/EmbeddedBrokerRunner.java @@ -19,6 +19,7 @@ import java.util.Enumeration; import java.util.Properties; +import java.util.Set; import java.util.StringTokenizer; import java.util.Vector; import java.util.logging.Level; @@ -56,6 +57,31 @@ public class EmbeddedBrokerRunner implements BrokerEventListener { protected static final String _lgrMID_ERR = _lgrMIDPrefix + "3001: "; protected static final String _lgrMID_EXC = _lgrMIDPrefix + "4001: "; + private static final Set PARAMETER_NAMES = Set.of( + "-debug", + "-dbuser", + "-dbpassword", + "-dbpwd", + "-name", + "-nobind", + "-password", + "-pwd", + "-ldappassword", + "-ldappwd", + "-passfile", + "-backup", + "-restore", + "-cluster", + "-varhome", + "-jmqvarhome", + "-imqhome", + "-libhome", + "-javahome", + "-jrehome", + "-adminkeyfile", + "-reset", + "-activateServices"); + public EmbeddedBrokerRunner(String brokerInstanceName, String brokerBindAddress, int brokerPort, String brokerHomeDir, String brokerLibDir, String brokerVarDir, String brokerJavaDir, String brokerExtraArgs, boolean useJNDIRMIServiceURL, int rmiRegistryPort, boolean startRMIRegistry, boolean useSSLJMXConnector, boolean doBind, Properties sysProps) @@ -156,7 +182,7 @@ private void logSysPropsInbrokerLog(Properties props) { /** * Assemble a String[] of broker arguments corresponding to the supplied method arguments - * + * * @return The String[] of broker arguments */ private String[] assembleBrokerArgs(String brokerInstanceName, int brokerPort, String brokerHomeDir, String brokerLibDir, String brokerVarDir, @@ -167,9 +193,13 @@ private String[] assembleBrokerArgs(String brokerInstanceName, int brokerPort, S // Add extra args first; explicit config will override args if (brokerExtraArgs != null && !("".equals(brokerExtraArgs))) { StringTokenizer st = new StringTokenizer(brokerExtraArgs, " "); - while (st.hasMoreTokens()) { - String t = st.nextToken(); - v.add(t); + if (st.countTokens() > 2) { + processBrokerExtraArgs(st, v); + } else { + while (st.hasMoreTokens()) { + String t = st.nextToken(); + v.add(t); + } } } @@ -225,9 +255,38 @@ private String[] assembleBrokerArgs(String brokerInstanceName, int brokerPort, S return brokerArgs; } + /** + * This method separates the parameter names from the values considering blank spaces + * + * @param st StringTokenizer containing the available tokens + * @param v Reference of the Vector object to save the parameter and the value in consecutive order + */ + private static void processBrokerExtraArgs(StringTokenizer st, Vector v) { + StringBuilder builderValue = new StringBuilder(); + while (st.hasMoreTokens()) { + String s = st.nextToken(); + if (PARAMETER_NAMES.contains(s)) { + if (!builderValue.isEmpty()) { + v.add(builderValue.toString()); + builderValue.delete(0, builderValue.length()); + } + v.add(s); + continue; + } + builderValue.append(s); + if (st.hasMoreTokens()){ + builderValue.append(" "); + } + } + + if (!builderValue.isEmpty()) { + v.add(builderValue.toString()); + } + } + /** * Create the in-JVM broker instance - * + * * Requires field: brokerType Sets fields: directBroker */ private void createTheInVMBrokerInstance() throws ClassNotFoundException, IllegalAccessException, InstantiationException { @@ -252,9 +311,9 @@ private void createTheInVMBrokerInstance() throws ClassNotFoundException, Illega /** * Parse the supplied broker arguments and convert them into a Properties object - * + * * Requires fields: brokerType, apiDirectBroker or raDirectBroker - * + * * @param brokerArgs the supplied broker arguments * @return a Properties object corresponding to the supplied arguments */