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.

ConnectorBundle.java 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*
  2. * Copyright 2000-2014 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.io.Serializable;
  18. import java.util.Arrays;
  19. import java.util.Collection;
  20. import java.util.Collections;
  21. import java.util.HashMap;
  22. import java.util.HashSet;
  23. import java.util.Iterator;
  24. import java.util.List;
  25. import java.util.Map;
  26. import java.util.Set;
  27. import com.google.gwt.core.ext.TreeLogger;
  28. import com.google.gwt.core.ext.TreeLogger.Type;
  29. import com.google.gwt.core.ext.UnableToCompleteException;
  30. import com.google.gwt.core.ext.typeinfo.JArrayType;
  31. import com.google.gwt.core.ext.typeinfo.JClassType;
  32. import com.google.gwt.core.ext.typeinfo.JEnumType;
  33. import com.google.gwt.core.ext.typeinfo.JMethod;
  34. import com.google.gwt.core.ext.typeinfo.JParameterizedType;
  35. import com.google.gwt.core.ext.typeinfo.JType;
  36. import com.google.gwt.core.ext.typeinfo.NotFoundException;
  37. import com.google.gwt.core.ext.typeinfo.TypeOracle;
  38. import com.google.gwt.json.client.JSONValue;
  39. import com.vaadin.client.ApplicationConnection;
  40. import com.vaadin.client.ComponentConnector;
  41. import com.vaadin.client.ServerConnector;
  42. import com.vaadin.client.communication.JSONSerializer;
  43. import com.vaadin.client.ui.UnknownComponentConnector;
  44. import com.vaadin.client.ui.grid.renderers.AbstractRendererConnector;
  45. import com.vaadin.shared.communication.ClientRpc;
  46. import com.vaadin.shared.communication.ServerRpc;
  47. import com.vaadin.shared.ui.Connect;
  48. public class ConnectorBundle {
  49. private static final String FAIL_IF_NOT_SERIALIZABLE = "vFailIfNotSerializable";
  50. private final String name;
  51. private final ConnectorBundle previousBundle;
  52. private final Collection<TypeVisitor> visitors;
  53. private final Map<JType, JClassType> customSerializers;
  54. private final Set<JType> hasSerializeSupport = new HashSet<JType>();
  55. private final Set<JType> needsSerializeSupport = new HashSet<JType>();
  56. private final Map<JType, GeneratedSerializer> serializers = new HashMap<JType, GeneratedSerializer>();
  57. private final Set<JClassType> needsSuperClass = new HashSet<JClassType>();
  58. private final Set<JClassType> needsGwtConstructor = new HashSet<JClassType>();
  59. private final Set<JClassType> visitedTypes = new HashSet<JClassType>();
  60. private final Set<JClassType> needsProxySupport = new HashSet<JClassType>();
  61. private final Map<JClassType, Set<String>> identifiers = new HashMap<JClassType, Set<String>>();
  62. private final Map<JClassType, Set<JMethod>> needsReturnType = new HashMap<JClassType, Set<JMethod>>();
  63. private final Map<JClassType, Set<JMethod>> needsInvoker = new HashMap<JClassType, Set<JMethod>>();
  64. private final Map<JClassType, Set<JMethod>> needsParamTypes = new HashMap<JClassType, Set<JMethod>>();
  65. private final Map<JClassType, Set<JMethod>> needsDelayedInfo = new HashMap<JClassType, Set<JMethod>>();
  66. private final Map<JClassType, Set<JMethod>> needsOnStateChange = new HashMap<JClassType, Set<JMethod>>();
  67. private final Set<Property> needsProperty = new HashSet<Property>();
  68. private final Set<Property> needsDelegateToWidget = new HashSet<Property>();
  69. private ConnectorBundle(String name, ConnectorBundle previousBundle,
  70. Collection<TypeVisitor> visitors,
  71. Map<JType, JClassType> customSerializers) {
  72. this.name = name;
  73. this.previousBundle = previousBundle;
  74. this.visitors = visitors;
  75. this.customSerializers = customSerializers;
  76. }
  77. public ConnectorBundle(String name, ConnectorBundle previousBundle) {
  78. this(name, previousBundle, previousBundle.visitors,
  79. previousBundle.customSerializers);
  80. }
  81. public ConnectorBundle(String name, Collection<TypeVisitor> visitors,
  82. TypeOracle oracle) throws NotFoundException {
  83. this(name, null, visitors, findCustomSerializers(oracle));
  84. }
  85. private static Map<JType, JClassType> findCustomSerializers(
  86. TypeOracle oracle) throws NotFoundException {
  87. Map<JType, JClassType> serializers = new HashMap<JType, JClassType>();
  88. JClassType serializerInterface = oracle.findType(JSONSerializer.class
  89. .getName());
  90. JType[] deserializeParamTypes = new JType[] {
  91. oracle.findType(com.vaadin.client.metadata.Type.class.getName()),
  92. oracle.findType(JSONValue.class.getName()),
  93. oracle.findType(ApplicationConnection.class.getName()) };
  94. String deserializeMethodName = "deserialize";
  95. // Just test that the method exists
  96. serializerInterface.getMethod(deserializeMethodName,
  97. deserializeParamTypes);
  98. for (JClassType serializer : serializerInterface.getSubtypes()) {
  99. JMethod deserializeMethod = serializer.findMethod(
  100. deserializeMethodName, deserializeParamTypes);
  101. if (deserializeMethod == null) {
  102. continue;
  103. }
  104. JType returnType = deserializeMethod.getReturnType();
  105. serializers.put(returnType, serializer);
  106. }
  107. return serializers;
  108. }
  109. public void setNeedsGwtConstructor(JClassType type) {
  110. if (!needsGwtConstructor(type)) {
  111. needsGwtConstructor.add(type);
  112. }
  113. }
  114. private boolean needsGwtConstructor(JClassType type) {
  115. if (needsGwtConstructor.contains(type)) {
  116. return true;
  117. } else {
  118. return previousBundle != null
  119. && previousBundle.needsGwtConstructor(type);
  120. }
  121. }
  122. public void setIdentifier(JClassType type, String identifier) {
  123. if (!hasIdentifier(type, identifier)) {
  124. addMapping(identifiers, type, identifier);
  125. }
  126. }
  127. private boolean hasIdentifier(JClassType type, String identifier) {
  128. if (hasMapping(identifiers, type, identifier)) {
  129. return true;
  130. } else {
  131. return previousBundle != null
  132. && previousBundle.hasIdentifier(type, identifier);
  133. }
  134. }
  135. public ConnectorBundle getPreviousBundle() {
  136. return previousBundle;
  137. }
  138. public String getName() {
  139. return name;
  140. }
  141. public Map<JClassType, Set<String>> getIdentifiers() {
  142. return Collections.unmodifiableMap(identifiers);
  143. }
  144. public Set<JClassType> getGwtConstructors() {
  145. return Collections.unmodifiableSet(needsGwtConstructor);
  146. }
  147. public void processTypes(TreeLogger logger, Collection<JClassType> types)
  148. throws UnableToCompleteException {
  149. for (JClassType type : types) {
  150. processType(logger, type);
  151. }
  152. }
  153. public void processType(TreeLogger logger, JClassType type)
  154. throws UnableToCompleteException {
  155. if (!isTypeVisited(type)) {
  156. for (TypeVisitor typeVisitor : visitors) {
  157. invokeVisitor(logger, type, typeVisitor);
  158. }
  159. visitedTypes.add(type);
  160. purgeSerializeSupportQueue(logger);
  161. }
  162. }
  163. private boolean isTypeVisited(JClassType type) {
  164. if (visitedTypes.contains(type)) {
  165. return true;
  166. } else {
  167. return previousBundle != null && previousBundle.isTypeVisited(type);
  168. }
  169. }
  170. private void purgeSerializeSupportQueue(TreeLogger logger)
  171. throws UnableToCompleteException {
  172. while (!needsSerializeSupport.isEmpty()) {
  173. Iterator<JType> iterator = needsSerializeSupport.iterator();
  174. JType type = iterator.next();
  175. iterator.remove();
  176. if (hasSerializeSupport(type)) {
  177. continue;
  178. }
  179. addSerializeSupport(logger, type);
  180. }
  181. }
  182. private void addSerializeSupport(TreeLogger logger, JType type)
  183. throws UnableToCompleteException {
  184. hasSerializeSupport.add(type);
  185. JParameterizedType parametrized = type.isParameterized();
  186. if (parametrized != null) {
  187. for (JClassType parameterType : parametrized.getTypeArgs()) {
  188. setNeedsSerialize(parameterType);
  189. }
  190. }
  191. if (serializationHandledByFramework(type)) {
  192. return;
  193. }
  194. JClassType customSerializer = customSerializers.get(type);
  195. JClassType typeAsClass = type.isClass();
  196. JEnumType enumType = type.isEnum();
  197. JArrayType arrayType = type.isArray();
  198. if (customSerializer != null) {
  199. logger.log(Type.INFO, "Will serialize " + type + " using "
  200. + customSerializer.getName());
  201. setSerializer(type, new CustomSerializer(customSerializer));
  202. } else if (arrayType != null) {
  203. logger.log(Type.INFO, "Will serialize " + type + " as an array");
  204. setSerializer(type, new ArraySerializer(arrayType));
  205. setNeedsSerialize(arrayType.getComponentType());
  206. } else if (enumType != null) {
  207. logger.log(Type.INFO, "Will serialize " + type + " as an enum");
  208. setSerializer(type, new EnumSerializer(enumType));
  209. } else if (typeAsClass != null) {
  210. // Bean
  211. checkSerializable(logger, typeAsClass);
  212. logger.log(Type.INFO, "Will serialize " + type + " as a bean");
  213. JClassType needsSuperClass = typeAsClass;
  214. while (needsSuperClass != null) {
  215. if (needsSuperClass.isPublic()) {
  216. setNeedsSuperclass(needsSuperClass);
  217. }
  218. needsSuperClass = needsSuperClass.getSuperclass();
  219. }
  220. setNeedsGwtConstructor(typeAsClass);
  221. for (Property property : getProperties(typeAsClass)) {
  222. setNeedsProperty(property);
  223. JType propertyType = property.getPropertyType();
  224. setNeedsSerialize(propertyType);
  225. }
  226. }
  227. }
  228. private void checkSerializable(TreeLogger logger, JClassType type)
  229. throws UnableToCompleteException {
  230. JClassType javaSerializable = type.getOracle().findType(
  231. Serializable.class.getName());
  232. boolean serializable = type.isAssignableTo(javaSerializable);
  233. if (!serializable) {
  234. boolean abortCompile = "true".equals(System
  235. .getProperty(FAIL_IF_NOT_SERIALIZABLE));
  236. logger.log(
  237. abortCompile ? Type.ERROR : Type.WARN,
  238. type
  239. + " is used in RPC or shared state but does not implement "
  240. + Serializable.class.getName()
  241. + ". Communication will work but the Application on server side cannot be serialized if it refers to objects of this type. "
  242. + "If the system property "
  243. + FAIL_IF_NOT_SERIALIZABLE
  244. + " is set to \"true\", this causes the compilation to fail instead of just emitting a warning.");
  245. if (abortCompile) {
  246. throw new UnableToCompleteException();
  247. }
  248. }
  249. }
  250. private void setSerializer(JType type, GeneratedSerializer serializer) {
  251. if (!hasSerializer(type)) {
  252. serializers.put(type, serializer);
  253. }
  254. }
  255. private boolean hasSerializer(JType type) {
  256. if (serializers.containsKey(type)) {
  257. return true;
  258. } else {
  259. return previousBundle != null && previousBundle.hasSerializer(type);
  260. }
  261. }
  262. public Map<JType, GeneratedSerializer> getSerializers() {
  263. return Collections.unmodifiableMap(serializers);
  264. }
  265. private void setNeedsSuperclass(JClassType typeAsClass) {
  266. if (!isNeedsSuperClass(typeAsClass)) {
  267. needsSuperClass.add(typeAsClass);
  268. }
  269. }
  270. private boolean isNeedsSuperClass(JClassType typeAsClass) {
  271. if (needsSuperClass.contains(typeAsClass)) {
  272. return true;
  273. } else {
  274. return previousBundle != null
  275. && previousBundle.isNeedsSuperClass(typeAsClass);
  276. }
  277. }
  278. public Set<JClassType> getNeedsSuperclass() {
  279. return Collections.unmodifiableSet(needsSuperClass);
  280. }
  281. private void setNeedsProperty(Property property) {
  282. if (!isNeedsProperty(property)) {
  283. needsProperty.add(property);
  284. }
  285. }
  286. private boolean isNeedsProperty(Property property) {
  287. if (needsProperty.contains(property)) {
  288. return true;
  289. } else {
  290. return previousBundle != null
  291. && previousBundle.isNeedsProperty(property);
  292. }
  293. }
  294. public Set<Property> getNeedsProperty() {
  295. return Collections.unmodifiableSet(needsProperty);
  296. }
  297. public Collection<Property> getProperties(JClassType type) {
  298. HashSet<Property> properties = new HashSet<Property>();
  299. properties.addAll(MethodProperty.findProperties(type));
  300. properties.addAll(FieldProperty.findProperties(type));
  301. return properties;
  302. }
  303. private void invokeVisitor(TreeLogger logger, JClassType type,
  304. TypeVisitor typeVisitor) throws UnableToCompleteException {
  305. TreeLogger subLogger = logger.branch(Type.TRACE,
  306. "Visiting " + type.getName() + " with "
  307. + typeVisitor.getClass().getSimpleName());
  308. if (isConnectedConnector(type)) {
  309. typeVisitor.visitConnector(subLogger, type, this);
  310. }
  311. if (isClientRpc(type)) {
  312. typeVisitor.visitClientRpc(subLogger, type, this);
  313. }
  314. if (isServerRpc(type)) {
  315. typeVisitor.visitServerRpc(subLogger, type, this);
  316. }
  317. }
  318. public void processSubTypes(TreeLogger logger, JClassType type)
  319. throws UnableToCompleteException {
  320. processTypes(logger, Arrays.asList(type.getSubtypes()));
  321. }
  322. public void setNeedsReturnType(JClassType type, JMethod method) {
  323. if (!isNeedsReturnType(type, method)) {
  324. addMapping(needsReturnType, type, method);
  325. }
  326. }
  327. private boolean isNeedsReturnType(JClassType type, JMethod method) {
  328. if (hasMapping(needsReturnType, type, method)) {
  329. return true;
  330. } else {
  331. return previousBundle != null
  332. && previousBundle.isNeedsReturnType(type, method);
  333. }
  334. }
  335. public Map<JClassType, Set<JMethod>> getMethodReturnTypes() {
  336. return Collections.unmodifiableMap(needsReturnType);
  337. }
  338. private static boolean isClientRpc(JClassType type) {
  339. return isInterfaceType(type, ClientRpc.class);
  340. }
  341. private static boolean isServerRpc(JClassType type) {
  342. return isInterfaceType(type, ServerRpc.class);
  343. }
  344. public static boolean isConnectedConnector(JClassType type) {
  345. return isConnected(type) && isType(type, ServerConnector.class);
  346. }
  347. private static boolean isConnected(JClassType type) {
  348. return type.isAnnotationPresent(Connect.class)
  349. || type.getQualifiedSourceName().equals(
  350. UnknownComponentConnector.class.getCanonicalName());
  351. }
  352. public static boolean isConnectedComponentConnector(JClassType type) {
  353. return isConnected(type) && isType(type, ComponentConnector.class);
  354. }
  355. public static boolean isConnectedRendererConnector(JClassType type) {
  356. return isConnected(type)
  357. && isType(type, AbstractRendererConnector.class);
  358. }
  359. private static boolean isInterfaceType(JClassType type, Class<?> class1) {
  360. return type.isInterface() != null && isType(type, class1);
  361. }
  362. private static boolean isType(JClassType type, Class<?> class1) {
  363. try {
  364. return type.getOracle().getType(class1.getName())
  365. .isAssignableFrom(type);
  366. } catch (NotFoundException e) {
  367. throw new RuntimeException("Could not find " + class1.getName(), e);
  368. }
  369. }
  370. public void setNeedsInvoker(JClassType type, JMethod method) {
  371. if (!isNeedsInvoker(type, method)) {
  372. addMapping(needsInvoker, type, method);
  373. }
  374. }
  375. private <K, V> void addMapping(Map<K, Set<V>> map, K key, V value) {
  376. Set<V> set = map.get(key);
  377. if (set == null) {
  378. set = new HashSet<V>();
  379. map.put(key, set);
  380. }
  381. set.add(value);
  382. }
  383. private <K, V> boolean hasMapping(Map<K, Set<V>> map, K key, V value) {
  384. return map.containsKey(key) && map.get(key).contains(value);
  385. }
  386. private boolean isNeedsInvoker(JClassType type, JMethod method) {
  387. if (hasMapping(needsInvoker, type, method)) {
  388. return true;
  389. } else {
  390. return previousBundle != null
  391. && previousBundle.isNeedsInvoker(type, method);
  392. }
  393. }
  394. public Map<JClassType, Set<JMethod>> getNeedsInvoker() {
  395. return Collections.unmodifiableMap(needsInvoker);
  396. }
  397. public void setNeedsParamTypes(JClassType type, JMethod method) {
  398. if (!isNeedsParamTypes(type, method)) {
  399. addMapping(needsParamTypes, type, method);
  400. }
  401. }
  402. private boolean isNeedsParamTypes(JClassType type, JMethod method) {
  403. if (hasMapping(needsParamTypes, type, method)) {
  404. return true;
  405. } else {
  406. return previousBundle != null
  407. && previousBundle.isNeedsParamTypes(type, method);
  408. }
  409. }
  410. public Map<JClassType, Set<JMethod>> getNeedsParamTypes() {
  411. return Collections.unmodifiableMap(needsParamTypes);
  412. }
  413. public void setNeedsProxySupport(JClassType type) {
  414. if (!isNeedsProxySupport(type)) {
  415. needsProxySupport.add(type);
  416. }
  417. }
  418. private boolean isNeedsProxySupport(JClassType type) {
  419. if (needsProxySupport.contains(type)) {
  420. return true;
  421. } else {
  422. return previousBundle != null
  423. && previousBundle.isNeedsProxySupport(type);
  424. }
  425. }
  426. public Set<JClassType> getNeedsProxySupport() {
  427. return Collections.unmodifiableSet(needsProxySupport);
  428. }
  429. public void setNeedsDelayedInfo(JClassType type, JMethod method) {
  430. if (!isNeedsDelayedInfo(type, method)) {
  431. addMapping(needsDelayedInfo, type, method);
  432. }
  433. }
  434. private boolean isNeedsDelayedInfo(JClassType type, JMethod method) {
  435. if (hasMapping(needsDelayedInfo, type, method)) {
  436. return true;
  437. } else {
  438. return previousBundle != null
  439. && previousBundle.isNeedsDelayedInfo(type, method);
  440. }
  441. }
  442. public Map<JClassType, Set<JMethod>> getNeedsDelayedInfo() {
  443. return Collections.unmodifiableMap(needsDelayedInfo);
  444. }
  445. public void setNeedsSerialize(JType type) {
  446. if (!hasSerializeSupport(type)) {
  447. needsSerializeSupport.add(type);
  448. }
  449. }
  450. private static Set<Class<?>> frameworkHandledTypes = new HashSet<Class<?>>();
  451. {
  452. frameworkHandledTypes.add(String.class);
  453. frameworkHandledTypes.add(Boolean.class);
  454. frameworkHandledTypes.add(Integer.class);
  455. frameworkHandledTypes.add(Float.class);
  456. frameworkHandledTypes.add(Double.class);
  457. frameworkHandledTypes.add(Long.class);
  458. frameworkHandledTypes.add(Enum.class);
  459. frameworkHandledTypes.add(String[].class);
  460. frameworkHandledTypes.add(Object[].class);
  461. frameworkHandledTypes.add(Map.class);
  462. frameworkHandledTypes.add(List.class);
  463. frameworkHandledTypes.add(Set.class);
  464. frameworkHandledTypes.add(Byte.class);
  465. frameworkHandledTypes.add(Character.class);
  466. }
  467. private boolean serializationHandledByFramework(JType setterType) {
  468. // Some types are handled by the framework at the moment. See #8449
  469. // This method should be removed at some point.
  470. if (setterType.isPrimitive() != null) {
  471. return true;
  472. }
  473. String qualifiedName = setterType.getQualifiedSourceName();
  474. for (Class<?> cls : frameworkHandledTypes) {
  475. if (qualifiedName.equals(cls.getName())) {
  476. return true;
  477. }
  478. }
  479. return false;
  480. }
  481. private boolean hasSerializeSupport(JType type) {
  482. if (hasSerializeSupport.contains(type)) {
  483. return true;
  484. } else {
  485. return previousBundle != null
  486. && previousBundle.hasSerializeSupport(type);
  487. }
  488. }
  489. public void setNeedsDelegateToWidget(Property property) {
  490. if (!isNeedsDelegateToWidget(property)) {
  491. needsDelegateToWidget.add(property);
  492. }
  493. }
  494. private boolean isNeedsDelegateToWidget(Property property) {
  495. if (needsDelegateToWidget.contains(property)) {
  496. return true;
  497. } else {
  498. return previousBundle != null
  499. && previousBundle.isNeedsDelegateToWidget(property);
  500. }
  501. }
  502. public Set<Property> getNeedsDelegateToWidget() {
  503. return Collections.unmodifiableSet(needsDelegateToWidget);
  504. }
  505. public void setNeedsOnStateChangeHandler(JClassType type, JMethod method) {
  506. if (!isNeedsOnStateChangeHandler(type, method)) {
  507. addMapping(needsOnStateChange, type, method);
  508. }
  509. }
  510. private boolean isNeedsOnStateChangeHandler(JClassType type, JMethod method) {
  511. if (hasMapping(needsOnStateChange, type, method)) {
  512. return true;
  513. } else {
  514. return previousBundle != null
  515. && previousBundle.isNeedsOnStateChangeHandler(type, method);
  516. }
  517. }
  518. public Map<JClassType, Set<JMethod>> getNeedsOnStateChangeHandler() {
  519. return Collections.unmodifiableMap(needsOnStateChange);
  520. }
  521. public static JMethod findInheritedMethod(JClassType type,
  522. String methodName, JType... params) {
  523. JClassType currentType = type;
  524. while (currentType != null) {
  525. JMethod method = currentType.findMethod(methodName, params);
  526. if (method != null) {
  527. return method;
  528. }
  529. currentType = currentType.getSuperclass();
  530. }
  531. JClassType[] interfaces = type.getImplementedInterfaces();
  532. for (JClassType iface : interfaces) {
  533. JMethod method = iface.findMethod(methodName, params);
  534. if (method != null) {
  535. return method;
  536. }
  537. }
  538. return null;
  539. }
  540. }