// Use the provided name as the table name (what if it is null ?)
props.put("sequence-name", seqMetaData.getDatastoreSequence());
}
// Get a PoidManager to create the generator
PoidManager mgr = storeMgr.getPoidManager();
PoidConnectionProvider connProvider = new PoidConnectionProvider()
{
ManagedConnection mconn;
public ManagedConnection retrieveConnection()
{
try
{
// Obtain a new connection
// Note : it may be worthwhile to use the PM's connection here however where a Sequence doesnt yet
// exist the connection would then be effectively dead until the end of the tx
// The way around this would be to find a way of checking for existence of the sequence
PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration();
int isolationLevel = TransactionUtils.getTransactionIsolationLevelForName(conf.getStringProperty("org.jpox.poid.transactionIsolation"));
this.mconn = ((RDBMSManager)storeManager).getConnection(isolationLevel);
}
catch (SQLException e)
{
String msg = LOCALISER.msg("017006", e);
JPOXLogger.JDO.error(msg);
throw new JDODataStoreException(msg,e);
}
return mconn;
}
public void releaseConnection()
{
try
{
// Release the connection
mconn.close();
}
catch (JPOXException e)
{
String msg = LOCALISER.msg("017007", e);
JPOXLogger.JDO.error(msg);
throw new JDODataStoreException(msg, e);
}
}
};
Class cls = null;
ConfigurationElement elem =
objectMgr.getOMFContext().getPluginManager().getConfigurationElementForExtension("org.jpox.store_valuegenerator",
new String[]{"name", "datastore"}, new String[] {poidGeneratorName, storeManager.getStoreManagerKey()});
if (elem != null)
{
cls = objectMgr.getOMFContext().getPluginManager().loadClass(elem.getExtension().getPlugin().getSymbolicName(), elem.getAttribute("class-name"));
}
if( cls == null )
{
throw new JPOXException("Cannot create Poid Generator for strategy "+poidGeneratorName);
}
generator = mgr.createPoidGenerator(seqMetaData.getName(), cls, props, storeManager, connProvider);
if (JPOXLogger.JDO.isDebugEnabled())
{
JPOXLogger.JDO.debug(LOCALISER.msg("017003", seqMetaData.getName(), poidGeneratorName));
}