解決axis2在tomcat的temp中產生大量的臨時文件

解決在使用axis2時,每一次請求產生axis2jar臨時文件,導致佔用大量磁盤空間問題。

方法:在axis2生成的客戶端的Stub類中,設置org.apache.axis2.context.ConfigurationContextFactory第1、2兩個參數爲null。

一、使用Spring設置Stub:

Stub:

       < bean id ="stub" class ="...Stub" scope ="prototype" >
             < constructor-arg ref ="axisConfigContext" />
       </ bean>
org.apache.axis2.context.ConfigurationContextFactory設置:
       < bean id ="axisConfigContext"
                   class ="org.apache.axis2.context.ConfigurationContextFactory"
                   factory-method ="createConfigurationContextFromFileSystem" >
             < constructor-arg index ="0" >< null /></ constructor-arg>
             < constructor-arg index ="1" >< null /></ constructor-arg>
       </ bean>

二、代碼方式實現:

1、實例化一個Context配置:

private static ConfigurationContext configurationContext;
    static {
        try {
            configurationContext = ConfigurationContextFactory
.createConfigurationContextFromFileSystem(null, null);
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        }
}

2、配置到Stub中

YourServiceStub sd=new YourServiceStub(configurationContext);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章