修改 builder
This commit is contained in:
parent
05d692f066
commit
ca47ba3abc
1
pom.xml
1
pom.xml
@ -76,7 +76,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--<dependency>-->
|
<!--<dependency>-->
|
||||||
<!--<groupId>club.fullstack</groupId>-->
|
<!--<groupId>club.fullstack</groupId>-->
|
||||||
<!--<artifactId>serialize</artifactId>-->
|
<!--<artifactId>serialize</artifactId>-->
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package racal.sunyard.main;
|
package racal.sunyard.main;
|
||||||
|
|
||||||
|
import com.sun.xml.internal.fastinfoset.Encoder;
|
||||||
import com.sunyard.SydApi;
|
import com.sunyard.SydApi;
|
||||||
import com.sunyard.SydApiException;
|
import com.sunyard.SydApiException;
|
||||||
|
|
||||||
@ -10,21 +11,12 @@ public class SydApiBuilder {
|
|||||||
private String pwd;
|
private String pwd;
|
||||||
private int timeout = 3000;
|
private int timeout = 3000;
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
|
private String encode = Encoder.UTF_8;
|
||||||
private boolean useEBCDMode = false;
|
private boolean useEBCDMode = false;
|
||||||
private boolean useETEncrypt = false;
|
private boolean useETEncrypt = false;
|
||||||
private ClassLoader classLoader;
|
|
||||||
private String encode="UTF-8";
|
|
||||||
|
|
||||||
public String getEncode() {
|
|
||||||
return encode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEncode(String encode) {
|
|
||||||
this.encode = encode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public SydApi build() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
public SydApi build(){
|
||||||
|
|
||||||
if ( null == ip || "".equals(ip) ){
|
if ( null == ip || "".equals(ip) ){
|
||||||
throw new SydApiException("ip 配置不正确", 40000);
|
throw new SydApiException("ip 配置不正确", 40000);
|
||||||
@ -34,23 +26,19 @@ public class SydApiBuilder {
|
|||||||
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
System.setProperty("com.sunyard.sydapi4j.debug", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
Class clazz = classLoader.loadClass("racal.sunyard.main.SydApi4j");
|
SydApi4j api = new SydApi4j();
|
||||||
Object api = clazz.newInstance();
|
api.keepBuilder(this);
|
||||||
|
api.connect( ip , port, pwd, timeout);
|
||||||
|
return api;
|
||||||
// SydApi4j api = new SydApi4j();
|
|
||||||
// api.keepBuilder(this);
|
|
||||||
// api.connect( ip , port, pwd, timeout);
|
|
||||||
return (SydApi) api;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ClassLoader getClassLoader() {
|
public String getEncode() {
|
||||||
return classLoader;
|
return encode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClassLoader(ClassLoader classLoader) {
|
public void setEncode(String encode) {
|
||||||
this.classLoader = classLoader;
|
this.encode = encode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIp() {
|
public String getIp() {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.sunyard.sydapi.loadrunner;
|
package com.sunyard.sydapi.loadrunner;
|
||||||
|
|
||||||
|
import com.sunyard.sydapi.loadrunner.action1.Actions;
|
||||||
import racal.sunyard.main.SydApi4j;
|
import racal.sunyard.main.SydApi4j;
|
||||||
import racal.sunyard.main.SydApiBuilder;
|
import racal.sunyard.main.SydApiBuilder;
|
||||||
|
|
||||||
@ -37,15 +38,15 @@ public class ShangTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
public static void main(String[] args) throws Throwable {
|
||||||
|
|
||||||
|
|
||||||
System.out.println( SydApi4j.getVersion() );
|
System.out.println( SydApi4j.getVersion() );
|
||||||
|
|
||||||
ShangTest test = new ShangTest();
|
Actions test = new Actions();
|
||||||
test.init();
|
test.init();
|
||||||
test.hash4();
|
test.action();
|
||||||
test.destroy();
|
test.end();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.sunyard.sydapi.loadrunner.action1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LoadRunner Java script. (Build: _build_number_)
|
||||||
|
*
|
||||||
|
* Script Description:
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
import racal.sunyard.main.SydApi4j;
|
||||||
|
import racal.sunyard.main.SydApiBuilder;
|
||||||
|
|
||||||
|
public class Actions
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final byte[] testData = new byte[ 4 * 1024 ];
|
||||||
|
|
||||||
|
private SydApi4j api = null;
|
||||||
|
|
||||||
|
public int init() throws Throwable {
|
||||||
|
api = (SydApi4j) new SydApiBuilder()
|
||||||
|
.setIp("172.16.18.59")
|
||||||
|
.setPort( 8889 )
|
||||||
|
.useDebugMode()
|
||||||
|
.build();
|
||||||
|
return 0;
|
||||||
|
}//end of init
|
||||||
|
|
||||||
|
|
||||||
|
public int action() throws Throwable {
|
||||||
|
api.SM3Hash( testData );
|
||||||
|
return 0;
|
||||||
|
}//end of action
|
||||||
|
|
||||||
|
|
||||||
|
public int end() throws Throwable {
|
||||||
|
if (null != this.api ) {
|
||||||
|
this.api.disconnect();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}//end of end
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user