return new RdbSequencePName(this, en);
}
}
//Binder role
PBindingCtrl pb = (PBindingCtrl) en;
byte nextstate = PStateGraph.nextStatePBinding(pb.getStatus(),
PBinding.ACTION_EXPORT);
if (nextstate == PBinding.LIFECYCLE_ERROR)
throw new PExceptionProtocol("Unauthorized operation");
PName pn = null;
boolean connectionAllocatedLocaly = false;
try {
if (c == null) {
c = getBinderClassMapping().getPMapper().getConnection();
connectionAllocatedLocaly = true;
}
initSequenceHelper();
long lid = ((Long) sequence.next()).longValue();
//TODO : if factory, lid = factory.next
pn = new RdbSequencePName(this, new Long(lid));
} finally {
if (connectionAllocatedLocaly) {
getBinderClassMapping().getPMapper().closeConnection(c);
} else if (c instanceof ConnectionHolder) {
try {
((ConnectionHolder) c).releaseCHConnection();
} catch (PersistenceException e) {
throw new PException(e, "Problem with Perseus connection releasing.");
}
}
}
if (cache != null) {
synchronized (cache) {
if (cache.lookup(pn) != null) {
throw new PExceptionExistingName("[" + getClassName()
+ "]: an object has been already export with the same identifier");
}
try {
cache.fix(cache.bind(pn, pb));
} catch (CacheException e) {
throw new PException(e, "[" + getClassName()
+ "]: problem with cache management");
}
}
}
pb.setPName(pn);
pb.setStatus(nextstate);
return pn;
}