JNDI解决了ApplicationContext在Spring中无法解决的哪个问题? [英] Which issue does JNDI solve that ApplicationContext does not solve in Spring?

查看:141
本文介绍了JNDI解决了ApplicationContext在Spring中无法解决的哪个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JNDI是从字符串名称检索/存储数据或对象的一种手段.该功能由运行应用程序的容器提供.

JNDI is a mean to retrieve/store data or objects from string names. This feature is provided by the container running the application.

ApplicationContext允许从其字符串名称创建和检索bean.

ApplicationContext allows the creation and retrieval of beans from their string name.

两者都满足类似的需求.但是,Spring提供了从JNDI检索对象的方法.也可以通过JndiTemplate访问JNDI.

Both serve similar needs. Yet, Spring offers means to retrieve objects from JNDI. One can also access JNDI via the JndiTemplate.

真的需要在Spring中使用JNDI吗?它解决了ApplicationContext不能解决的哪个问题?

Is there a real need to use JNDI in Spring? Which problem does it solve that ApplicationContext does not?

推荐答案

应用上下文不会帮助您查找REMOTE对象.它将仅在当前应用程序中查找不是远程的对象.

The Application Context would not help you in looking up a REMOTE object. It will only look for objects in the current application, which are not remote.

请参阅以下"Context.PROVIDER_URL".您可以访问EJB,RMI或JMS等REMOTE对象.此外,您还可以访问由Java EE容器管理的任何资源,例如数据源.

See the following "Context.PROVIDER_URL". You can get access to REMOTE objects like EJBs or RMI or JMS, etc. Also, you could access any resource managed by the Java EE Container such as a DataSource.

ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://HOSTNAME:PORT");

这篇关于JNDI解决了ApplicationContext在Spring中无法解决的哪个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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