WebSphere:EJB 初始上下文 +聚类查找
我想知道以下简单代码是否有效,因为我有:
WebSphere ND。
两个应用程序服务器充当 Web 服务器。
作为应用程序服务器的两个应用程序服务器(作为集群 X)
我可以使用以下代码访问部署在 X 集群上的 EJB: InitialContext 初始上下文 = new InitialContext(); MyBeanHome = initialContext.lookup("/cells/clusters/X/MyBeanHome");
或者: 初始上下文是否需要实际指定从中下载路由表的服务器?也就是说,为initialContext 等定义属性。
我问这个问题的原因是因为我想知道WebSphere 是否以某种方式使得可以利用单元概念并允许以某种方式进行jndiLookup 而无需指定我们使用jndi 的服务器。
I was wondering whether the following simple code will work, given that I have:
WebSphere ND.
two application servers acting as web-servers.
two application servers acting as application-servers (as cluster X)
Can I access an EJB deployed on the X cluster, using the following code:
InitialContext initialContext = new InitialContext();
MyBeanHome = initialContext.lookup("/cells/clusters/X/MyBeanHome");
or:
Will the initialContext demand actually specifing servers from which to download the routing table? That is, define properties for the initialContext etc.
The reason I am asking is because I was wondering if WebSphere somehow made it possible to take use of the cell concept and to allow to jndiLookup somehow without specifying the servers on which we use jndi.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从服务器内创建一个 InitialContext 将针对您正在运行的服务器进行引导,并且它将了解其单元拓扑,因此您不需要使用 corbaloc 等指定属性。
(我相信语法是查找(“cell/clusters/X/MyBeanHome”)没有前导“/”,尽管我可能会弄错,并且命名可能允许两者。)
Creating an InitialContext from within a server will bootstrap against the server in which you're running, and it will be aware of its cell topology, so you don't need to specify properties with corbaloc, etc.
(I believe the syntax is lookup("cell/clusters/X/MyBeanHome") without the leading "/", though I might be mistaken, and naming might allow both.)
名称空间都是相互关联的。一旦你掌握了命名服务器(这就是你在获取初始上下文时所做的事情),只要你使用复合名称,你就可以遍历整个树。该复合名称具有完整的拓扑,允许命名服务器导航联合名称空间以找到正确的资源。
一般来说,不要在应用程序中对拓扑进行硬编码。使用本地名称空间 (java:comp/env)。作为应用程序部署的一部分,将这些本地名称空间映射到复合名称。如果拓扑发生变化,则无需更改代码。您可以更改绑定并准备好使用更改。
查看这些链接以更好地理解
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rnam_names.html < /一>
<一href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/cnam_name_space_partitions.html" rel="nofollow">http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/cnam_name_space_partitions.html
HTH
曼格鲁
The names spaces are all interconnected. Once you get hold of a Naming Server (which is what you do when you get the Intial Context) you can traverse the entire tree as long as you use the Compound name. This compound name has the entire topology which allows the naming server to navigate the federated name space to locate the right resources.
In general, do not hardcode the topology in your application. Work with local names space (java:comp/env). Map these local name spaces to the compound names as part of your application deployment. If the topology changes then you don't need to change your code. You can change the bindings and have the changes ready to be used.
Have a look at these links to get a better understanding
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rnam_names.html
http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/cnam_name_space_partitions.html
HTH
Manglu