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.7KB

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