是否有任何简单的 JNDI 上下文实现,这意味着它们可以启动/停止等而不会泄漏
我不是 JNDI 的特别粉丝——我认为当人们出于多种原因想要使用 OSGI 时,它是一种糟糕的技术。
- JNDI 不是独立的。
- jndi 中很容易泄漏和留下东西。
- 因为它是基于字符串的,所以很容易发生冲突。
- JNDI 通常是一个没有范围的全局事物 - 任何人都可以在绑定时不存在命名冲突的情况下添加内容。
- 它应该是无套接字的 - 仅从 Map 获取对象。
我想控制 jndi 上下文的范围。我需要它来使用 Hornet JMS 层,不幸的是,该层使用 JNDI 来注册队列、主题等。我不想提供自己编码的 jndi 上下文,而是尝试重用另一个提供其作用域而不是全局的上下文。
有人有解决这个问题的解决方案/建议吗?
I am not a particular fan of JNDI - i think its a bad technology when one wants to use OSGI for a number of reasons.
- JNDI is not self contained.
- Its too easy to leak and leave stuff in jndi.
- Its too easy to get conflicts because it is string based.
- JNDI is often a global thing with no scope - any one is putting stuff in providing there are no naming conflicts when binding.
- It should be socket less - sourcing objects from only a Map.
I would like to control the scope of a jndi context. I need it to use the Hornet JMS layer which unfortunately uses JNDI to register queues, topics etc. Rather than supply my own coded jndi context i would like to try and reuse another providing its scoped and not global.
Does anyone have any solutions/suggestions to solving this problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SimpleJNDI 是 JNDI 的开源实现,它支持内存中上下文,并且可以从文件夹树(子上下文)和属性/XML 文件(对象)进行填充。
更多信息请参见官方网站:http://code.google.com/p/osjava/ wiki/SimpleJNDI(文档位于可下载存档内)。
(PS:这不是一个活跃的项目 - 最新版本是 2010 年 - 但无论如何它可以提供帮助......)
SimpleJNDI is an open-source implementation of JNDI which supports in-memory contexts, and can be populated from a tree of folders (sub-contexts) and properties/XML files (objects).
More info on the official website : http://code.google.com/p/osjava/wiki/SimpleJNDI (the documentation is inside the downloadable archive).
(P.S.: this is not an active project - the latest release being from 2010 - but it can help anyway...)
我认为 Simple-JNDI 可以满足您的要求“提供其范围而不是全局”。您可以将其配置为生成共享或非共享上下文。在非共享模式下,每次调用时,
您都会获得上下文定义的唯一内存中副本,只有调用代码可以查看和修改。
要获取有关它的更多信息,请访问 https://github.com/h-thurow/Simple- JNDI。它是一个基于旧 osjava Simple-JNDI 的活跃项目。
I think Simple-JNDI could meet your requirement "providing its scoped and not global." You can configure it to produce shared or unshared contexts. In unshared mode every time you call
you get a unique in-memory copy of your context definition that only the calling code can see and modify.
To get more information about it go to https://github.com/h-thurow/Simple-JNDI . It is an active project that is based on old osjava Simple-JNDI.
您不需要 JNDI 上下文实现来解决此问题。您只需像在 Java 的其余部分中一样正确编码资源获取和释放:基本上,通过
finally{}
块中的Context.close()
进行。另请确保关闭您可能拥有的所有NamingEnumerations
。You don't need a JNDI context implementation to solve this problem. You just need to code your resource acquisition and release correctly as in the rest of Java: basically, via
Context.close()
infinally{}
blocks. Also make sure to close anyNamingEnumerations
you may have.