/** * Request selector interface for implementing a find method. */ @Service(FindService.class) public interface FindRequest extends RequestContext { /** * Use the implicit lookup in passing EntityProxy types to service methods. */ <P extends EntityProxy> Request<P> find(EntityProxyId<P> proxyId); }
private boolean hasServiceLocator(TypeElement x, State state) { Service service = x.getAnnotation(Service.class); if (service != null) { // See javadoc on getAnnotation try { service.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.serviceLocatorType.asElement()); } } ServiceName serviceName = x.getAnnotation(ServiceName.class); return serviceName != null && !serviceName.locator().isEmpty(); }
@Override public Class<?> resolveServiceClass(Class<? extends RequestContext> requestContextClass) { Class<?> searchIn = null; Service s = requestContextClass.getAnnotation(Service.class); if (s != null) { searchIn = s.value(); } ServiceName sn = requestContextClass.getAnnotation(ServiceName.class); if (sn != null) { searchIn = forName(sn.value()); } if (searchIn == null) { die(null, "The %s type %s did not specify a service type", RequestContext.class .getSimpleName(), requestContextClass.getCanonicalName()); } return searchIn; }
/** * "API Generated" request selector interface implemented by objects that give * client access to the methods of {@link Logging}. */ @Service(Logging.class) public interface LoggingRequest extends RequestContext { // TODO(unnurg): Pass a SerializableLogRecord here rather than it's // serialized string. /** * Log a message on the server. * * @param serializedLogRecordString a json serialized LogRecord, as provided * by * {@link com.google.gwt.logging.client.JsonLogRecordClientUtil#logRecordAsJsonObject(LogRecord)} * @return a Void {@link Request} */ Request<Void> logMessage(String serializedLogRecordString); }
@Override public Class<? extends ServiceLocator> resolveServiceLocator( Class<? extends RequestContext> requestContext) { Class<? extends ServiceLocator> locatorType; Service l = requestContext.getAnnotation(Service.class); ServiceName ln = requestContext.getAnnotation(ServiceName.class); if (l != null && !ServiceLocator.class.equals(l.locator())) { locatorType = l.locator(); } else if (ln != null && ln.locator().length() > 0) { try { locatorType = Class.forName(ln.locator(), false, getTop().getDomainClassLoader()).asSubclass( ServiceLocator.class); } catch (ClassNotFoundException e) { return die(e, "Could not find the locator type specified in the @%s annotation %s", ServiceName.class.getCanonicalName(), ln.value()); } } else { locatorType = null; } return locatorType; }
@Override public Void visitType(TypeElement x, State state) { checkedElement = x; Service service = x.getAnnotation(Service.class); ServiceName serviceName = x.getAnnotation(ServiceName.class); JsonRpcService jsonRpcService = x.getAnnotation(JsonRpcService.class); if (service != null) { poisonIfAnnotationPresent(state, x, serviceName, jsonRpcService); // See javadoc on Element.getAnnotation() for why it works this way try { service.value(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror type = expected.getTypeMirror(); state.addMapping(x, (TypeElement) state.types.asElement(type)); } } if (serviceName != null) { poisonIfAnnotationPresent(state, x, jsonRpcService); TypeElement domain = state.elements.getTypeElement(BinaryName.toSourceName(serviceName.value())); if (domain == null) { state.warn(x, Messages.contextMissingDomainType(serviceName.value())); } state.addMapping(x, domain); } scanAllInheritedMethods(x, state); state.checkExtraTypes(x); return null; }
@Service(value = NoteDao.class, locator = OsgiServiceLocator.class) public interface NoteRequestContext extends RequestContext { Request<List<NoteValueProxy>> getNotes(); Request<Void> createNote(NoteValueProxy note); Request<Void> deleteNote(String path); } NoteRequestContext context();
private boolean hasServiceLocator(TypeElement x, State state) { Service service = x.getAnnotation(Service.class); if (service != null) { // See javadoc on getAnnotation try { service.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.serviceLocatorType.asElement()); } } ServiceName serviceName = x.getAnnotation(ServiceName.class); return serviceName != null && !serviceName.locator().isEmpty(); }
@Override public Class<?> resolveServiceClass(Class<? extends RequestContext> requestContextClass) { Class<?> searchIn = null; Service s = requestContextClass.getAnnotation(Service.class); if (s != null) { searchIn = s.value(); } ServiceName sn = requestContextClass.getAnnotation(ServiceName.class); if (sn != null) { searchIn = forName(sn.value()); } if (searchIn == null) { die(null, "The %s type %s did not specify a service type", RequestContext.class .getSimpleName(), requestContextClass.getCanonicalName()); } return searchIn; }
/** * Request selector interface for implementing a find method. */ @Service(FindService.class) public interface FindRequest extends RequestContext { /** * Use the implicit lookup in passing EntityProxy types to service methods. */ <P extends EntityProxy> Request<P> find(EntityProxyId<P> proxyId); }
private boolean hasServiceLocator(TypeElement x, State state) { Service service = x.getAnnotation(Service.class); if (service != null) { // See javadoc on getAnnotation try { service.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.serviceLocatorType.asElement()); } } ServiceName serviceName = x.getAnnotation(ServiceName.class); return serviceName != null && !serviceName.locator().isEmpty(); }
@Override public Class<?> resolveServiceClass(Class<? extends RequestContext> requestContextClass) { Class<?> searchIn = null; Service s = requestContextClass.getAnnotation(Service.class); if (s != null) { searchIn = s.value(); } ServiceName sn = requestContextClass.getAnnotation(ServiceName.class); if (sn != null) { searchIn = forName(sn.value()); } if (searchIn == null) { die(null, "The %s type %s did not specify a service type", RequestContext.class .getSimpleName(), requestContextClass.getCanonicalName()); } return searchIn; }
/** * Request selector interface for implementing a find method. */ @Service(FindService.class) public interface FindRequest extends RequestContext { /** * Use the implicit lookup in passing EntityProxy types to service methods. */ <P extends EntityProxy> Request<P> find(EntityProxyId<P> proxyId); }
private boolean hasServiceLocator(TypeElement x, State state) { Service service = x.getAnnotation(Service.class); if (service != null) { // See javadoc on getAnnotation try { service.locator(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror locatorType = expected.getTypeMirror(); return !state.types.asElement(locatorType).equals(state.serviceLocatorType.asElement()); } } ServiceName serviceName = x.getAnnotation(ServiceName.class); return serviceName != null && !serviceName.locator().isEmpty(); }
@Override public Class<?> resolveServiceClass(Class<? extends RequestContext> requestContextClass) { Class<?> searchIn = null; Service s = requestContextClass.getAnnotation(Service.class); if (s != null) { searchIn = s.value(); } ServiceName sn = requestContextClass.getAnnotation(ServiceName.class); if (sn != null) { searchIn = forName(sn.value()); } if (searchIn == null) { die(null, "The %s type %s did not specify a service type", RequestContext.class .getSimpleName(), requestContextClass.getCanonicalName()); } return searchIn; }
/** * Request selector interface for implementing a find method. */ @Service(FindService.class) public interface FindRequest extends RequestContext { /** * Use the implicit lookup in passing EntityProxy types to service methods. */ <P extends EntityProxy> Request<P> find(EntityProxyId<P> proxyId); }
@Override public Class<? extends ServiceLocator> resolveServiceLocator( Class<? extends RequestContext> requestContext) { Class<? extends ServiceLocator> locatorType; Service l = requestContext.getAnnotation(Service.class); ServiceName ln = requestContext.getAnnotation(ServiceName.class); if (l != null && !ServiceLocator.class.equals(l.locator())) { locatorType = l.locator(); } else if (ln != null && ln.locator().length() > 0) { try { locatorType = Class.forName(ln.locator(), false, getTop().getDomainClassLoader()).asSubclass( ServiceLocator.class); } catch (ClassNotFoundException e) { return die(e, "Could not find the locator type specified in the @%s annotation %s", ServiceName.class.getCanonicalName(), ln.value()); } } else { locatorType = null; } return locatorType; }
@Override public Void visitType(TypeElement x, State state) { checkedElement = x; Service service = x.getAnnotation(Service.class); ServiceName serviceName = x.getAnnotation(ServiceName.class); JsonRpcService jsonRpcService = x.getAnnotation(JsonRpcService.class); if (service != null) { poisonIfAnnotationPresent(state, x, serviceName, jsonRpcService); // See javadoc on Element.getAnnotation() for why it works this way try { service.value(); throw new RuntimeException("Should not reach here"); } catch (MirroredTypeException expected) { TypeMirror type = expected.getTypeMirror(); state.addMapping(x, (TypeElement) state.types.asElement(type)); } } if (serviceName != null) { poisonIfAnnotationPresent(state, x, jsonRpcService); TypeElement domain = state.elements.getTypeElement(BinaryName.toSourceName(serviceName.value())); if (domain == null) { state.warn(x, Messages.contextMissingDomainType(serviceName.value())); } state.addMapping(x, domain); } scanAllInheritedMethods(x, state); state.checkExtraTypes(x); return null; }
@Service(value = LocaleService.class, locator = GwtServiceLocator.class) public interface LocaleRequest extends RequestContext { Request<Void> setLocale(String localeCode); }
@Override public Class<? extends ServiceLocator> resolveServiceLocator( Class<? extends RequestContext> requestContext) { Class<? extends ServiceLocator> locatorType; Service l = requestContext.getAnnotation(Service.class); ServiceName ln = requestContext.getAnnotation(ServiceName.class); if (l != null && !ServiceLocator.class.equals(l.locator())) { locatorType = l.locator(); } else if (ln != null && ln.locator().length() > 0) { try { locatorType = Class.forName(ln.locator(), false, getTop().getDomainClassLoader()).asSubclass( ServiceLocator.class); } catch (ClassNotFoundException e) { return die(e, "Could not find the locator type specified in the @%s annotation %s", ServiceName.class.getCanonicalName(), ln.value()); } } else { locatorType = null; } return locatorType; }