是否有JNDI命名空间约定? [英] Are there JNDI namespace conventions?

查看:188
本文介绍了是否有JNDI命名空间约定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了JBoss EAP 6.1,我将添加一个新的数据源。我必须将数据源绑定到JNDI名称。通过读取示例数据源的JNDI名称:

I have downloaded JBoss EAP 6.1 and I am going to add a new data source. I must bind the data source to a JNDI name. By reading the JNDI name of the sample data source which is:

java:jboss/datasources/ExampleDS

我看到他们在之后使用了 datasources 的java:JBoss的。这只是一个命名约定 - 我无法在任何地方找到 - 或者使用 java:jboss / bananaboat / MyDS 吗?

I see that they have used datasources after java:jboss. Is this just a naming convention - that I am not able to find anywhere - or would it be fine using java:jboss/bananaboat/MyDS?`

下面列出的第一部分是否正确 - 例如 java:comp 是范围,其余部分只是正常的层次结构组织?

Is it correct that the first part that is listed below - such as java:comp is the scope and the rest is just normal hierarchy organization?

java:comp/ - The namespace is scoped to the current component (i.e. EJB) 
java:module/ - Scoped to the current module 
java:app/ - Scoped to the current application      
java:global/ - Scoped to the application server

https:// docs。 jboss.org/author/display/AS71/JNDI+Reference

推荐答案

我不得不回答同样的问题我把这些链接拉到一起。

I had to answer the same question to myself and pulled these links together.

简而言之, JNDI命名策略 可以是任何,但JEE定义自己的:

In short, JNDI Naming Policies can be any but JEE defines its own:


JNDI是独立定义的任何特定命名和
目录服务实现。

JNDI is defined independent of any specific naming and directory service implementation.

但是,一个重要的平台确定了一组有限的
命名策略以使用JNDI是... JEE

However, one important platform that does define a limited set of naming policies for using the JNDI is ... JEE.

这将是数据源最常规的名称:

This would be the most conventional name for the datasource:


企业名称空间植根于 java URL方案的URL上下文。

The enterprise namespace is rooted in a URL context for the java URL scheme.

例如,JDBC Salary 数据库的名称可能为 java:comp / env / jdbc /薪水

For example, a JDBC Salary database might have the name "java:comp/env/jdbc/Salary".


  • ... comp 绑定到为与组件相关的绑定保留的子树。

  • ... env 绑定到为其保留的子树组件的环境相关绑定,如define d通过其部署描述符。

  • 资源工厂引用放在由资源管理器类型区分的子树中。


    • ... jdbc 用于JDBC DataSource引用。

    • ... comp is bound to a subtree reserved for component-related bindings.
    • ... env is bound to a subtree that is reserved for the component's environment-related bindings, as defined by its deployment descriptor.
    • Resource factory references are placed in subtrees differentiated by their resource manager type.
      • ...jdbc for JDBC DataSource references.

      JEE 7教程还详细说明了在 32.4.1.1便携式JNDI语法

      JEE 7 Tutorial also details naming policies to reference EJBs in 32.4.1.1 Portable JNDI Syntax.

      注意 @Resource 注入注释 DataSource 通常指定JNDI名称相对于 java:comp / env - 请参阅 此答案 此答案 ,适用于便携式和可部署的解决方案。

      Note that @Resource annotation to inject DataSource often specifies JNDI name relative to java:comp/env - see this answer or this answer for portable and deployable solutions.

      您的更新链接 java:jboss 命名空间是自定义扩展n仅由WildFly / JBoss提供。

      As mentioned in your updated link, java:jboss namespace is a custom extension provided by WildFly/JBoss only.

      要回答这个问题,标准名称空间下的子树只是正常层次。显然,只有应用服务器,文档,进程等(广泛地)识别这些子树才有意义。否则,我猜几乎是平键值或随机 bananaboat / MyDS 很好但仍然必须在支持的命名空间下挂载,如 java:jboss

      To answer the question, the sub-trees under standard namespaces are just normal hierarchy. Obviously, it only makes sense if these sub-trees are (widely) recognized by application server, documentation, processes, etc. Otherwise, I guess nearly flat key-value or random bananaboat/MyDS is fine but still has to be "mounted" under supported namespace like java:jboss.

      这篇关于是否有JNDI命名空间约定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