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.

MethodInvocation.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2011 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.shared.communication;
  17. import java.io.Serializable;
  18. import java.util.Arrays;
  19. /**
  20. * Information needed by the framework to send an RPC method invocation from the
  21. * client to the server or vice versa.
  22. *
  23. * @since 7.0
  24. */
  25. public class MethodInvocation implements Serializable {
  26. private final String connectorId;
  27. private final String interfaceName;
  28. private final String methodName;
  29. private Object[] parameters;
  30. public MethodInvocation(String connectorId, String interfaceName,
  31. String methodName) {
  32. this.connectorId = connectorId;
  33. this.interfaceName = interfaceName;
  34. this.methodName = methodName;
  35. }
  36. public MethodInvocation(String connectorId, String interfaceName,
  37. String methodName, Object[] parameters) {
  38. this(connectorId, interfaceName, methodName);
  39. setParameters(parameters);
  40. }
  41. public String getConnectorId() {
  42. return connectorId;
  43. }
  44. public String getInterfaceName() {
  45. return interfaceName;
  46. }
  47. public String getMethodName() {
  48. return methodName;
  49. }
  50. public Object[] getParameters() {
  51. return parameters;
  52. }
  53. public void setParameters(Object[] parameters) {
  54. this.parameters = parameters;
  55. }
  56. @Override
  57. public String toString() {
  58. return connectorId + ":" + interfaceName + "." + methodName + "("
  59. + Arrays.toString(parameters) + ")";
  60. }
  61. /**
  62. * Gets a String tag that is used to uniquely identify previous method
  63. * invocations that should be purged from the queue if
  64. * <code>{@literal @}Delay(lastonly = true)</code> is used.
  65. * <p>
  66. * The returned string should contain at least one non-number char to ensure
  67. * it doesn't collide with the keys used for invocations without lastonly.
  68. *
  69. * @return a string identifying this method invocation
  70. */
  71. public String getLastonlyTag() {
  72. return connectorId + "-" + getInterfaceName() + "-" + getMethodName();
  73. }
  74. }