Defining custom properties in Application panel - how to get the value in the code?

你离开我真会死。 提交于 2019-12-21 09:35:16

问题


In IBM WebSphere web admin console one can go to Applications -> WebSphere enterprise applications, pick an application and click on "Custom Properties" link. There will be a page to add key-value pairs. How would you access those values from the code? The properties don't seem to end up in System properties nor in ServletContext..


回答1:


I've never seen it used during my 7-year career with IBM WebSphere Application Server. I think that if it's ever used it's so rarely that I'd call the feature a left-over from the past version of IBM WebSphere that supported it.

For application-specific configuration settings I'd strongly recommend web.xml for web applications or @Resource annotation for web applications and the other application types.




回答2:


This answer will be not exactly on the topic, but it can resolve the issue to define and set configuration properties for Web Applications managed by WebSphere.

The easiest way to define configuration settings for a Web Application under WebSphere is below:

  1. Define a Web Application settings using the servlet initialization parameters:

web.xml

<servlet>
  <servlet-name>my-servlet</servlet-name>
  <servlet-class>
    my.servlet.ClassName
  </servlet-class>
  <init-param>
    <param-name>someConfigurationPropertyName</param-name>
    <param-value>This Value Can Be Set</param-value>
  </init-param>
</servlet>
  1. The value of these servlet parameters can be changed using Web Administration Console, you will find and can change them in Enterprise Applications > your-web-application-name > Initialize parameters for servlets



回答3:


I tested this on WAS ND 8.5. Adding a custom property to the application adds it to the deployment.xml.

I updated \DefaultApplication.ear with the property name="testprop" value="true". It gets updated here:

C:\WASNEW85\WebSphere\AppServer\profiles\Dmgr01\config\cells\cell01\applications\DefaultApplication.ear.ear\deployments\DefaultApplication.ear

The value shows:

<properties xmi:id="Property_1424805152486" name="testprop" value="true" description="test-forum" required="false"/>

I hope this helps.




回答4:


To set a webcontainer custom property on IBM WebSphere Application Server Version 7 or Version 8

  1. In the administrative console, click "Servers" and under Servers click "Server Types" and under Server Types click "WebSphere Application Servers"
  2. Click on the server to which the custom property is to be applied
  3. Under "Configuration" and "Container settings" click "Web Container Settings" and under Web Container Settings click "Web container"
  4. Under "Configuration" and "Additional Properties" click "Custom Properties"
  5. In the Custom Properties page, click "New"
  6. In the settings page, enter the name of the custom property to be added in the "Name" field and the value to be set for the custom property in the "Value" field. Note that some properties are case sensitive.
  7. Click "Apply" or "OK"
  8. Click "Save" in the "Messages" box that appears
  9. Restart the server for the custom property to take effect

To set a webcontainer custom property on IBM WebSphere Application Server Version 6:

  1. In the administrative console, click "Servers" and under Servers click "Application Servers"
  2. Click on the server to which the custom property is to be applied
  3. Under "Configuration" and "Container settings" click "Web Container Settings" and under Web Container Settings click "Web Container"
  4. Under "Configuration" and "Additional Properties" click "Custom Properties"
  5. In the Custom Properties page, click "New"
  6. In the settings page, enter the name of the custom property to be added in the "Name" field and the value to be set for the custom property in the "Value" field. Note that some properties are case sensitive.
  7. Click "Apply" or "OK"
  8. Click "Save" in the "Messages" box that appears
  9. Restart the server for the custom property to take effect

To set a webcontainer custom property on WebSphere Application Server Version 6 using wsadmin:

  1. Create a jacl script to add/update the custom property.
  2. Ensure that the server is running.
  3. Run the jacl script in wsadmin using "wsadmin -f .jacl
  4. Restart the server for the custom property to take effect.


来源:https://stackoverflow.com/questions/14229079/defining-custom-properties-in-application-panel-how-to-get-the-value-in-the-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!