ServiceClass service = new ServiceClass(clienttype, requestXml);
new InsertThread(service).start();
提示错误信息如下:
No enclosing instance of type OrderServices is accessible. Must qualify the allocation with an enclosing instance of type OrderServices (e.g. x.new A()
where x is an instance of OrderServices).
内部类如下:
class ServiceClass{
private AuthenticatorTBEServiceStub atss = null;
private String clienttype;
private String requestXml;
public ServiceClass(String clienttype,String requestXml){
this.clienttype = clienttype;
this.requestXml = requestXml;
}
public synchronized void insertService() throws RemoteException, ExceptionException{
atss = new AuthenticatorTBEServiceStub();
GetBookTicketE gbte = new GetBookTicketE();
GetBookTicket gbt = new GetBookTicket();
gbt.setClienttype(clienttype);
gbt.setQcbag(requestXml);
gbt.setQcresult(com.tempus.order.BookTicket.readBookXML(requestXml));
gbte.setGetBookTicket(gbt);
atss.getBookTicket(gbte);
}
public synchronized String responseXml(){
return com.tempus.order.BookTicket.readBookXML(requestXml);
}
}
class InsertThread extends Thread{
private ServiceClass service;
public InsertThread(ServiceClass service){
this.service = service;
}
@Override
public void run() {
super.run();
try {
Thread.sleep(100);
service.insertService();
} catch (RemoteException e) {
e.printStackTrace();
Logs.info("抛出RemoteException,添加数据时错误!");
} catch (ExceptionException e) {
e.printStackTrace();
Logs.info("抛出ExceptionException,添加数据时错误!");
}catch (InterruptedException e) {
e.printStackTrace();
Logs.info("抛出InterruptedException,添加数据时错误!");
}
}
}
class ResponseThread extends Thread{
private ServiceClass service;
public ResponseThread(ServiceClass service){
this.service = service;
}
@Override
public void run() {
super.run();
service.responseXml();
}
}