Singleton Pattern in IS 4.6 - is it possible?!


I would like to implement the following functionality - not sure how to do it in IS 4.6 - need advice.

I want to create a Java FlowService which will run once - (i.e. everytime the server starts or everytime the folder gets loaded). This JavaService will read a file which contains ErrorCodes and ErrorMessages. This service will then build a data structure (need help here with a data type… maybe a Record List), which will contain all ErrorCode/ErrorMessage combinations.

Here is the most important thing: I want this Java Service to build this data structure only once and then publish it into the Pipeline for all other Flow Services to use at anytime.

I want this data structure to ‘live’ in the Pipeline indefinitely (until the server is re-started) - so that all other Flow Services can contintue to use this Data Structure without re-loading it from file everytime… essentially a Singleton Pattern, but not sure how to implement it in IS 4.6 - Please help!



You can almost have exactly what you want.

Write a Java flow service that loads your file into Java objects at startup (or the first time it’s called). The state should be saved in Java class variables (i.e. statics).

The flows services that need these constants can either call an associated Java flow service to get them, or they can call a service to populate the pipeline.

I think a service that provides the data via an interface would be preferable to loading the pipeline with lots of data that may or may not be needed by a particular service.


A package startup service can be used to initialize the Java static data structure declared in the Shared Code portion of the service.

Possibly a Java Hashtable that is keyed using the ErrorCode and the value is the ErrorMessage? This depends on how you are going to access the data. See WmPublic pub.string:lookupDictionary and pub.string:lookupTable for possible accessor services.

You can’t automagically insert something into the pipeline for all services unless you write a ContentHandler (there is an example of this in WmSamples).

But you can create an “init” service that is called by your process’ “entry point services” that does interesting things like prime the pipeline with such a data structure, log the input pipeline or restore a logged pipeline for debugging purposes, put a process start timer into the pipeline for tuning purposes, etc.

try services in the which permits to have a global variable.