property files in memory

What is the best way to load a property file into memory so that it is available to all packages across the IS? I have tried a few different ways with no success.

  1. Used psUtilities/hashtable, don’t like the way that works… could be simpler IMHO
  2. Used psUtilities/memory, get exceptions with this one; suspect that there is a problem with class casting;
  3. Could use system properties, but that is not preferred and a last resort.

Consider usage such as log4j, would like behavior like that.

Fairly new to webMethods, any hints, suggestions, or examples would be appreciated.

Thanks in advance.

I allways work with a config file in a local directory and pick up it only when I need it.

Here’s another approach.

Define a get Java service to retrieve a specific property.

On the Shared tab, declare and define a static Properties object. Use a static initializer to load a file into that object.

In the get service, retrieve the value of the property from the Properties object. Any service from any thread can call this service.

If you need to refresh the object, do not assign null to the Properties object and create a new one. Instead, call clear and then reload. That will be thread safe.

I haven’t try but if you point your browser to extended settings, and click on Edit, you should be able to type:

my.prop.name=1000
my.prop.name2=abc

Save and restart IS, then in your code do a:

Config.getProperty(null, “my.prop.name”)

You need to import wm.something.Config (Can’t remember full path)

Thats “should” work. give it a try :smiley:

If you put custom items in the Extended settings, it needs to be prefixed by watt. or it will not be loaded. (Or has that changed?)

This technique is good for just a few properties. As the number increases, and the groupings of properties is needed, then this becomes unmanageable.

To me, using custom items in extended settings is like using system properties and not preferred.

I do have something useful cooked - after much discussion with teammates regarding using hash and IData objects I decided on the simpler approach using properties. Willing to share, it is appropriate to post code? (still new! :slight_smile: