Skip to Content
avatar image
Former Member

Singleton in a Custom Adaptor Module

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 29, 2008 at 10:31 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 29, 2008 at 01:59 PM

    did u try using GlobalContainer to achieve the singleton?.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      "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