OSB 自定义XPath Function

来源:互联网 发布:c语言教程电子书 编辑:程序博客网 时间:2024/05/21 18:47
此文翻译、整理出自<OSB Cookbook>自定义XPath函数章

1 编写你自己要实现的java类,将其打包成jar.
package osbcookbook.util.checksum;

import java.util.zip.CRC32;
import java.util.zip.Checksum;

public class ChecksunUtil {
       
        public static long calculateChecksum (String data) {
              Checksum checksum = new CRC32();
              checksum.update(data.getBytes(), 0, data.getBytes(). length);
               return checksum.getValue();
       }
}

2 复制%Middleware_HOME%\Oracle_OSB1\config\xpath-functions下的osb-build-in.xml,修改<xpf:function/>元素,定义我们自己的xpath函数,更改文件名.保存
<?xml version="1.0" encoding="UTF-8"?>
<xpf:xpathFunctions xmlns:xpf="http://www.bea.com/wli/sb/xpath/config">
    <xpf:category id="%OSB_FUNCTIONS%">
        <xpf:function>
             <xpf:function>
            <xpf:name>calculateChecksum</xpf:name>
            <xpf:comment>Return the checksum of the given string passed as parameter</xpf:comment>
            <xpf:namespaceURI>http://osbcookbook.org/xquery/xquery-functions</xpf:namespaceURI>
            <xpf:className>osbcookbook.util.checksum.</xpf:className>
            <xpf:method>long calculateChecksum(java.lang.String)</xpf:method>
            <xpf:isDeterministic>true</xpf:isDeterministic>
            <xpf:scope>Pipeline</xpf:scope>
            <xpf:scope>SplitJoin</xpf:scope>
        </xpf:function>
        </xpf:function>
    </xpf:category>
</xpf:xpathFunctions>

4 将我们编写的jar包放在%Middleware_HOME%\Oracle_OSB1\config\xpath-functions文件夹下


5 重启OSB项目在所domain的Weblogic server,重启OEPE.

0 0