cancel
Showing results for 
Search instead for 
Did you mean: 

Singleton in a Custom Adaptor Module

Former Member
0 Kudos

Hi,

I've written a custom adaptor module to manipulate some data on an incoming FTP communication channel (Content Conversion).

The adaptor module creates a sequence number for the incoming data, and checks to see whether an ID on the data has been processed before.

As each file is processed the ID is written out to a file. I've implemented this as a Singleton so the IDs are maintened in a map and the file only needs to be read when the Singleton is first created.

Unfortunately the Singleton is created each time the Adaptor Module is used, which leads me to believe that a new Java instance is created any time a call is made to an Adaptor Module.

Could anyone possibly confirm this?

Is it possible to use a Singleton Pattern in a custom adaptor module?

Kind regards,

John

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

did u try using GlobalContainer to achieve the singleton?.

Former Member
0 Kudos

"GlobalContainer enables you to cache the values that you want to read again when you next call any user-defined function in the same message mapping."

GlobalContainer would appear to used for in any classes written for MessageMapping rather than in an Adaptor Module.

It would appear to be persistent only for the life of the Message Mapping.

- "A message mapping has exactly one global container during the execution."

I wrote the classic implementation of a Singleton (for the sake of argument called IDCheckSingleton) using a static instance of the IDCheckSingleton within the IDCheckSingleton and a getInstance method.

John

bhavesh_kantilal
Active Contributor
0 Kudos

As far as I know the singleton implementation is not possible.

I have seen a similar discussion on SDN on the same topic but on Java Mappings and a reason for this was provided, will try to look up that thread as well.

Regards

Bhavesh