29.01.2013 Views

WebSphere Application Server V7.0: Concepts ... - IBM Redbooks

WebSphere Application Server V7.0: Concepts ... - IBM Redbooks

WebSphere Application Server V7.0: Concepts ... - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A lesser known, but better, approach to access property files is to use URL<br />

resources. We do not go into the details of exactly how to do that here, but the<br />

following steps describe the approach:<br />

1. Create a folder on your system that holds the property file.<br />

2. Use the Integrated Solutions Console and create a URL resource that points<br />

to the property file and assign it a JNDI name.<br />

3. In the application, create a URL resource reference binding pointing to the<br />

JNDI name chosen.<br />

4. In Java, use JNDI to look up the URL resource reference. Create an<br />

InputStream from the URL, and use that InputStream as input to the<br />

java.util.Properties class to load the property files.<br />

This approach to access property files is also more Java EE compliant because it<br />

does not rely on the java.io package for file access, which is prohibited according<br />

to the Java EE specification.<br />

The method also gives you the opportunity to load the property files using HTTP<br />

and FTP. This allows you to set up an HTTP server serving properties files from a<br />

central location.<br />

Unless you are using the previous technique with the HTTP or FTP protocol, it is<br />

convenient to manage all property files in a central location, on the deployment<br />

manager. However, property files stored in folders outside the EAR files are not<br />

propagated to the <strong>WebSphere</strong> nodes unless the folders are created under the<br />

deployment manager cell configuration folder, which is<br />

\config\cells\.<br />

By creating a folder, such as appconfig, under this folder, you can take advantage<br />

of the <strong>WebSphere</strong> file transfer service to propagate your files to the nodes.<br />

Because this folder is not known to the <strong>WebSphere</strong> <strong>Application</strong> <strong>Server</strong><br />

infrastructure, it will not happen automatically when the contents are changed.<br />

You need to force a synchronization with the nodes. This propagates the property<br />

files to the \config\cells\\appconfig directory on each<br />

node. You can include that folder on the class path using a shared library or point<br />

your URL resources to it.<br />

Tip: When deciding on names for settings in property files, it is a good idea to<br />

include the unit of the setting referred to in the name. Therefore, instead of<br />

using MaxMemory or Timeout, it is better to use MaxMemoryMB and<br />

TimeoutMS to indicate that the max memory should be given as megabytes<br />

and the timeout as milliseconds. This can help reduce confusion for the<br />

system administrator who does not know the internals of the application.<br />

304 <strong>WebSphere</strong> <strong>Application</strong> <strong>Server</strong> <strong>V7.0</strong>: <strong>Concepts</strong>, Planning, and Design

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!