Oracle EBS R12 整合ADF

本文详细介绍了如何将ADF (Application Development Framework) 与Oracle EBS (Enterprise Business Suite) R12.2.3版本进行整合。通过创建Java类和过滤器,实现获取EBS登录用户信息的功能。步骤包括:创建ConnectionProvider、EBizUtil、EBSWrapperFilter和UserInfo类,配置adfc-config.xml和web.xml,以及在Oracle EBS端设置Function、Menu和Responsibility。整合过程中涉及ADF、Java Servlet和EBSDataSource的JNDI配置。
摘要由CSDN通过智能技术生成

环境
ADF version: 11.1.1.6.0
Oracle EBS version: R12.2.3

程序的目的在于取得 EBS 登入时的用户相关信息。整个程序架构如下图:

ADF 的程序面:
Step 01: 在 ViewController 依序建立 Java Class:ConnectionProvider、EBizUtil、EBSWrapperFilter、以及存取用户信息的 Java Bean: UserInfo资料的 ConnectionProvider.java代码:

package com.oracle.view;

import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class ConnectionProvider {
    private static DataSource ebsDS = null;
    static{
        try {
            Context ctx = new InitialContext();
            ebsDS = (DataSource) ctx.lookup("jdbc/TEST32");
            
            // your datasource jndi name as defined during configuration
            if (ctx != null)
                ctx.close();
            
        } catch (Exception e) {
            // TODO: Add catch code
            //ne.printStackTrace(); //ideally you should log it
            throw new RuntimeException(e);
            // means jndi setup is not correct or doesn't exist
        }
    }
    
    private ConnectionProvider() {
        super();
    }
    

   public static Connection getConnection() throws SQLException{
        if (ebsDS == null)
            throw new IllegalStateException("AppsDatasource is not properly initialized or available");
        return ebsDS.getConnection();
    }
 
}

PS: 在 EBS 环境中是以 jdbc 的模式取得数据库联机,可以进入 weblogic 的 Services-> Data Sources 查看,如:EBSDataSource 的 JNDI: jdbc/TEST32 ,并可以得知要布署到那一个主机上:oacore_cluster1

EBizUtil.java 代码:

package com.oracle.view;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.apps.fnd.ext.common.EBiz;


public class EBizUtil {
    public EBizUtil() {
        super();
    }
    private static final Logger logger = Logger.getLogger(EBizUtil.class.getName());
    private static EBiz INSTANCE = null;
    static {
        Connection connection = null;
        try {
            connection = ConnectionProvider.getConnection();
            // DO NOT hard code applServerID for a real application
            // Get applServerID as CONTEXT-PARAM from web.xml or elsewhere
            INSTANCE = new EBiz(connection, "F1CB87199593E5F4E0431F030A0AD0AB31310251131793525291714692481335");
        } catch (SQLException e) {
            logger.log(Level.SEVERE, "SQLException while creating EBiz instance -->", e);
            throw new RuntimeException(e);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Exception while creating EBiz instance -->", e);
            throw new RuntimeException(e);
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }

    public static EBiz getEBizInstance() {
        return INSTANCE;
    }    
    
}

PS: APPL_SERVER_ID 可以到 EBS APP Server 路径下的 $INST_TOP/appl/fnd/12.0.0/secure/TEST32.dbc 取得Server ID :
APPL_SERVER_ID=F1CB87199593E5F4E0431F030A0AD0AB31310251131793525291714692481335
EBSWrapperFilter.java代码:

package com.oracle.view;

import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oracle.apps.fnd.ext.common.AppsRequestWrapper;
import oracle.apps.fnd.ext.common.AppsRequestWrapper.WrapperException;

public class EBSWrapperFilter implements Filter {
    public EBSWrapperFilter() {
        super();
    }


    private static final Logger logger = Logger.getLogger(EBSWrapperFilter.class.getName());
    
    public void init(FilterConfig filterConfig) {
        logger.info("Filter initialized ");
    }

    public void doFilter(ServletRequest request, ServletResponse response,  FilterChain chain) throws IOException,ServletException {
        AppsRequestWrapper wrapper = null;
        logger.info("-current URI =" + ((HttpServletRequest)request).getRequestURI());

        try {
            
            wrapper = new AppsRequestWrapper((HttpServletRequest)request, (HttpServletResponse)response, ConnectionProvider.getConnection(), EBizUtil.getEBizInstance());
            
        } catch (WrapperException e2) {
            logger.log(Level.SEVERE, "WrapperException error encountered ", e2);
            throw new ServletException(e2);
        } catch (SQLException e2) {
            logger.log(Level.SEVERE, "SQLException error encountered ", e2);
            throw new ServletException(e2);
        }
        try {
            logger.info("Created AppsRequestWrapper object." + " Continuing the filter chain.");
            chain.doFilter(wrapper, response);
            logger.info("- the filter chain ends");
        } finally {
            //AppsRequestWrapper caches a connection internally.
            //AppsRequestWrapper.getConnection()--returns this connection this connection can be used in doGet()/doPost() service layer
            //whenever our application requires a connection in order to service the current request.
            //When AppsRequestWrapper instance is in use, this connection should not be closed by other code.
            //At this point, we are done using AppsRequestWrapper instance so, as good practice, we are going to close (release) this connection now.
            if (wrapper != null) {
                try {
                    logger.info("- releasing the connection attached to the" + " current AppsRequestWrapper instance ");
                    wrapper.getConnection().close();
                } catch (SQLException e3) {
                    logger.log(Level.WARNING, "SQLException error while closing connection--", e3);
                    throw new ServletException(e3);
                }
            }
            wrapper = null;
        }
    }

