public void setCacheInstances(final String[] names) { for (int i = 0; i < names.length; i++) { NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(names[i]); cache.put(spec, Boolean.TRUE); } }
public NakedObjectSpecification getSpecification() { return NakedObjectsContext.getReflector().loadSpecification(cls); }
public NakedObjectSpecification[] getParameterSpecifications() { final NakedObjectSpecification[] specifications = new NakedObjectSpecification[parameters.length]; for (int i = 0; i < parameters.length; i++) { specifications[i] = NakedObjectsContext.getReflector().loadSpecification(parameters[i]); } return specifications; }
public NakedObjectSpecification getElementType() { return NakedObjectsContext.getReflector().loadSpecification(elementClass); }
private NakedObjectSpecification getSpecification(final String fullName) { return NakedObjectsContext.getReflector().loadSpecification(fullName); }
private NakedObjectSpecification specFor(final Data data) { return NakedObjectsContext.getReflector().loadSpecification(data.getClassName()); }
public NakedObjectSpecification getSpecification() { return NakedObjectsContext.getReflector().loadSpecification(Person.class); }
public void execute(final Workspace workspace, final View view, final Location at) { NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(Perspective.class); NakedCollection collection = NakedObjectsContext.getObjectPersistor() .findInstances(new AllInstances(spec, false)); addOpenViewFor(collection, at); } });
public void execute(final Workspace workspace, final View view, final Location at) { Object services[] = NakedObjectsContext.getObjectLoader().getServices(); NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(Object.class); NakedCollection collection = NakedObjectsContext.getObjectLoader().createAdapterForCollection(services, spec); addOpenViewFor(collection, at); } });
public void testFindInstancesButNoneFound() throws Exception { system.setObjectPersistor(proxy); //system.addSpecificationToLoader(new MovieSpecification()); CriteriaData c = new TestCriteria(); remoteInterface.findInstances(session, c); expectLastCall().andReturn(new ObjectData[0]); AllInstances criteria = new AllInstances(NakedObjectsContext.getReflector().loadSpecification(Movie.class), false); expect(encoder.createCriteriaData(criteria)).andReturn(c); EasyMock.replay(remoteInterface); EasyMock.replay(encoder); proxy.findInstances(criteria); EasyMock.verify(remoteInterface); EasyMock.verify(encoder); }
public void introspect(ReflectionPeerBuilder builder) { className = Perspective.class.getName(); fields = new NakedObjectField[] { builder.createField(new NamePeer()), builder.createField(new ServicesPeer()), builder.createField(new ObjectsPeer()), builder.createField(new UserNamePeer()), }; superClassSpecification = NakedObjectsContext.getReflector().loadSpecification(Object.class); superClassSpecification.addSubclass(this); }
public void testHasInstances() throws Exception { system.setObjectPersistor(proxy); remoteInterface.hasInstances(session, Movie.class.getName()); expectLastCall().andReturn(true); expectLastCall().andReturn(false); EasyMock.replay(remoteInterface); NakedObjectSpecification type = NakedObjectsContext.getReflector().loadSpecification(Movie.class); assertTrue(proxy.hasInstances(type, false)); assertFalse(proxy.hasInstances(type, false)); EasyMock.verify(remoteInterface); }
public NakedObject recreateObject() { if (state == null) { return null; } else { NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(state.className); NakedObjectLoader objectLoader = NakedObjectsContext.getObjectLoader(); NakedObject object; ResolveState targetState; if (getOid().isTransient()) { object = objectLoader.recreateTransientInstance(getOid(), spec); targetState = ResolveState.SERIALIZING_TRANSIENT; } else { object = objectLoader.recreateAdapterForPersistent(getOid(), spec); targetState = ResolveState.UPDATING; } updateObject(object, state, targetState); LOG.debug("recreated object " + object.getOid()); return object; } }
private NakedObject recreateReference(final Data data) { NakedObjectLoader objectLoader = NakedObjectsContext.getObjectLoader(); synchronized (objectLoader) { Oid oid = data.oid; NakedObject ref; if (oid == null) { ref = null; } else { NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(data.className); ResolveState resolveState; if (oid.isTransient()) { ref = objectLoader.recreateTransientInstance(oid, spec); resolveState = ResolveState.getResolveState(data.resolveState); } else { ref = objectLoader.recreateAdapterForPersistent(oid, spec); resolveState = ResolveState.GHOST; } if (data instanceof ObjectData) { updateObject(ref, data, resolveState); } } return ref; } }
public NakedObject recreateAdapter(final Oid oid, final Object pojo) { DummyNakedObject adapter = new DummyNakedObject(oid, ResolveState.GHOST); // Object pojo = ((TestSpecification) spec).newInstance(); adapter.setupObject(pojo); NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(pojo.getClass()); adapter.setupSpecification(spec); /* * * DummyNakedObject adapter = (DummyNakedObject) recreatedPersistent.get(oid); if (adapter == null) { * throw new DummyException("No adapter for " + oid); } adapter.setupOid(oid); */ addAdapter(pojo, adapter); addIdentity(oid, adapter); return adapter; }
private NakedObjectMember getMember(final String memberName) { final MemberIdentifier id = MemberIdentifierImpl.fromIdentityString(memberName); final NakedObjectSpecification specification = NakedObjectsContext.getReflector().loadSpecification(id.getClassName()); NakedObjectMember member; if (id.isField()) { member = (NakedObjectMember) specification.getField(id.getName()); if (member == null) { throw new IllegalRequestException("No field found for id " + id); } } else { member = (NakedObjectMember) specification.getObjectAction(NakedObjectAction.USER, id.getName(), id .getParameterSpecifications()); if (member == null) { throw new IllegalRequestException("No user action found for id " + id); } } return member; }
/** * NB: this test version doesn't (seem to) support defaulting properties, even if requested. */ public NakedObject createAdapterForTransient(final Object object, boolean defaultProperties) { DummyNakedObject adapter = new DummyNakedObject(); adapter.setupObject(object); adapter.setupResolveState(ResolveState.TRANSIENT); DummyOid oid = new DummyOid(oidSerialNumber--); adapter.setupOid(oid); NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(object.getClass()); adapter.setupSpecification(spec); addAdapter(object, adapter); addIdentity(oid, adapter); return adapter; }
/** * NB: this test version doesn't (seem to) support defaulting properties, even if requested. */ public NakedObject createAdapterForTransient(final Object object, boolean defaultProperties) { Assert.assertNotNull("pojo must be specified", object); TestProxyNakedObject adapter = new TestProxyNakedObject(); adapter.setupObject(object); adapter.setupResolveState(ResolveState.TRANSIENT); TestProxyOid oid = new TestProxyOid(oidSerialNumber--); adapter.setupOid(oid); NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(object.getClass()); adapter.setupSpecification(spec); addAdapter(object, adapter); addIdentity(oid, adapter); return adapter; }
private Object loadUnresolvedObject( final LoadEvent event, final EntityPersister persister, final EntityKey keyToLoad, final LoadEventListener.LoadType options, final PersistenceContext persistenceContext) { final HibernateOid oid = new HibernateOid(event.getEntityClassName(), event.getEntityId()); final NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(event.getEntityClassName()); final NakedObjectLoader loader = NakedObjectsContext.getObjectLoader(); NakedObject nakedObject = loader.getAdapterFor(oid); if (nakedObject == null) { nakedObject = loader.recreateAdapterForPersistent(oid, spec); Assert.assertFalse(persistenceContext.isEntryFor(nakedObject.getObject())); return nakedObject.getObject(); } else { return load(event, persister, keyToLoad, options); } } }
public NakedObject recreateAdapter(final Oid oid, final Object pojo) { if (isIdentityKnown(oid)) { return getAdapterFor(oid); } TestProxyNakedObject adapter = new TestProxyNakedObject(); adapter.setupOid(oid); adapter.setupResolveState(oid.isTransient() ? ResolveState.TRANSIENT : ResolveState.GHOST); adapter.setupObject(pojo); NakedObjectSpecification spec = NakedObjectsContext.getReflector().loadSpecification(pojo.getClass()); adapter.setupSpecification(spec); addAdapter(pojo, adapter); addIdentity(oid, adapter); return adapter; }