JCO 自定义DestinationDataProvider
要让JAVA程序能访问SAP系统,一般通过SAP JCO接口进行通讯,在获取到SAP的连接时需求提供一些连接参数,这些参数在最新的 JCO 3.0 中需要被保存到一个带有扩展名.jcoDestination的文件中,这个文件同时被保存在应用程序的安装目录中。因为这只中一个纯文本文件,所有的连接参数并没有被加密,这样对于公用程序可能有安全问题。要使用登陆连接更加安全可以实现自定义的 DestinationDataProvider 实现:
此接口只有简单的三个方法:
interface DestinationDataProvider {
Properties getDestinationProperties(java.lang.String destinationName);
void setDestinationDataEventListener(DestinationDataEventListener eventListener);
boolean supportsEvents();
}
getDestinationProperties 当Java程序获取到SAP的连接时,jco会从这里读取连接属性,你可以编程动态的设定这些属性
setDestinationDataEventListener 设置一个连接事件监听器,实现一个监听器,当JCO连接SAP以获得通知
supportsEvents 返回是否被实现的DestinationDataProvider有事件监听器
实现一个自定义Provider:
static class MyDestinationDataProvider implements DestinationDataProvider
{
private DestinationDataEventListener eL; private Properties ABAP_AS_properties; public Properties getDestinationProperties(String destinationName)
{
if(destinationName.equals("ABAP_AS") && ABAP_AS_properties!=null)
return ABAP_AS_properties; return null;
//alternatively throw runtime exception
//throw new RuntimeException("Destination " + destinationName + " is not available");
} public void setDestinationDataEventListener(DestinationDataEventListener eventListener)
{
this.eL = eventListener;
} public boolean supportsEvents()
{
return true;
} void changePropertiesForABAP_AS(Properties properties)
{
if(properties==null)
{
eL.deleted("ABAP_AS");
ABAP_AS_properties = null;
}
else
{
if(ABAP_AS_properties!=null && !ABAP_AS_properties.equals(properties))
eL.updated("ABAP_AS");
ABAP_AS_properties = properties;
}
}
}
测试连接:
public static void main(String[] args) throws Exception
{
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "binmain");
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "53");
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "000");
connectProperties.setProperty(DestinationDataProvider.JCO_USER, "JCOTEST");
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "JCOTEST");
connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "en"); MyDestinationDataProvider myProvider = new MyDestinationDataProvider(); com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(myProvider);
myProvider.changePropertiesForABAP_AS(connectProperties); JCoDestination ABAP_AS = JCoDestinationManager.getDestination("ABAP_AS");
ABAP_AS.ping(); System.out.println("ABAP_AS destination is ok"); }
JCO 自定义DestinationDataProvider的更多相关文章
- SAP接口编程 之 JCo3.0系列(05) : Exception Handling
JCO3.0的Exception,常用的Exception如下: JCoException 继承自java.lang.Exception,是JCo3中Exception的基类. JCoRuntimeE ...
- Java(JCo3)与SAP系统相互调用
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- java call sap
1.下载需要的jar,windows用dll,linux用so win下载地址 linux下载地址 win下载地址new 2.环境: windows -> sapjco3.dll放到wi ...
- [SAP ABAP开发技术总结]BAPI调用
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- SAP接口编程 之 JCo3.0系列(01):JCoDestination
SAP接口编程 之 JCo3.0系列(01):JCoDestination 字数2101 阅读103 评论0 喜欢0 JCo3.0是Java语言与ABAP语言双向通讯的中间件.与之前1.0/2.0相比 ...
- JAVA连接SAP
1.首先需要在SAP事务码SE37中新建一个可以被远程调用的RFC 事务码:SE37 新建一个函数组:输入事务码SE37回车后,来到函数构建器屏幕,到上面一排菜单栏:转到 -> 函数组 -> ...
- SAP传输请求自动发布
最近公司服务器做迁移,原R3 PRE需要迁到另外的地方,迁移后一段时间内,需要两套PRE环境同时运行,过一段时间后才将传输路线切换到新的PRE.在切换前,要求新PRE环境也要正常同步发布请求, ...
- JAVA Hibersap 框架调用 SAP
In this example we will create a simple Maven project which uses Hibersap to call a function in SAP ...
- 使用Java connector消费ABAP系统的函数
Java Connector(JCO)环境的搭建:Step by step to download and configure JCO in your laptop 我的ABAP系统有个函数名叫ZDI ...
随机推荐
- FFmpeg YUV2RGB
AVFrame* YUV2RGB( AVCodecContext * avctx, AVFrame * frame ) { AVFrame* pFrameRGB=NULL; pFrameRGB=avc ...
- 代码规范审查 – Sonar分析项目
Sonar搭建成功之后,就可以通过简单的CMD指令进行项目分析,此篇主要介绍使用Sonar来分析.net项目. 扫描步骤: a. 打开CMD,切换到指定的项目根目录,和.sln同级目录即可(此处 ...
- [转]Oracle dblink调用函数报ORA-00904 标识符无效
新建oracle的database link时,提示错误“ORA-12169: TNS: 指定为连接标识符的 Net 服务名太长”, 网上查了下,是因为目标oracle是集群,连接字符串过长,超过25 ...
- ASP.NET 5 Beta6发布了(翻译)
感觉就好像我们刚刚发布了一个版本,现在我们又要发布一个新的版本.开发团队通过努力工作在Visual Studio2015的正式版上提交使用ASP.NET 5开发工具的上的更新以及库的更新.新的版本为b ...
- axure 6.5 汉化正式版软件及注册码
Axure公司发布了Axure RP 6.5 正式版. 官方主页: http://www.axure.com/news 官方下载: http://www.axure.com/download 视频介绍 ...
- 会话追踪(session tracking)
HTTP是一种无连接的协议,如果一个客户端只是单纯地请求一个文件(HTML或GIF),服务器端可以响应给客户端,并不需要知道一连串的请求是否来自于相同的客户端,而且也不需要担心客户端是否处在连接状态. ...
- Heap Spray原理
Heap Spray定义基本描述 Heap Spray并没有一个官方的正式定义,毕竟这是漏洞攻击技术的一部分.但是我们可以根据它的特点自己来简单总结一下.Heap Spray是在shellcode的前 ...
- [React] Use the useReducer Hook and Dispatch Actions to Update State (useReducer, useMemo, useEffect)
As an alternate to useState, you could also use the useReducer hook that provides state and a dispat ...
- Oracle Spatial 创建空间表、添加空间原表信息、添加删除空间索引
一.创建空间表 创建一个空间表tbsvrc_buffer_t ,SQL如下: create table tbsvrc_buffer_t( ID VARCHAR2(50) not null, ...
- css换行缩进
1.换行缩进 <div id="alertiframe"> <span id="closeiframe">×</span> ...