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
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
prefix
protected long prefix
suffix
protected long suffix
idCounter
protected int idCounter
SimpleKeyGenerator
public SimpleKeyGenerator()
SimpleKeyGenerator
public SimpleKeyGenerator(byte[] ipAddress,
int port)
SimpleKeyGenerator
public SimpleKeyGenerator(long uniquePrefix)
createSessionKey
public SimpleKeyGenerator.SimpleSessionKey createSessionKey()
- Create and return the sessionKey.
- Specified by:
createSessionKey in interface SFSBUUIDUtil<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 interface SFSBUUIDUtil<SimpleKeyGenerator.SimpleSessionKey>- Specified by:
keyToByteArray in interface org.glassfish.ha.store.util.KeyTransformer<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 interface SFSBUUIDUtil<SimpleKeyGenerator.SimpleSessionKey>- Specified by:
byteArrayToKey in interface org.glassfish.ha.store.util.KeyTransformer<SimpleKeyGenerator.SimpleSessionKey>
- Returns:
- the sessionKey object
Copyright © 2012 GlassFish Community. All Rights Reserved.