Ejemplo n.º 1
0
  private void recreateAdapters(final ObjectStoreInstances objectStoreInstances) {
    for (final Oid oid : objectStoreInstances.getOids()) {

      // it's important not to "touch" the pojo, not even in log messages.
      // That's because
      // the toString() will cause bytecode enhancement to try to resolve
      // references.

      if (LOG.isDebugEnabled()) {
        LOG.debug("recreating adapter: oid=" + oid);
      }
      final Object pojo = objectStoreInstances.getPojo(oid);

      final ObjectAdapter existingAdapterLookedUpByPojo = getAdapterManager().getAdapterFor(pojo);
      if (existingAdapterLookedUpByPojo != null) {
        // this could happen if we rehydrate a persisted object that
        // depends on another persisted object
        // not yet rehydrated.
        getPersistenceSession().removeAdapter(existingAdapterLookedUpByPojo);
      }

      final ObjectAdapter existingAdapterLookedUpByOid = getAdapterManager().getAdapterFor(oid);
      if (existingAdapterLookedUpByOid != null) {
        throw new IsisException(
            "A mapping already exists for " + oid + ": " + existingAdapterLookedUpByOid);
      }

      final ObjectAdapter recreatedAdapter = getPersistenceSession().mapRecreatedPojo(oid, pojo);

      final Version version = objectStoreInstances.getVersion(oid);
      recreatedAdapter.setVersion(version);
    }
  }
Ejemplo n.º 2
0
 @Override
 public void debugData(final DebugBuilder debug) {
   debug.appendTitle("Domain Objects");
   for (final ObjectSpecId specId : persistedObjects.specifications()) {
     debug.appendln(specId.asString());
     final ObjectStoreInstances instances = instancesFor(specId);
     instances.debugData(debug);
   }
   debug.unindent();
   debug.appendln();
 }
Ejemplo n.º 3
0
 @Override
 public ObjectAdapter loadInstanceAndAdapt(final TypedOid oid)
     throws ObjectNotFoundException, ObjectPersistenceException {
   if (LOG.isDebugEnabled()) {
     LOG.debug("getObject " + oid);
   }
   final ObjectSpecification objectSpec =
       getSpecificationLookup().lookupBySpecId(oid.getObjectSpecId());
   final ObjectStoreInstances ins = instancesFor(objectSpec.getSpecId());
   final ObjectAdapter adapter = ins.getObjectAndMapIfRequired(oid);
   if (adapter == null) {
     throw new ObjectNotFoundException(oid);
   }
   return adapter;
 }