import org.apache.isis.core.runtime.system.context.IsisContext;
public class PojoRecreatorDefault implements PojoRecreator {
public Object recreatePojo(final TypedOid oid) {
final ObjectSpecification spec = getSpecificationLoader().lookupBySpecId(oid.getObjectSpecId());
final Object pojo = spec.createObject();
if(oid.isViewModel()) {
// initialize the view model pojo from the oid's identifier
final ViewModelFacet facet = spec.getFacet(ViewModelFacet.class);
if(facet == null) {
throw new IllegalArgumentException("spec does not have ViewModelFacet; " + oid.toString() + "; spec is " + spec.getFullIdentifier());
}
// a slight compromise? close enough.
if(!(oid instanceof RootOid)) {
throw new IllegalArgumentException("oid is view model but not a RootOid; " + oid.toString());