Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whitespaces #2109

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> 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)
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -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<String> 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 {
Expand All @@ -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
*/
Expand Down
Loading