📄 testingclientobject.java
字号:
/*
* TestingClientObject.java
*
* Created on 19 November 2006, 15:58
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package uk.ac.kent.dpa.coord.clients;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.globus.stubs.TestingService_instance.*;
import org.globus.stubs.TestingService_instance.service.TestingServiceAddressingLocator;
import org.w3c.dom.Element;
import org.globus.wsrf.security.Constants;
import javax.xml.rpc.Stub;
import org.globus.wsrf.impl.security.descriptor.ClientSecurityDescriptor;
import org.globus.wsrf.impl.security.authorization.NoAuthorization;
//import javax.security.auth.*;
import org.globus.axis.util.Util;
/**
*
* @author ls97
*/
public class TestingClientObject {
private String serviceURI;
private String descFile;
static {
Util.registerTransport();
}
/** Creates a new instance of TestingClientObject */
public TestingClientObject(String uriIn, String desc) throws TestingClientException {
if (uriIn==null) throw new TestingClientException("the service URI must be set");
this.serviceURI = uriIn;
this.descFile = desc;
}
public void watch(int minutes) throws TestingClientException {
TestingServiceAddressingLocator locator = new TestingServiceAddressingLocator();
try {
// Create endpoint reference to service
EndpointReferenceType endpoint = new EndpointReferenceType();
endpoint.setAddress(new Address(this.serviceURI));
TestingPortType simulate = locator.getTestingPortTypePort(endpoint);
String CLIENT_DESC = this.descFile;
simulate = locator.getTestingPortTypePort(endpoint);
((Stub)simulate)._setProperty(Constants.CLIENT_DESCRIPTOR_FILE,CLIENT_DESC);
((Stub)simulate)._setProperty(Constants.GSI_SEC_CONV,Constants.ENCRYPTION);
((Stub)simulate)._setProperty(Constants.AUTHORIZATION,NoAuthorization.getInstance());
try {
DomyResponse resp = simulate.watch(minutes);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
throw new TestingClientException(this.serviceURI+" does not exist "+e.getMessage());
}
}
public void start(int minutes) throws TestingClientException {
TestingServiceAddressingLocator locator = new TestingServiceAddressingLocator();
try {
// Create endpoint reference to service
EndpointReferenceType endpoint = new EndpointReferenceType();
endpoint.setAddress(new Address(this.serviceURI));
TestingPortType simulate = locator.getTestingPortTypePort(endpoint);
String CLIENT_DESC = this.descFile;
simulate = locator.getTestingPortTypePort(endpoint);
((Stub)simulate)._setProperty(Constants.CLIENT_DESCRIPTOR_FILE,CLIENT_DESC);
((Stub)simulate)._setProperty(Constants.GSI_SEC_CONV,Constants.ENCRYPTION);
((Stub)simulate)._setProperty(Constants.AUTHORIZATION,NoAuthorization.getInstance());
try {
DomyResponse resp = simulate.start(minutes);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
throw new TestingClientException(this.serviceURI+" does not exist "+e.getMessage());
}
}
public void stop() throws TestingClientException {
TestingServiceAddressingLocator locator = new TestingServiceAddressingLocator();
try {
// Create endpoint reference to service
EndpointReferenceType endpoint = new EndpointReferenceType();
endpoint.setAddress(new Address(this.serviceURI));
TestingPortType simulate = locator.getTestingPortTypePort(endpoint);
String CLIENT_DESC = this.descFile;
simulate = locator.getTestingPortTypePort(endpoint);
((Stub)simulate)._setProperty(Constants.CLIENT_DESCRIPTOR_FILE,CLIENT_DESC);
((Stub)simulate)._setProperty(Constants.GSI_SEC_CONV,Constants.ENCRYPTION);
((Stub)simulate)._setProperty(Constants.AUTHORIZATION,NoAuthorization.getInstance());
try {
StopRequest req = new StopRequest();
DomyResponse resp = simulate.stop(req);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
throw new TestingClientException(this.serviceURI+" does not exist "+e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -