getTransactionManager().startTransaction();
for (final Object service : servicesInjector.getRegisteredServices()) {
final ObjectSpecification serviceNoSpec = specificationLoader.loadSpecification(service.getClass());
serviceNoSpec.markAsService();
final String serviceId = ServiceUtil.id(service);
final Oid existingOid = getOidForService(serviceId);
ObjectAdapter adapter;
if (existingOid == null) {
adapter = getAdapterManager().adapterFor(service);
} else {
adapter = getAdapterManager().recreateRootAdapter(existingOid, service);
}
if (adapter.getOid().isTransient()) {
adapterManager.remapAsPersistent(adapter);
}
if (adapter.getResolveState().canChangeTo(ResolveState.RESOLVING)) {
adapter.changeState(ResolveState.RESOLVING);
adapter.changeState(ResolveState.RESOLVED);
}
if (existingOid == null) {
final Oid persistentOid = adapter.getOid();
registerService(serviceId, persistentOid);
}
}
getTransactionManager().endTransaction();