    public void destroy() {
        logger.info("Filter destroyed ");
    }
}

UserInfo.java 代码:

package com.oracle.bean;

import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import oracle.apps.fnd.ext.common.AppsRequestWrapper;
import oracle.apps.fnd.ext.common.Session;

public class UserInfo {
    private String user;
    private String userInfo;

    public UserInfo() {
        super();
    }


    public void setUser(String user) {
        this.user = user;
    }

    public String getUser() {
        return user;
    }


    public void beforePhase(PhaseEvent phaseEvent) {
        // Add event code here...
        AppsRequestWrapper wrappedRequest =
            (AppsRequestWrapper)FacesContext.getCurrentInstance().getExternalContext().getRequest();

        Session session = wrappedRequest.getAppsSession();

        setUser(session.getUserName());

        Map columns = session.getInfo();
        StringBuffer temp = new StringBuffer();
        temp.append("<table>");
        for (Object key : columns.keySet()) {
            temp.append("<tr>");
            temp.append("<td>");
            temp.append(key);
            temp.append("</td>");
            temp.append("<td>");
            temp.append(columns.get(key));
            temp.append("</td>");
            temp.append("</tr>");
        }
        temp.append("</table>");

        setUserInfo(temp.toString());

    }

    public void setUserInfo(String userInfo) {
        this.userInfo = userInfo;
    }

    public String getUserInfo() {
        return userInfo;
    }
}

Step 02:在 adfc-config.xml 建立 view: userInfo.jspx 及 设定 Managed Beans
userInfo.jspx 

版面:PageGroupLayout :layout = vertical
      OutPutText:value="Hello #{pageFlowScope.userInfoBean.user}!!"
          inlineStyle="font-size:medium; color:Red;" 
      Separator
       OutPutText:value="#User Info:<br>#{pageFlowScope.userInfoBean.userInfo}" 
           escape="false"
                  inlineStyle="font-size:medium;"

Managed Beans:userInfoBean :

Step 03: 设定 userInfo.jspx 的 beforePhase

这是在 UserInfo.java 的一段程序

public void beforePhase(PhaseEvent phaseEvent) {
        // Add event code here...
        AppsRequestWrapper wrappedRequest =
            (AppsRequestWrapper)FacesContext.getCurrentInstance().getExternalContext().getRequest();

        Session session = wrappedRequest.getAppsSession();

        setUser(session.getUserName());

        Map columns = session.getInfo();
        StringBuffer temp = new StringBuffer();
        temp.append("<table>");
        for (Object key : columns.keySet()) {
            temp.append("<tr>");
            temp.append("<td>");
            temp.append(key);
            temp.append("</td>");
            temp.append("<td>");
            temp.append(columns.get(key));
            temp.append("</td>");
            temp.append("</tr>");
        }
        temp.append("</table>");

        setUserInfo(temp.toString());

    }

Step 04 : web.xml 中设定 Filters

Oracle EBS 上的设定 :
Step 01: 设定 Function : Menu: Responsibiliey:
Function: WEI_ADFLAB_USERINFO 

Function

WEI_ADFLAB_USERINFO

Properties-Type

External ADF Application

WebHTML-HTML Call

GWY.jsp?targetPage=faces/userInfo


Menu:WEI_LAB_MENU 

Responsibility: WEI Labs 

Step 02: Responsibility: Functional Administrator 上的设定
a.Core Services → Profiles → Code: FND_EXTERNAL_ADF_URL → Go
b.然后点选External ADF Application URL 后按 Define Profile Values

a. 点选Define Profile Values → Responsibility
b. 选择 Responsibility & Value
c. Value:  客制程式在 weblogic 的路径,如: http://lnxap104:7214/LAB_EBS-ViewController-context-root/ ,最后要加 /
d. 按 Update

一个Responsibility只能绑定一个程序的root,所以如果有多个功能,可能要放在同一包应用程序里面。也有其它使用者在问此问题,但现在并没有进一步的解法。例如: Oracle论坛,其他使用者提问的 >> 问题
Step 03: 清除 Caching Framework & Testing

本文章转载:ADF 整合於 ( Integrate ) Oracle EBS R12 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值