String name = attrs.getValue("name");
Log log = getLog();
if (log.isTraceEnabled())
log.trace(_loc.get("parse-sequence", name));
SequenceMetaData meta = getRepository().getCachedSequenceMetaData(name);
if (meta != null && log.isWarnEnabled())
log.warn(_loc.get("override-sequence", name));
meta = getRepository().addSequenceMetaData(name);
String seq = attrs.getValue("sequence-name");
// Do not normalize the sequence name if it appears to be a plugin
if (seq.indexOf('(') == -1){
seq = normalizeSequenceName(seq);
}
String val = attrs.getValue("initial-value");
int initial = val == null ? 1 : Integer.parseInt(val);
val = attrs.getValue("allocation-size");
int allocate = val == null ? 50 : Integer.parseInt(val);
String schema = normalizeSchemaName(attrs.getValue("schema"));
String catalog = normalizeCatalogName(attrs.getValue("catalog"));
String clsName, props;
if (seq == null || seq.indexOf('(') == -1) {
clsName = SequenceMetaData.IMPL_NATIVE;
props = null;
} else { // plugin
clsName = Configurations.getClassName(seq);
props = Configurations.getProperties(seq);
seq = null;
}
meta.setSequencePlugin(Configurations.getPlugin(clsName, props));
meta.setSequence(seq);
meta.setInitialValue(initial);
meta.setAllocate(allocate);
meta.setSchema(schema);
meta.setCatalog(catalog);
Object cur = currentElement();
Object scope = (cur instanceof ClassMetaData)
? ((ClassMetaData) cur).getDescribedType() : null;
meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML);
Locator locator = getLocation().getLocator();
if (locator != null) {
meta.setLineNumber(locator.getLineNumber());
meta.setColNumber(locator.getColumnNumber());
}
return true;
}