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.

ServerConnector.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client;
  5. import java.util.Collection;
  6. import java.util.List;
  7. import com.google.gwt.event.shared.GwtEvent;
  8. import com.google.web.bindery.event.shared.HandlerRegistration;
  9. import com.vaadin.shared.Connector;
  10. import com.vaadin.shared.communication.ClientRpc;
  11. import com.vaadin.terminal.gwt.client.communication.StateChangeEvent.StateChangeHandler;
  12. /**
  13. * Interface implemented by all client side classes that can be communicate with
  14. * the server. Classes implementing this interface are initialized by the
  15. * framework when needed and have the ability to communicate with the server.
  16. *
  17. * @author Vaadin Ltd
  18. * @version @VERSION@
  19. * @since 7.0.0
  20. */
  21. public interface ServerConnector extends Connector {
  22. /**
  23. * Gets ApplicationConnection instance that created this connector.
  24. *
  25. * @return The ApplicationConnection as set by
  26. * {@link #doInit(String, ApplicationConnection)}
  27. */
  28. public ApplicationConnection getConnection();
  29. /**
  30. * Tests whether the connector is enabled or not. This method checks that
  31. * the connector is enabled in context, i.e. if the parent connector is
  32. * disabled, this method must return false.
  33. *
  34. * @return true if the connector is enabled, false otherwise
  35. */
  36. public boolean isEnabled();
  37. /**
  38. *
  39. * Called once by the framework to initialize the connector.
  40. * <p>
  41. * Note that the shared state is not yet available at this point nor any
  42. * hierarchy information.
  43. */
  44. public void doInit(String connectorId, ApplicationConnection connection);
  45. /**
  46. * For internal use by the framework: returns the registered RPC
  47. * implementations for an RPC interface identifier.
  48. *
  49. * TODO interface identifier type or format may change
  50. *
  51. * @param rpcInterfaceId
  52. * RPC interface identifier: fully qualified interface type name
  53. * @return RPC interface implementations registered for an RPC interface,
  54. * not null
  55. */
  56. public <T extends ClientRpc> Collection<T> getRpcImplementations(
  57. String rpcInterfaceId);
  58. /**
  59. * Adds a handler that is called whenever some part of the state has been
  60. * updated by the server.
  61. *
  62. * @param handler
  63. * The handler that should be added.
  64. * @return A handler registration reference that can be used to unregister
  65. * the handler
  66. */
  67. public HandlerRegistration addStateChangeHandler(StateChangeHandler handler);
  68. /**
  69. * Sends the given event to all registered handlers.
  70. *
  71. * @param event
  72. * The event to send.
  73. */
  74. public void fireEvent(GwtEvent<?> event);
  75. /**
  76. * Event called when connector has been unregistered.
  77. */
  78. public void onUnregister();
  79. /**
  80. * Returns the parent of this connector. Can be null for only the root
  81. * connector.
  82. *
  83. * @return The parent of this connector, as set by
  84. * {@link #setParent(ServerConnector)}.
  85. */
  86. @Override
  87. public ServerConnector getParent();
  88. /**
  89. * Sets the parent for this connector. This method should only be called by
  90. * the framework to ensure that the connector hierarchy on the client side
  91. * and the server side are in sync.
  92. * <p>
  93. * Note that calling this method does not fire a
  94. * {@link ConnectorHierarchyChangeEvent}. The event is fired only when the
  95. * whole hierarchy has been updated.
  96. *
  97. * @param parent
  98. * The new parent of the connector
  99. */
  100. public void setParent(ServerConnector parent);
  101. public void updateEnabledState(boolean enabledState);
  102. public void setChildren(List<ServerConnector> children);
  103. public List<ServerConnector> getChildren();
  104. }