/** * An analog to EntityProxy for domain types that do not have an identity * concept. */ @ProxyFor(Object.class) public interface ValueProxy extends BaseProxy { }
private boolean hasProxyLocator(TypeElement x, State state) { ProxyFor proxyFor = x.getAnnotation(ProxyFor.class); if (proxyFor != null) { // See javadoc on getAnnotation try { proxyFor.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.locatorType.asElement()); } } ProxyForName proxyForName = x.getAnnotation(ProxyForName.class); return proxyForName != null && !proxyForName.locator().isEmpty(); }
@Override public Class<?> resolveDomainClass(Class<?> clazz) { if (List.class.equals(clazz)) { return List.class; } else if (Set.class.equals(clazz)) { return Set.class; } else if (Map.class.equals(clazz)) { return Map.class; } else if (BaseProxy.class.isAssignableFrom(clazz)) { ProxyFor pf = clazz.getAnnotation(ProxyFor.class); if (pf != null) { return pf.value(); } ProxyForName pfn = clazz.getAnnotation(ProxyForName.class); if (pfn != null) { Class<?> toReturn = forName(pfn.value()); return toReturn; } } return die(null, "Could not resolve a domain type for client type %s", clazz.getCanonicalName()); }
/** * A stable, opaque id of an {@link EntityProxy} that remains stable across * updates, creates, deletes on the client. * <p> * In particular, an {@link EntityProxy} foo that is yet to be persisted and a * copy of foo after being persisted have equal {@link EntityProxyId}. * * @param <P> the entity type */ @ProxyFor(Object.class) public interface EntityProxyId<P extends EntityProxy> { /** * Returns the class of the proxy identified. * * @return a Class object of type P */ Class<P> getProxyClass(); }
ProxyFor l = proxyType.getAnnotation(ProxyFor.class); ProxyForName ln = proxyType.getAnnotation(ProxyForName.class); if (l != null && !Locator.class.equals(l.locator())) { @SuppressWarnings("unchecked") Class<? extends Locator<?, ?>> found = (Class<? extends Locator<?, ?>>) l.locator(); locatorType = found; } else if (ln != null && ln.locator().length() > 0) {
@Override public Void visitType(TypeElement x, State state) { checkedElement = x; ProxyFor proxyFor = x.getAnnotation(ProxyFor.class); ProxyForName proxyForName = x.getAnnotation(ProxyForName.class); JsonRpcProxy jsonRpcProxy = x.getAnnotation(JsonRpcProxy.class); if (proxyFor != null) { poisonIfAnnotationPresent(state, x, proxyForName, jsonRpcProxy); // See javadoc on Element.getAnnotation() for why it works this way try { proxyFor.value(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror type = expected.getTypeMirror(); state.addMapping(x, (TypeElement) state.types.asElement(type)); } } if (proxyForName != null) { poisonIfAnnotationPresent(state, x, jsonRpcProxy); TypeElement domain = state.elements.getTypeElement(BinaryName.toSourceName(proxyForName.value())); if (domain == null) { state.warn(x, Messages.proxyMissingDomainType(proxyForName.value())); } state.addMapping(x, domain); } scanAllInheritedMethods(x, state); state.checkExtraTypes(x); return null; }
/** * A proxy for a server-side domain object. */ @ProxyFor(Object.class) public interface EntityProxy extends BaseProxy { /** * Returns the {@link EntityProxyId} that identifies a particular instance of * the type proxied by the receiver. * <p> * An id returned by a proxy newly created by {@link RequestContext#create} * {@link Object#equals(Object) equals} those returned later by proxies to the * persisted object. * <p> * Subtypes should override to declare they return a stable id of their own * type, to allow type safe use of the request objects returned by * {@link RequestFactory#find(EntityProxyId)}. * * @return an {@link EntityProxyId} instance */ EntityProxyId<?> stableId(); }
private boolean hasProxyLocator(TypeElement x, State state) { ProxyFor proxyFor = x.getAnnotation(ProxyFor.class); if (proxyFor != null) { // See javadoc on getAnnotation try { proxyFor.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.locatorType.asElement()); } } ProxyForName proxyForName = x.getAnnotation(ProxyForName.class); return proxyForName != null && !proxyForName.locator().isEmpty(); }
@Override public Class<?> resolveDomainClass(Class<?> clazz) { if (List.class.equals(clazz)) { return List.class; } else if (Set.class.equals(clazz)) { return Set.class; } else if (Map.class.equals(clazz)) { return Map.class; } else if (BaseProxy.class.isAssignableFrom(clazz)) { ProxyFor pf = clazz.getAnnotation(ProxyFor.class); if (pf != null) { return pf.value(); } ProxyForName pfn = clazz.getAnnotation(ProxyForName.class); if (pfn != null) { Class<?> toReturn = forName(pfn.value()); return toReturn; } } return die(null, "Could not resolve a domain type for client type %s", clazz.getCanonicalName()); }
/** * An analog to EntityProxy for domain types that do not have an identity * concept. */ @ProxyFor(Object.class) public interface ValueProxy extends BaseProxy { }
private boolean hasProxyLocator(TypeElement x, State state) { ProxyFor proxyFor = x.getAnnotation(ProxyFor.class); if (proxyFor != null) { // See javadoc on getAnnotation try { proxyFor.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.locatorType.asElement()); } } ProxyForName proxyForName = x.getAnnotation(ProxyForName.class); return proxyForName != null && !proxyForName.locator().isEmpty(); }
@Override public Class<?> resolveDomainClass(Class<?> clazz) { if (List.class.equals(clazz)) { return List.class; } else if (Set.class.equals(clazz)) { return Set.class; } else if (Map.class.equals(clazz)) { return Map.class; } else if (BaseProxy.class.isAssignableFrom(clazz)) { ProxyFor pf = clazz.getAnnotation(ProxyFor.class); if (pf != null) { return pf.value(); } ProxyForName pfn = clazz.getAnnotation(ProxyForName.class); if (pfn != null) { Class<?> toReturn = forName(pfn.value()); return toReturn; } } return die(null, "Could not resolve a domain type for client type %s", clazz.getCanonicalName()); }
/** * An analog to EntityProxy for domain types that do not have an identity * concept. */ @ProxyFor(Object.class) public interface ValueProxy extends BaseProxy { }
private boolean hasProxyLocator(TypeElement x, State state) { ProxyFor proxyFor = x.getAnnotation(ProxyFor.class); if (proxyFor != null) { // See javadoc on getAnnotation try { proxyFor.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.locatorType.asElement()); } } ProxyForName proxyForName = x.getAnnotation(ProxyForName.class); return proxyForName != null && !proxyForName.locator().isEmpty(); }
@Override public Class<?> resolveDomainClass(Class<?> clazz) { if (List.class.equals(clazz)) { return List.class; } else if (Set.class.equals(clazz)) { return Set.class; } else if (Map.class.equals(clazz)) { return Map.class; } else if (BaseProxy.class.isAssignableFrom(clazz)) { ProxyFor pf = clazz.getAnnotation(ProxyFor.class); if (pf != null) { return pf.value(); } ProxyForName pfn = clazz.getAnnotation(ProxyForName.class); if (pfn != null) { Class<?> toReturn = forName(pfn.value()); return toReturn; } } return die(null, "Could not resolve a domain type for client type %s", clazz.getCanonicalName()); }
/** * This interface is the note's entity-proxy. * An entity proxy is a client-side representation of a server-side entity. The proxy interfaces are implemented by RequestFactory. * */ @ProxyFor(value = NoteBean.class) public interface NoteValueProxy extends ValueProxy { public void setTitle(String title); public void setText(String text); public void setPath(String path); public String getTitle(); public String getText(); public String getPath(); }
ProxyFor l = proxyType.getAnnotation(ProxyFor.class); ProxyForName ln = proxyType.getAnnotation(ProxyForName.class); if (l != null && !Locator.class.equals(l.locator())) { @SuppressWarnings("unchecked") Class<? extends Locator<?, ?>> found = (Class<? extends Locator<?, ?>>) l.locator(); locatorType = found; } else if (ln != null && ln.locator().length() > 0) {
@Override public Void visitType(TypeElement x, State state) { checkedElement = x; ProxyFor proxyFor = x.getAnnotation(ProxyFor.class); ProxyForName proxyForName = x.getAnnotation(ProxyForName.class); JsonRpcProxy jsonRpcProxy = x.getAnnotation(JsonRpcProxy.class); if (proxyFor != null) { poisonIfAnnotationPresent(state, x, proxyForName, jsonRpcProxy); // See javadoc on Element.getAnnotation() for why it works this way try { proxyFor.value(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror type = expected.getTypeMirror(); state.addMapping(x, (TypeElement) state.types.asElement(type)); } } if (proxyForName != null) { poisonIfAnnotationPresent(state, x, jsonRpcProxy); TypeElement domain = state.elements.getTypeElement(BinaryName.toSourceName(proxyForName.value())); if (domain == null) { state.warn(x, Messages.proxyMissingDomainType(proxyForName.value())); } state.addMapping(x, domain); } scanAllInheritedMethods(x, state); state.checkExtraTypes(x); return null; }
/** * An analog to EntityProxy for domain types that do not have an identity * concept. */ @ProxyFor(Object.class) public interface ValueProxy extends BaseProxy { }
ProxyFor l = proxyType.getAnnotation(ProxyFor.class); ProxyForName ln = proxyType.getAnnotation(ProxyForName.class); if (l != null && !Locator.class.equals(l.locator())) { @SuppressWarnings("unchecked") Class<? extends Locator<?, ?>> found = (Class<? extends Locator<?, ?>>) l.locator(); locatorType = found; } else if (ln != null && ln.locator().length() > 0) {