String factoryName = entityCommand.getAttribute("key-generator-factory");
if (factoryName == null) {
throw new RuntimeException("key-generator-factory attribute must be set for entity " + entity.getEntityName());
}
try {
KeyGeneratorFactory keyGeneratorFactory = entity.getManager().getKeyGeneratorFactory(factoryName);
if(keyGeneratorFactory == null) {
throw new IllegalArgumentException("Invalid key generator name; not found: " + factoryName);
}
keyGenerator = keyGeneratorFactory.getKeyGenerator();
} catch (Exception e) {
throw new RuntimeException("Error: can't create key generator instance; key generator factory: " + factoryName, e);
}
}