use of org.eclipse.persistence.internal.sessions.factories.model.sequencing.TableSequenceConfig in project eclipselink by eclipse-ee4j.
the class SessionsFactory method buildSequence.
/**
* INTERNAL:
* Builds a Sequence from the given SequenceConfig.
*/
protected Sequence buildSequence(SequenceConfig sequenceConfig) {
if (sequenceConfig == null) {
return null;
}
String name = sequenceConfig.getName();
int size = sequenceConfig.getPreallocationSize();
if (sequenceConfig instanceof DefaultSequenceConfig) {
return new DefaultSequence(name, size);
} else if (sequenceConfig instanceof NativeSequenceConfig) {
return new NativeSequence(name, size);
} else if (sequenceConfig instanceof TableSequenceConfig) {
TableSequenceConfig tsc = (TableSequenceConfig) sequenceConfig;
return new TableSequence(name, size, tsc.getTable(), tsc.getNameField(), tsc.getCounterField());
} else if (sequenceConfig instanceof UnaryTableSequenceConfig) {
UnaryTableSequenceConfig utsc = (UnaryTableSequenceConfig) sequenceConfig;
return new UnaryTableSequence(name, size, utsc.getCounterField());
} else if (sequenceConfig instanceof XMLFileSequenceConfig) {
try {
// Can no longer reference class directly as in a different project.
@SuppressWarnings({ "unchecked" }) Class<Sequence> xmlClass = (Class<Sequence>) Class.forName("org.eclipse.persistence.eis.adapters.xmlfile.XMLFileSequence");
Sequence sequence = xmlClass.getConstructor().newInstance();
sequence.setName(name);
sequence.setInitialValue(size);
return sequence;
} catch (Exception missing) {
return null;
}
} else {
// Unknown SequenceConfig subclass - should never happen
return null;
}
}
Aggregations