generatorNameKeyInManager = cmd.getFullClassName();
}
}
// Try to find the generator from the PoidManager if we already have it managed
PoidGenerator generator = poidManager.getPoidGenerator(generatorNameKeyInManager);
if (generator == null)
{
if (poidGeneratorName == null)
{
// No available value-generator for the specified strategy for this datastore
throw new JPOXUserException(LOCALISER.msg("038004", strategy));
}
// Set up the default properties available for all value generators
Properties props = getPropertiesForGenerator(cmd, absoluteFieldNumber, om, sequenceMetaData,
tableGeneratorMetaData);
Class cls = null;
if (elem != null)
{
cls = omfContext.getPluginManager().loadClass(elem.getExtension().getPlugin().getSymbolicName(),
elem.getAttribute("class-name"));
}
if (cls == null)
{
throw new JPOXException("Cannot create Poid Generator for strategy " + poidGeneratorName);
}
// Create the new PoidGenerator since the first time required (registers it with the PoidManager too)
generator = poidManager.createPoidGenerator(generatorNameKeyInManager, cls, props, this, null);
}
// Get the next value from the generator
Object oid = getStrategyValueForGenerator(generator, om);
if (mmd != null)
{
// replace the value of the id, but before convert the value to the field type if needed
Object convertedValue = TypeConversionHelper.convertTo(oid, mmd.getType());
if (convertedValue == null)
{
throw new JPOXException(LOCALISER.msg("038003", mmd.getFullFieldName(), oid)).setFatal();
}
oid = convertedValue;
}
if (JPOXLogger.POID.isDebugEnabled())
{
JPOXLogger.POID.debug(LOCALISER.msg("038002", fieldName, strategy, generator.getClass().getName(), oid));
}
return oid;
}