public abstract class AbstractConnector extends Object implements ServerConnector, StateChangeEvent.StateChangeHandler
Constructor and Description |
---|
AbstractConnector() |
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addStateChangeHandler(StateChangeEvent.StateChangeHandler handler)
Adds a handler that is called whenever any part of the state has been
updated by the server.
|
com.google.gwt.event.shared.HandlerRegistration |
addStateChangeHandler(String propertyName,
StateChangeEvent.StateChangeHandler handler)
Adds a handler that is called whenever the given part of the state has
been updated by the server.
|
protected SharedState |
createState()
Creates a state object with default values for this connector.
|
void |
doInit(String connectorId,
ApplicationConnection connection)
Called once by the framework to initialize the connector.
|
protected com.google.gwt.event.shared.HandlerManager |
ensureHandlerManager() |
void |
fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
Sends the given event to all registered handlers.
|
void |
forceStateChange()
Force the connector to recheck its state variables as the variables or
their meaning might have changed.
|
List<ServerConnector> |
getChildren()
Returns the child connectors for this connector (child components and
extensions).
|
ApplicationConnection |
getConnection()
Gets ApplicationConnection instance that created this connector.
|
String |
getConnectorId()
Returns the id for this connector.
|
ServerConnector |
getParent()
Returns the parent of this connector.
|
String |
getResourceUrl(String key)
Gets the URL for a resource that has been added by the server-side
connector using
com.vaadin.terminal.AbstractClientConnector#setResource(String, com.vaadin.terminal.Resource)
with the same key. |
<T extends ClientRpc> |
getRpcImplementations(String rpcInterfaceId)
For internal use by the framework: returns the registered RPC
implementations for an RPC interface identifier.
|
protected <T extends ServerRpc> |
getRpcProxy(Class<T> rpcInterface)
Returns an RPC proxy object which can be used to invoke the RPC method on
the server.
|
SharedState |
getState()
Returns the shared state object for this connector.
|
static Type |
getStateType(ServerConnector connector) |
boolean |
hasEventListener(String eventIdentifier)
Checks if an event listener has been registered on the server side for
the given event identifier.
|
protected void |
init()
Called when the connector has been initialized.
|
boolean |
isEnabled()
Tests whether the connector is enabled or not.
|
void |
onStateChanged(StateChangeEvent stateChangeEvent)
Notifies the event handler that the state has changed.
|
void |
onUnregister()
Event called when connector has been unregistered.
|
protected <T extends ClientRpc> |
registerRpc(Class<T> rpcInterface,
T implementation)
Registers an implementation for a server to client RPC interface.
|
void |
removeStateChangeHandler(StateChangeEvent.StateChangeHandler handler)
Removes a handler that is called whenever any part of the state has been
updated by the server.
|
void |
removeStateChangeHandler(String propertyName,
StateChangeEvent.StateChangeHandler handler)
Removes a handler that is called whenever any part of the state has been
updated by the server.
|
void |
setChildren(List<ServerConnector> children)
Sets the children for this connector.
|
void |
setParent(ServerConnector parent)
Sets the parent for this connector.
|
protected <T extends ClientRpc> |
unregisterRpc(Class<T> rpcInterface,
T implementation)
Unregisters an implementation for a server to client RPC interface.
|
void |
updateEnabledState(boolean enabledState) |
public final ApplicationConnection getConnection()
ServerConnector
getConnection
in interface ServerConnector
ServerConnector.doInit(String, ApplicationConnection)
public String getConnectorId()
Connector
getConnectorId
in interface Connector
public final void doInit(String connectorId, ApplicationConnection connection)
Note that the shared state is not yet available when this method is called.
Connector classes should override init()
instead of this method.
doInit
in interface ServerConnector
protected void init()
protected <T extends ClientRpc> void registerRpc(Class<T> rpcInterface, T implementation)
T
- The type of the RPC interface that is being registeredrpcInterface
- RPC interfaceimplementation
- implementation that should receive RPC callsprotected <T extends ClientRpc> void unregisterRpc(Class<T> rpcInterface, T implementation)
rpcInterface
- RPC interfaceimplementation
- implementation to unregisterprotected <T extends ServerRpc> T getRpcProxy(Class<T> rpcInterface)
T
- The type of the ServerRpc interfacerpcInterface
- The ServerRpc interface to retrieve a proxy object forpublic <T extends ClientRpc> Collection<T> getRpcImplementations(String rpcInterfaceId)
ServerConnector
getRpcImplementations
in interface ServerConnector
rpcInterfaceId
- RPC interface identifier: fully qualified interface type namepublic void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
ServerConnector
fireEvent
in interface ServerConnector
event
- The event to send.protected com.google.gwt.event.shared.HandlerManager ensureHandlerManager()
public com.google.gwt.event.shared.HandlerRegistration addStateChangeHandler(StateChangeEvent.StateChangeHandler handler)
ServerConnector
addStateChangeHandler
in interface ServerConnector
handler
- The handler that should be added.public void removeStateChangeHandler(StateChangeEvent.StateChangeHandler handler)
ServerConnector
removeStateChangeHandler
in interface ServerConnector
handler
- The handler that should be removed.public com.google.gwt.event.shared.HandlerRegistration addStateChangeHandler(String propertyName, StateChangeEvent.StateChangeHandler handler)
ServerConnector
addStateChangeHandler
in interface ServerConnector
propertyName
- the name of the property for which the handler should be
calledhandler
- The handler that should be added.public void removeStateChangeHandler(String propertyName, StateChangeEvent.StateChangeHandler handler)
ServerConnector
removeStateChangeHandler
in interface ServerConnector
propertyName
- the name of the property for which the handler should be
calledhandler
- The handler that should be removed.public void onStateChanged(StateChangeEvent stateChangeEvent)
StateChangeEvent.StateChangeHandler
onStateChanged
in interface StateChangeEvent.StateChangeHandler
stateChangeEvent
- the state change event with details about the changepublic void onUnregister()
ServerConnector
onUnregister
in interface ServerConnector
public SharedState getState()
getState
in interface ServerConnector
protected SharedState createState()
getState()
. The default implementation creates a state object
using GWT.create() using the defined return type of getState()
.public static Type getStateType(ServerConnector connector)
public ServerConnector getParent()
ServerConnector
getParent
in interface ServerConnector
getParent
in interface Connector
ServerConnector.setParent(ServerConnector)
.public void setParent(ServerConnector parent)
ServerConnector
Note that calling this method does not fire a
ConnectorHierarchyChangeEvent
. The event is fired only when the
whole hierarchy has been updated.
setParent
in interface ServerConnector
parent
- The new parent of the connectorpublic List<ServerConnector> getChildren()
ServerConnector
Note that the method HasComponentsConnector.getChildComponents()
can be used to obtain the subset of child connectors that correspond to
components and not extensions.
getChildren
in interface ServerConnector
public void setChildren(List<ServerConnector> children)
ServerConnector
Note that this method is separate from
HasComponentsConnector.setChildComponents(List)
and takes both
extensions and child components. Both methods are called separately by
the framework if the connector can have child components.
setChildren
in interface ServerConnector
children
- The new child connectors (extensions and/or components)public boolean isEnabled()
ServerConnector
isEnabled
in interface ServerConnector
public void updateEnabledState(boolean enabledState)
updateEnabledState
in interface ServerConnector
public String getResourceUrl(String key)
com.vaadin.terminal.AbstractClientConnector#setResource(String, com.vaadin.terminal.Resource)
with the same key. null
is returned if no corresponding
resource is found.key
- a string identifying the resource.null
if no
corresponding resource is found.public boolean hasEventListener(String eventIdentifier)
ServerConnector
hasEventListener
in interface ServerConnector
eventIdentifier
- The identifier for the eventpublic void forceStateChange()
Copyright © 2019 Vaadin Ltd. All rights reserved.