简体   繁体   English

Websphere Web应用程序的可选JNDI绑定

[英]Optional JNDI Binding For Websphere Web Application

I would like to have optionally supplied information available to my webapp when deployed to Websphere (we are using 8.5) via the application's JNDI context. 通过应用程序的JNDI上下文部署到Websphere(我们正在使用8.5)时,我希望有选择地提供信息给我的webapp。

I know that I can put a resource-ref or resource-env-ref in my web.xml but when I do that WAS will require me to supply a binding for it and deployment time. 我知道我可以在我的web.xml中放置一个resource-refresource-env-ref ,但是当我这样做时,WAS将要求我为其提供绑定和部署时间。

My application will look in JNDI for certain values and adjust its behavior if found, but will function fine with default behaviour if it does not find values in JNDI. 我的应用程序将在JNDI中查找某些值并调整其行为(如果找到),但如果在JNDI中找不到值,则可以使用默认行为正常运行。 How, in WAS, do I supply a binding (just for a string or a URL) for my webapp without declaring a dependency on it in a resource-ref or resource-env-ref in my web.xml. 在WAS中,如何在不为web.xml的resource-refresource-env-ref中声明对它的依赖关系的情况下,为我的webapp提供绑定(仅针对字符串或URL)。

I know how to do this in Tomcat, I just put a Environment entry in the context.xml, like this: 我知道如何在Tomcat中执行此操作,我只是将一个Environment条目放在context.xml中,如下所示:

<Environment 
    name="com.myorg.config" 
    value="http://localhost:8081/suff"
    type="java.lang.String"/>

You can use an @Resource String lookupName; 您可以使用@Resource String lookupName; to accomplish the same in a portable manner. 以可移植的方式完成相同的任务。 You will be prompted for a value at deployment time, but you can specify nothing, which will cause no value to be injected. 在部署时将提示您输入值,但是您可以不指定任何值,这将导致不注入任何值。

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

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