com.sap.aii.af.service.idmap

Class MessageIDMapper

java.lang.Object
  extended by com.sap.aii.af.service.idmap.MessageIDMapper

public class MessageIDMapper
extends Object

MessageIDMapper is a singleton that allows applications to create id mappings in a transactional manner. MessageIDMapper mapper = MessageIDMapper.getInstance(); mapper.createIDMap(mid1, mid2);

Version:
$Id: //tc/xpi.af/710_SP_REL/src/_af_service/psrv/api/com/sap/aii/af/service/idmap/MessageIDMapper.java#3 $

Method Summary
 void createIDMap(MessageKey mkey1, MessageKey mkey2, long archiveAfter, boolean callPMIAgent, boolean transactional)
          Creates a map between two message keys.
 void createIDMap(String mid1, String mid2, long archiveAfter)
           
 void createIDMap(String mid1, String mid2, long archiveAfter, boolean transactional)
          Creates a map between two message ids.
static MessageIDMapper getInstance()
          Gets the singleton MessageIDMapper
 String getMappedId(String mid)
          Retrieves a message id from the mapped message ids.
 MessageKey getMappedKey(MessageKey mkey)
          Retrieves a message key from the mapped message keys.
 LinkedList<String[]> readIDMapEntries()
          Reads all IDMap entries available in the DB and returnes them as a LinkedList of IDMap objects.
 String remove(String mid)
           
 String remove(String mid, boolean transactional)
          Removes the message id map entry for this id.
 void removeExpiredIDMaps()
           
 void removeExpiredIDMaps(Timestamp timeStamp)
          Deletes all IDMapper entries, where the persist duration has already expired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MessageIDMapper getInstance()
Gets the singleton MessageIDMapper

Returns:
the MessageIDMapper singleton.

getMappedId

public String getMappedId(String mid)
Retrieves a message id from the mapped message ids.

Parameters:
mid - the message id.
Returns:
the mapped id for the given input, null if no id exists.

getMappedKey

public MessageKey getMappedKey(MessageKey mkey)
Retrieves a message key from the mapped message keys. When using this method, the entry needs to be written with the createIDMap method with the message key parameters.

Parameters:
mid - the message key.
Returns:
the mapped key for the given input, null if no key exists.

remove

public String remove(String mid,
                     boolean transactional)
Removes the message id map entry for this id.

Parameters:
mid - the messasge id for which to remove the map.
Returns:
Always returns null.

remove

public String remove(String mid)

createIDMap

public void createIDMap(String mid1,
                        String mid2,
                        long archiveAfter)
                 throws UtilException
Throws:
UtilException

createIDMap

public void createIDMap(String mid1,
                        String mid2,
                        long archiveAfter,
                        boolean transactional)
                 throws UtilException
Creates a map between two message ids. Both ids should be GUIDs so that it should be possible to retrieve ids in both directions based on either id without collisions.

Parameters:
mid1 - the first message id.
mid2 - the second message id.
archiveAfter - a point in time represented in milliseconds as per the java standard after which this message id mapping will no longer be required and can be archived.
transactional - specifies if the IDMap entry should be written in an existing transactional context
Throws:
MessagingException - if one of the ids already exists in the database.
UtilException

createIDMap

public void createIDMap(MessageKey mkey1,
                        MessageKey mkey2,
                        long archiveAfter,
                        boolean callPMIAgent,
                        boolean transactional)
                 throws UtilException
Creates a map between two message keys. Both ids should be GUIDs so that it should be possible to retrieve ids in both directions based on either id without collisions. IDMap entries created with this method have to be checked using the getMappedKey method.

Parameters:
mkey1 - the first message key.
mkey2 - the second message key.
archiveAfter - a point in time represented in milliseconds as per the java standard after which this message id mapping will no longer be required and can be archived.
transactional - specifies if the IDMap entry should be created as part or a transactional context
callPMIAgent - specifies if the IDMapping PMI agent should be called
Throws:
MessagingException - if one of the ids already exists in the database.
UtilException

removeExpiredIDMaps

public void removeExpiredIDMaps(Timestamp timeStamp)
Deletes all IDMapper entries, where the persist duration has already expired.


removeExpiredIDMaps

public void removeExpiredIDMaps()

readIDMapEntries

public LinkedList<String[]> readIDMapEntries()
Reads all IDMap entries available in the DB and returnes them as a LinkedList of IDMap objects. This method is for testing only!.



Copyright 2007 SAP AG Complete Copyright Notice