Skip to content

Commit bdd7f77

Browse files
committed
review changes
1 parent 0fff9ae commit bdd7f77

8 files changed

Lines changed: 43 additions & 39 deletions

File tree

java/src/main/java/com/cybersource/ws/client/Client.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static Map runTransaction(
9999
MerchantConfig mc;
100100
LoggerWrapper logger = null;
101101
Connection con = null;
102-
Object client_class_obj;
102+
103103

104104
try {
105105
setVersionInformation(request);
@@ -125,19 +125,19 @@ public static Map runTransaction(
125125
// FileWriter writer = new FileWriter(new File("signedDoc.xml"));
126126
// writer.write(XMLUtils.PrettyDocumentToString(signedDoc));
127127
// writer.close();
128-
if(mc.isClientHttpFactoryEnabled()){
129-
Class<Connection> custom_connection_class;
128+
if(mc.iscustomHttpClassEnabled()){
129+
Class<Connection> customConnectionClass;
130130
try {
131-
custom_connection_class = (Class<Connection>) Class.forName(mc.getUseClientHttpFactory());
131+
customConnectionClass = (Class<Connection>) Class.forName(mc.getcustomHttpClass());
132132
Class[] constructor_Args = new Class[] {com.cybersource.ws.client.MerchantConfig.class, javax.xml.parsers.DocumentBuilder.class, com.cybersource.ws.client.LoggerWrapper.class};
133-
con=custom_connection_class.getDeclaredConstructor(constructor_Args).newInstance(mc, builder, logger);
134-
//con=((Connection) client_class_obj).getConnection();
133+
con=customConnectionClass.getDeclaredConstructor(constructor_Args).newInstance(mc, builder, logger);
134+
135135
} catch (InstantiationException e) {
136136
throw new ClientException(e, false, null);
137137
} catch (IllegalAccessException e) {
138138
throw new ClientException(e, false, null);
139139
} catch (ClassNotFoundException e) {
140-
System.out.println("could not load class amazon "+e);
140+
logger.log(Logger.LT_INFO, "Could not load the custom class ");
141141
throw new ClientException(e, false, null);
142142
} catch (IllegalArgumentException e) {
143143
throw new ClientException(e, false, null);

java/src/main/java/com/cybersource/ws/client/Connection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ abstract class Connection {
4848
private final DocumentBuilder builder;
4949
final LoggerWrapper logger;
5050

51-
Connection(MerchantConfig mc, DocumentBuilder builder,
51+
protected Connection(MerchantConfig mc, DocumentBuilder builder,
5252
LoggerWrapper logger) {
5353
this.mc = mc;
5454
this.builder = builder;

java/src/main/java/com/cybersource/ws/client/MerchantConfig.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ public class MerchantConfig {
6464
private String proxyUser;
6565
private String proxyPassword;
6666
private String cacertPassword;
67-
private String useClientHttpFactory;
68-
private boolean ClientHttpFactoryEnabled;
67+
private String customHttpClass;
68+
private boolean customHttpClassEnabled;
6969

70-
public String getUseClientHttpFactory() {
71-
return useClientHttpFactory;
70+
public String getcustomHttpClass() {
71+
return customHttpClass;
7272
}
73-
public boolean isClientHttpFactoryEnabled() {
74-
return ClientHttpFactoryEnabled;
73+
public boolean iscustomHttpClassEnabled() {
74+
return customHttpClassEnabled;
7575
}
7676
// computed values
7777
private String effectiveServerURL;
@@ -261,7 +261,7 @@ public MerchantConfig(Properties _props, String _merchantID)
261261
logFilename = getProperty(merchantID, "logFilename");
262262
logMaximumSize = getIntegerProperty(merchantID, "logMaximumSize", 10);
263263
useHttpClient = getBooleanProperty(merchantID, "useHttpClient", ConnectionHelper.getDefaultUseHttpClient());
264-
useClientHttpFactory = getProperty(merchantID, "useClientHttpFactory");
264+
customHttpClass = getProperty(merchantID, "customHttpClass");
265265
timeout = getIntegerProperty(merchantID, "timeout", DEFAULT_TIMEOUT);
266266
proxyHost = getProperty(merchantID, "proxyHost");
267267
proxyPort = getIntegerProperty(merchantID, "proxyPort", DEFAULT_PROXY_PORT);
@@ -270,7 +270,7 @@ public MerchantConfig(Properties _props, String _merchantID)
270270
enableJdkCert = getBooleanProperty(merchantID, "enableJdkCert", false);
271271
enableCacert=getBooleanProperty(merchantID, "enableCacert", false);
272272
cacertPassword=getProperty(merchantID,"cacertPassword","changeit");
273-
ClientHttpFactoryEnabled=getBooleanProperty(merchantID,"ClientHttpFactoryEnabled",false);
273+
customHttpClassEnabled=getBooleanProperty(merchantID,"customHttpClassEnabled",false);
274274
// compute and store effective namespace URI
275275

276276
if (namespaceURI == null && targetAPIVersion == null) {
@@ -473,8 +473,8 @@ public String getLogString() {
473473
appendPair(sb, "logDirectory", logDirectory);
474474
appendPair(sb, "logFilename", logFilename);
475475
appendPair(sb, "logMaximumSize", logMaximumSize);
476-
appendPair(sb, "useClientHttpFactory", useClientHttpFactory);
477-
appendPair(sb, "useClientHttpFactoryFlag", ClientHttpFactoryEnabled);
476+
appendPair(sb, "customHttpClass", customHttpClass);
477+
appendPair(sb, "customHttpClassEnabled", customHttpClassEnabled);
478478
appendPair(sb, "useHttpClient", useHttpClient);
479479
appendPair(sb, "enableJdkCert", enableJdkCert);
480480
appendPair(sb, "enableCacert", enableCacert);

java/src/main/java/com/cybersource/ws/client/XMLClient.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public class XMLClient {
6565

6666
private static Document soapEnvelope;
6767
private static Exception initException = null;
68-
private static Object client_class_obj;
69-
private static Class<Connection> clientclass;
68+
69+
7070
static {
7171
try {
7272
// load the SOAP envelope document.
@@ -180,18 +180,19 @@ public static Document runTransaction(
180180

181181
Document signedDoc
182182
= soapWrapAndSign(request, mc, builder, logger);
183-
if(mc.isClientHttpFactoryEnabled()){
184-
Class<Connection> custom_connection_class;
183+
if(mc.iscustomHttpClassEnabled()){
184+
Class<Connection> customConnectionClass;
185185
try {
186-
custom_connection_class = (Class<Connection>) Class.forName(mc.getUseClientHttpFactory());
186+
customConnectionClass = (Class<Connection>) Class.forName(mc.getcustomHttpClass());
187187
Class[] constructor_Args = new Class[] {com.cybersource.ws.client.MerchantConfig.class, javax.xml.parsers.DocumentBuilder.class, com.cybersource.ws.client.LoggerWrapper.class};
188-
con=custom_connection_class.getDeclaredConstructor(constructor_Args).newInstance(mc, builder, logger);
189-
//con=((Connection) client_class_obj).getConnection();
188+
con=customConnectionClass.getDeclaredConstructor(constructor_Args).newInstance(mc, builder, logger);
189+
190190
} catch (InstantiationException e) {
191191
throw new ClientException(e, false, null);
192192
} catch (IllegalAccessException e) {
193193
throw new ClientException(e, false, null);
194194
} catch (ClassNotFoundException e) {
195+
logger.log(Logger.LT_INFO, "Could not load the custom HTTP class ");
195196
throw new ClientException(e, false, null);
196197
} catch (IllegalArgumentException e) {
197198
throw new ClientException(e, false, null);

java/src/main/resources/cybs.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ allowRetry=true
3232
numberOfRetries=5
3333
retryInterval=5
3434

35-
#To use your own Http library set ClientHttpFactoryEnabled to true
36-
# set useClientHttpFactory field with the class name which has Http implementation. Provide the full class with package name.
37-
#ClientHttpFactoryEnabled=
38-
#useClientHttpFactory=
35+
36+
#To use your own Http library set customHttpClassEnabled to true
37+
# set customHttpClass field with the class name which has Http implementation. Provide the full class with package name.
38+
#customHttpClassEnabled=
39+
#customHttpClass=
3940

4041
# If This property is set to true then the p12 certificate must be stored in JKS format
4142
# program will read it from there. If it is set to false then the certificate will be read from

java/src/test/java/com/cybersource/ws/client/AmazonHttpConnection.java renamed to java/src/test/java/com/cybersource/ws/client/CustomHttpConnectionClass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
import org.w3c.dom.Document;
2929

3030

31-
public class AmazonHttpConnection extends Connection{
31+
public class CustomHttpConnectionClass extends Connection{
3232
private PostMethod postMethod = null;
3333

34-
AmazonHttpConnection(MerchantConfig mc, DocumentBuilder builder, LoggerWrapper logger) {
34+
CustomHttpConnectionClass(MerchantConfig mc, DocumentBuilder builder, LoggerWrapper logger) {
3535
super(mc, builder, logger);
3636
}
3737

samples/nvp/cybs.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ allowRetry=true
2727
numberOfRetries=5
2828
retryInterval=5
2929

30-
#To use your own Http library set ClientHttpFactoryEnabled to true
31-
# set useClientHttpFactory field with the class name which has Http implementation. Provide the full class with package name.
32-
#ClientHttpFactoryEnabled=
33-
#useClientHttpFactory=
30+
31+
#To use your own Http library set customHttpClassEnabled to true
32+
# set customHttpClass field with the class name which has Http implementation. Provide the full class with package name.
33+
#customHttpClassEnabled=
34+
#customHttpClass=
3435

3536
# If This property is set to true then the p12 certificate must be stored in JKS format
3637
# program will read it from there. If it is set to false then the certificate will be read from

samples/xml/cybs.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ allowRetry=true
2727
numberOfRetries=5
2828
retryInterval=5
2929

30-
#To use your own Http library set ClientHttpFactoryEnabled to true
31-
# set useClientHttpFactory field with the class name which has Http implementation. Provide the full class with package name.
32-
#ClientHttpFactoryEnabled=
33-
#useClientHttpFactory=
30+
31+
#To use your own Http library set customHttpClassEnabled to true
32+
# set customHttpClass field with the class name which has Http implementation. Provide the full class with package name.
33+
#customHttpClassEnabled=
34+
#customHttpClass=
3435

3536
# If This property is set to true then the p12 certificate must be stored in JKS format
3637
# program will read it from there. If it is set to false then the certificate will be read from

0 commit comments

Comments
 (0)