You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerRpcVisitor.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server.widgetsetutils.metadata;
  17. import java.util.Set;
  18. import com.google.gwt.core.ext.TreeLogger;
  19. import com.google.gwt.core.ext.UnableToCompleteException;
  20. import com.google.gwt.core.ext.typeinfo.JClassType;
  21. import com.google.gwt.core.ext.typeinfo.JMethod;
  22. import com.google.gwt.core.ext.typeinfo.JType;
  23. import com.vaadin.client.metadata.TypeDataStore.MethodAttribute;
  24. import com.vaadin.shared.annotations.Delayed;
  25. import com.vaadin.shared.annotations.NoLoadingIndicator;
  26. public class ServerRpcVisitor extends TypeVisitor {
  27. @Override
  28. public void visitServerRpc(TreeLogger logger, JClassType type,
  29. ConnectorBundle bundle) throws UnableToCompleteException {
  30. ClientRpcVisitor.checkGenericType(logger, type);
  31. bundle.setNeedsProxySupport(type);
  32. Set<? extends JClassType> superTypes = type
  33. .getFlattenedSupertypeHierarchy();
  34. for (JClassType subType : superTypes) {
  35. if (subType.isInterface() != null) {
  36. JMethod[] methods = subType.getMethods();
  37. for (JMethod method : methods) {
  38. ClientRpcVisitor.checkReturnType(logger, method);
  39. Delayed delayed = method.getAnnotation(Delayed.class);
  40. if (delayed != null) {
  41. bundle.setMethodAttribute(type, method,
  42. MethodAttribute.DELAYED);
  43. if (delayed.lastOnly()) {
  44. bundle.setMethodAttribute(type, method,
  45. MethodAttribute.LAST_ONLY);
  46. }
  47. }
  48. if (method
  49. .getAnnotation(NoLoadingIndicator.class) != null) {
  50. bundle.setMethodAttribute(type, method,
  51. MethodAttribute.NO_LOADING_INDICATOR);
  52. }
  53. bundle.setNeedsParamTypes(type, method);
  54. JType[] parameterTypes = method.getParameterTypes();
  55. for (JType paramType : parameterTypes) {
  56. bundle.setNeedsSerialize(paramType);
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }