情况是这样的:
我使用Axis2 1.6.2并为2个Web服务生成了Stubs(带有 wsdl2java ) - 让我们称之为 WS#1 和 WS#2 。
我通过实现扩展BasePoolableObjectFactory(org.apache.commons.pool.BasePoolableObjectFactory)的StubPoolableFactory为Stubs使用池化机制
为了达到这个目的,Stubs被作为Singletons的Adapters“包裹”。适配器的骨架如下所示:
/** The Adapter class */
public class PdfServiceAdapter extends PoolableStubAdapter<PdfServiceStub> {
/** The Singleton. */
private static PdfServiceAdapter pdfServiceAdapter;
/**
* Gets the PdfService adapter instance.
*
* @return the PdfService adapter
*/
public synchronized static PdfServiceAdapter getPdfServiceAdapter() {
if (null == pdfServiceAdapter) {
pdfServiceAdapter = new PdfServiceAdapter();
pdfServiceAdapter.initiateStubPool();
}
return pdfServiceAdapter;
}
public void doSomething() throws AdapterException {
try {
stub = getStub();
} catch (final Exception e) {
throw new AdapterPreparationException(e);
}
try {
//call some actual Stub method here...
} catch (final Exception e) {
stopWatch.stop("PdfService.doSomething.FAILURE");
throw new AdapterExecutionException(e);
} finally {
final ServiceClient client = stub._getServiceClient();
if (client != null) {
try {
client.cleanupTransport();
client.cleanup();
} catch (final AxisFault e) {
log.warn("Something went wrong while cleaning up service client: ", e);
}
}
releaseStub(stub);
}
}
@Override
protected int getMaxActive() {
return Integer.parseInt(ESignatureConfig.getInstance().getConfig().getString(
"AXIS_STUB_POOL_EREQUEST_COMMUNICATION_MAX_ACTIVE"));
}
@Override
protected boolean getLifo() {
return Boolean.parseBoolean(ESignatureConfig.getInstance().getConfig().getString(
"AXIS_STUB_POOL_EREQUEST_COMMUNICATION_LIFO_FLAG"));
}
@Override
protected int getMaxIdle() {
return Integer.parseInt(ESignatureConfig.getInstance().getConfig().getString(
"AXIS_STUB_POOL_EREQUEST_COMMUNICATION_MAX_IDLE"));
}
@Override
protected long getMaxWait() {
return Integer.parseInt(ESignatureConfig.getInstance().getConfig().getString(
"AXIS_STUB_POOL_EREQUEST_COMMUNICATION_MAX_WAIT"));
}
@Override
protected String getEndPointURL() {
return ESignatureConfig.getInstance().getConfig().getString("PDF_SERVICE_ENDPONT");
}
@Override
protected Stub getInstance() throws Exception {
return new PdfServiceStub(AxisConfigurationContextFactory.getInstance().getConfigurationContext());
}
}
正如您在请求存根实例时所看到的那样,轴配置将传递给存根。 此Axis配置从工厂返回,它是Singleton,基于具有缓存HTTP客户端的MultiThreadedHttpConnectionManager 。
现在,问题出在哪里:
你认为这与我的实施有关吗? 也许Singleton Axis配置或某些环境下的缓存HTTP客户端负责此重置?