JCO3 원격 호출 SAP 인터페이스 에세이 1(연결 풀 구성)

8382 단어 종합하다
1. 구성 환경: 1.sapjco3 다운로드dll 플러그인은 JDK, bin 폴더 아래에 있습니다. 2.sapjco3 다운로드jar 설치 공사 중
둘째, 액세스 속성 파일 SAP ConnectionPool을 구성합니다.properties
#sap IP , , IP /H/ IP/H/192.168.0.10 
jco.client.ashost=192.168.0.10 
#     
jco.client.sysnr=01
# client 
jco.client.client=999
jco.client.user=likb
jco.client.passwd=330330
jco.destination.pool_capacity=3
jco.destination.peak_limit=10
jco.client.lang=ZH

3. 인터페이스를 사용할 때 SAP ConnectionPool 클래스를 호출하기 위해 링크 탱크 링크 자바 클래스를 봉인합니다.
@Service("SAPConnectionPool")
public class SAPConnectionPool {
    private static final String SAP_CONN="SAP_CONN";

    public static JCoDestination getSAPDestination(){
        try {
            JCoDestination dest = JCoDestinationManager.getDestination(SAP_CONN);
            return dest;
        } catch (JCoException ex) {
                System.out.println(ex);
                System.out.println(" ");
                // 
                return RegetJocodestination();
        }           
    }   

    /*****
    * @author     :QZC
    * @createDate :2015 8 27   11:08:47
    *  : JCODestination
    * @return
    ****
     */
    public static JCoDestination RegetJocodestination(){
        try{
            Properties properFile = new Properties();
            ClassLoader cl=Thread.currentThread().getContextClassLoader();
            String filePath=cl.getResource("").toString()+"SAPConnectionPool.properties";
            filePath=filePath.replace("file:", "");
            FileInputStream inputFile = new FileInputStream(filePath);
            properFile.load(inputFile);
            inputFile.close();

            Properties connectProperties = new Properties();
            connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, properFile.getProperty("jco.client.ashost"));
            connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  properFile.getProperty("jco.client.sysnr"));
            connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, properFile.getProperty("jco.client.client"));
            connectProperties.setProperty(DestinationDataProvider.JCO_USER,   properFile.getProperty("jco.client.user"));
            connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, properFile.getProperty("jco.client.passwd"));
            connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, properFile.getProperty("jco.destination.pool_capacity"));
            connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT,   properFile.getProperty("jco.destination.peak_limit"));
            connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   properFile.getProperty("jco.client.lang"));

            CustomDestinationDataProvider provider = new CustomDestinationDataProvider();
            provider.addDestinationProperties(SAP_CONN, connectProperties);
            Environment.registerDestinationDataProvider(provider);
            try {
                JCoDestination dest = JCoDestinationManager.getDestination(SAP_CONN);
                return dest;
            } catch (JCoException ex) {
                    System.out.println(ex);
                    System.out.println(" ");
            }           
        }catch(Exception e){
            e.printStackTrace();
        }
        return null;        
    }

}

링크 가져오기 보조 처리 클래스: CustomDestinationDataProvider.java
public class CustomDestinationDataProvider implements DestinationDataProvider {
    private Map providers = new HashMap();
    @Override
    public Properties getDestinationProperties(String destName) {
       if (destName == null)
           throw new NullPointerException(" ");
       if (providers.size() == 0)
           throw new IllegalStateException(" ");
       return (Properties)providers.get(destName);
   }

   //  
   @Override
   public boolean supportsEvents(){
       return false;
   }

   @Override
   public void setDestinationDataEventListener(DestinationDataEventListener listener) {
       throw new UnsupportedOperationException();
   }

   public void addDestinationProperties(String destName, Properties provider) {
       providers.put(destName, provider);
   }
}

좋은 웹페이지 즐겨찾기