Package com.sun.ejb.base.sfsb.util
Class SimpleKeyGenerator
- java.lang.Object
-
- com.sun.ejb.base.sfsb.util.SimpleKeyGenerator
-
- All Implemented Interfaces:
SFSBUUIDUtil<SimpleKeyGenerator.SimpleSessionKey>
,org.glassfish.ha.store.util.KeyTransformer<SimpleKeyGenerator.SimpleSessionKey>
- Direct Known Subclasses:
ScrambledKeyGenerator
public class SimpleKeyGenerator extends Object implements SFSBUUIDUtil<SimpleKeyGenerator.SimpleSessionKey>, org.glassfish.ha.store.util.KeyTransformer<SimpleKeyGenerator.SimpleSessionKey>
A utility class that generates stateful session keys using two longs The session id generated by this class is guarenteed to be unique as long as the system clock is never reset to a previous value The hashCode of the SessionKey generated by SimpleKeyGenerator also allows uniform distribution of keys when hashed in a HashMap- Author:
- Mahesh Kannan
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
SimpleKeyGenerator.SimpleSessionKey
-
Constructor Summary
Constructors Constructor Description SimpleKeyGenerator()
SimpleKeyGenerator(byte[] ipAddress, int port)
SimpleKeyGenerator(long uniquePrefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleKeyGenerator.SimpleSessionKey
byteArrayToKey(byte[] array, int startIndex, int len)
Return the sessionKey that represents the sessionKey.SimpleKeyGenerator.SimpleSessionKey
createSessionKey()
Create and return the sessionKey.byte[]
keyToByteArray(SimpleKeyGenerator.SimpleSessionKey key)
Called from the Container before publishing an IOR.
-
-
-
Method Detail
-
createSessionKey
public SimpleKeyGenerator.SimpleSessionKey createSessionKey()
Create and return the sessionKey.- Specified by:
createSessionKey
in interfaceSFSBUUIDUtil<SimpleKeyGenerator.SimpleSessionKey>
- Returns:
- the sessionKey object
-
keyToByteArray
public byte[] keyToByteArray(SimpleKeyGenerator.SimpleSessionKey key)
Called from the Container before publishing an IOR. The method must convert the sessionKey into a byte[]- Specified by:
keyToByteArray
in interfaceorg.glassfish.ha.store.util.KeyTransformer<SimpleKeyGenerator.SimpleSessionKey>
- Specified by:
keyToByteArray
in interfaceSFSBUUIDUtil<SimpleKeyGenerator.SimpleSessionKey>
- Returns:
- A byte[] representation of the key. The byte[] could be created using serialization.
-
byteArrayToKey
public SimpleKeyGenerator.SimpleSessionKey byteArrayToKey(byte[] array, int startIndex, int len)
Return the sessionKey that represents the sessionKey. This has to be super efficient as the container calls this method on every invocation. Two objects obtained from identical byte[] must satisfy both o1.equals(o2) and o1.hashCode() == o2.hashCode()- Specified by:
byteArrayToKey
in interfaceorg.glassfish.ha.store.util.KeyTransformer<SimpleKeyGenerator.SimpleSessionKey>
- Specified by:
byteArrayToKey
in interfaceSFSBUUIDUtil<SimpleKeyGenerator.SimpleSessionKey>
- Returns:
- the sessionKey object
-
-