Пример #1
0
  public Object loadPojo(final TypedOid oid) {

    // REVIEW: does it make sense to get these directly?  not sure, so for now have decided to fail
    // fast.
    if (oid instanceof AggregatedOid) {
      throw new UnsupportedOperationException(
          "Cannot retrieve aggregated objects directly, oid: " + oid.enString(getOidMarshaller()));
    }

    final RootOid rootOid = (RootOid) oid;

    Object result = null;
    try {
      final Class<?> cls = clsOf(rootOid);
      final Object jdoObjectId = JdoObjectIdSerializer.toJdoObjectId(rootOid);
      final PersistenceManager pm = getPersistenceManager();
      FetchPlan fetchPlan = pm.getFetchPlan();
      fetchPlan.addGroup(FetchGroup.DEFAULT);
      result = pm.getObjectById(cls, jdoObjectId);
    } catch (final RuntimeException e) {
      throw e;
    }

    if (result == null) {
      throw new ObjectNotFoundException(oid);
    }
    return result;
  }
Пример #2
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;
 }
Пример #3
0
 private Class<?> clsOf(final TypedOid oid) {
   final ObjectSpecification objectSpec =
       getSpecificationLoader().lookupBySpecId(oid.getObjectSpecId());
   return objectSpec.getCorrespondingClass();
 }