简体   繁体   English

在 MobileFirst Foundation 中使用底层 Java EE 资源

[英]Using underlying Java EE Resources in MobileFirst Foundation

Looking at the Java Adapter documentation and samples , I don't see any examples of delegating like DataSource configuration to the underlying Java EE server.查看Java Adapter 文档示例,我没有看到任何将 DataSource 配置委托给底层 Java EE 服务器的示例。 Instead things like Driver and authentication are in Adapter properties.相反,诸如驱动程序和身份验证之类的东西位于适配器属性中。 Is using Java EE Resources a supported pattern?使用 Java EE 资源是受支持的模式吗?

It definitely seems non-ideal and tedious to have to manage resource details within each adapter, especially if multiple adapters might use the same resources.必须在每个适配器内管理资源详细信息显然是不理想且乏味的,尤其是在多个适配器可能使用相同资源的情况下。 Not to mention potentially having sensitive properties in adapter configuration files.更不用说在适配器配置文件中可能具有敏感属性。

Or is the idea that the people managing these things will know nothing about the Java EE server, and instead only know how to use the MFP console?或者管理这些东西的人对 Java EE 服务器一无所知,而只知道如何使用 MFP 控制台?

It definitely seems non-ideal and tedious to have to manage resource details within each adapter, especially if multiple adapters might use the same resources.必须在每个适配器内管理资源详细信息显然是不理想且乏味的,尤其是在多个适配器可能使用相同资源的情况下。

In MobileFirst Foundation 8.0 there are ways to manage such configurations using either Maven commands or CLI commands to pull and push configurations to adapters across different environments, and as you say, there is a web UI to handle it, too.在 MobileFirst Foundation 8.0 中,有一些方法可以使用 Maven 命令或 CLI 命令来管理此类配置,以跨不同环境将配置拉取和推送到适配器,而且正如您所说,还有一个 Web UI 来处理它。

Read more here: https://mobilefirstplatform.ibmcloud.com/blog/2017/01/03/tools-for-devops-flows-with-mobilefirst-foundation/在此处阅读更多信息: https ://mobilefirstplatform.ibmcloud.com/blog/2017/01/03/tools-for-devops-flows-with-mobilefirst-foundation/

Or is the idea that the people managing these things will know nothing about the Java EE server, and instead only know how to use the MFP console?或者管理这些东西的人对 Java EE 服务器一无所知,而只知道如何使用 MFP 控制台?

As with the previous paragraph, there are tools to handle it.与上一段一样,有一些工具可以处理它。

That said, it is true that nothing is written about it at this time.也就是说,目前确实没有任何关于它的文章。
Please feel free to contact your IBM representative to see if something can be done about it.请随时联系您的 IBM 代表,看看是否可以对此做些什么。

I have been able to do this in my Java EE server (WebSphere Liberty).我已经能够在我的 Java EE 服务器 (WebSphere Liberty) 中执行此操作。 Described in a blog post , recreated here.博客文章中描述,在此处重新创建。

Define the JNDI DataSource in your Java EE server.在 Java EE 服务器中定义 JNDI 数据源。 (eg Configuring relational database connectivity in Liberty ) (例如在 Liberty 中配置关系数据库连接

Put the JNDI name itself in Adapter configuration parameters:将 JNDI 名称本身放入适配器配置参数中:

<property name="dataSource.jndiName" 
          displayName="DataSource JNDI Name" defaultValue="jdbc/myDataSource"/>

In your adapter Java code, use the following simple code to obtain that DataSource:在您的适配器 Java 代码中,使用以下简单代码来获取该数据源:

    try {
        javax.naming.InitialContext ctx = new javax.naming.InitialContext();
        this.dataSource = (javax.sql.DataSource) ctx.lookup(dataSourceJndiName);
    }
    catch (javax.naming.NamingException e) {
        throw new RuntimeException(
            "Unable to locate specified DataSource: " + dataSourceJndiName);
    }

Where dataSourceJndiName is obtained from the MobileFirst ConfigurationAPI :其中 dataSourceJndiName 是从MobileFirst ConfigurationAPI获得的:

configApi.getPropertyValue("dataSource.jndiName");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM