Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.util.jdbc
Class IDGeneratorFactory

java.lang.Object
  extended by org.hyperic.util.jdbc.IDGeneratorFactory

public class IDGeneratorFactory
extends java.lang.Object

This factory is meant to be the central point of access for IDGenerator objects used by an application. It will hold the single IDGenerator in a private map and reuse it across repeated invocations of getNextId(). It is particularly useful for Entity bean scenarios, where multiple instances of an IDGenerator result in database row contention and SQL timeouts if more than one thread attempts to get a new id from the sequence at the same time.


Constructor Summary
IDGeneratorFactory()
           
 
Method Summary
static long getNextId(java.lang.String ctx, java.lang.String sequenceName, java.lang.String dsName)
          Get a new ID from the named sequence, accessible through the named datasource string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IDGeneratorFactory

public IDGeneratorFactory()
Method Detail

getNextId

public static long getNextId(java.lang.String ctx,
                             java.lang.String sequenceName,
                             java.lang.String dsName)
                      throws ConfigPropertyException,
                             javax.naming.NamingException,
                             SequenceRetrievalException,
                             java.sql.SQLException
Get a new ID from the named sequence, accessible through the named datasource string.

Parameters:
ctx - - the logging context. Typically the name of the calling class
sequenceName - - the name of the sequence to retrieve the new id from
dsName - - the JNDI name of the datasource
Throws:
ConfigPropertyException
javax.naming.NamingException
SequenceRetrievalException
java.sql.SQLException

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.