Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ServerConnector.java 5.1KB

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