if (longGenMgr == null) {
//if not already registered, create it
try {
longGenMgr = (LongGenMgr) Class.forName(getLongGenMgrName()).newInstance();
} catch (Exception e) {
throw new PException(e, "Cannot create LongGenMgr (probably a ClassLoader problem): " + getLongGenMgrName());
}
((LongGenMgr) longGenMgr).init(mapper, PClassMapping.CREATE_STRUCTURE_IF_NEEDED);
// and register it
LongGenMgrRegistry.registerLonGenMgr((LongGenMgr)longGenMgr);
}
}
}
//create the long gen and associate it to the sequence
s.setLongGen(((LongGenMgr) longGenMgr).getLongGen(s.getName()));
} else {
//else, use rdb_sequence_long_gen
if (mapperRdb != null) {
if (s.getLongGen() == null) {
RdbSequenceLongGen rdbLongGen = new RdbSequenceLongGen(mapperRdb, s.datastoreName, false);
if(s.start != null) {
rdbLongGen.setSequenceStart(s.start);
}
if(s.increment != null) {
rdbLongGen.setSequenceIncrement(s.increment);
}
if(s.cache != null) {
rdbLongGen.setSequenceStart(s.cache);
}
//create it
Object conn = mapperRdb.getConnection();
rdbLongGen.createSequence(conn);
//and associate it to the sequence
s.setLongGen(rdbLongGen);
//close the connection
mapperRdb.closeConnection(conn);
}
} else {
throw new PException("Problem while init the sequence "
+ ((SpeedoSequence)sequence).getName() + ": "
+ "a rdb sequence has been defined in a jdo file and no rdb is linked to the application.");
}
}
} catch (Exception e) {
throw new PException(e, "Problem while init the sequence " + ((SpeedoSequence)sequence).getName());
}
}
}