public abstract class AbstractClientConnector extends Object implements ClientConnector, MethodEventSource
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener| Constructor and Description |
|---|
AbstractClientConnector() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttachListener(ClientConnector.AttachListener listener) |
void |
addDetachListener(ClientConnector.DetachListener listener) |
protected void |
addExtension(Extension extension)
Add an extension to this connector.
|
void |
addListener(Class<?> eventType,
Object target,
Method method)
Registers a new listener with the specified activation method to listen
events generated by this component.
|
void |
addListener(Class<?> eventType,
Object target,
String methodName)
Deprecated.
As of 7.0. This method should be avoided. Use
addListener(Class, Object, Method) or
addListener(String, Class, Object, Method) instead. |
protected void |
addListener(String eventIdentifier,
Class<?> eventType,
Object target,
Method method)
Registers a new listener with the specified activation method to listen
events generated by this component.
|
protected void |
addMethodInvocationToQueue(String interfaceName,
Method method,
Object[] parameters)
For internal use: adds a method invocation to the pending RPC call queue.
|
void |
attach()
Notifies the connector that it is connected to a VaadinSession (and
therefore also to a UI).
|
void |
beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the
client.
|
protected SharedState |
createState()
Creates the shared state bean to be used in server to client
communication.
|
void |
detach()
Notifies the connector that it is detached from its VaadinSession.
|
elemental.json.JsonObject |
encodeState()
Called by the framework to encode the state to a JSONObject.
|
boolean |
equals(Object obj) |
protected void |
fireEvent(EventObject event)
Sends the event to all listeners.
|
static Iterable<? extends ClientConnector> |
getAllChildrenIterable(ClientConnector connector)
Get an Iterable for iterating over all child connectors, including both
extensions and child components.
|
String |
getConnectorId() |
ErrorHandler |
getErrorHandler()
Gets the error handler for the connector.
|
Collection<Extension> |
getExtensions()
Get a read-only collection of all extensions attached to this connector.
|
Collection<?> |
getListeners(Class<?> eventType)
Returns all listeners that are registered for the given event type or one
of its subclasses.
|
protected Resource |
getResource(String key)
Gets a resource defined using
setResource(String, Resource) with
the corresponding key. |
ServerRpcManager<?> |
getRpcManager(String rpcInterfaceName)
Returns the RPC manager instance to use when receiving calls for an RPC
interface.
|
protected <T extends ClientRpc> |
getRpcProxy(Class<T> rpcInterface)
Returns an RPC proxy for a given server to client RPC interface for this
component.
|
protected VaadinSession |
getSession()
Finds the
VaadinSession to which this connector belongs. |
protected SharedState |
getState()
Returns the shared state for this connector.
|
protected SharedState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
Class<? extends SharedState> |
getStateType()
Returns the type of the shared state for this connector
|
UI |
getUI()
Finds a UI ancestor of this connector.
|
boolean |
handleConnectorRequest(VaadinRequest request,
VaadinResponse response,
String path)
Handle a request directed to this connector.
|
int |
hashCode() |
protected boolean |
hasListeners(Class<?> eventType)
Checks if the given
Component.Event type is listened for this component. |
boolean |
isAttached()
Checks if the connector is attached to a VaadinSession.
|
boolean |
isConnectorEnabled()
Checks if the communicator is enabled.
|
protected boolean |
isThis(Object that)
Deprecated.
only defined for framework hacks, do not use.
|
void |
markAsDirty()
Marks that this connector's state might have changed.
|
void |
markAsDirtyRecursive()
Causes this connector and all connectors below it to be marked as dirty.
|
protected <T extends ServerRpc> |
registerRpc(T implementation)
Registers an RPC interface implementation for this component.
|
protected <T extends ServerRpc> |
registerRpc(T implementation,
Class<T> rpcInterfaceType)
Registers an RPC interface implementation for this component.
|
void |
removeAttachListener(ClientConnector.AttachListener listener) |
void |
removeDetachListener(ClientConnector.DetachListener listener) |
void |
removeExtension(Extension extension)
Remove an extension from this connector.
|
void |
removeListener(Class<?> eventType,
Object target)
Removes all registered listeners matching the given parameters.
|
void |
removeListener(Class<?> eventType,
Object target,
Method method)
Removes one registered listener method.
|
void |
removeListener(Class<?> eventType,
Object target,
String methodName)
Deprecated.
As of 7.0. This method should be avoided. Use
removeListener(Class, Object, Method) instead. |
protected void |
removeListener(String eventIdentifier,
Class<?> eventType,
Object target)
Removes all registered listeners matching the given parameters.
|
void |
requestRepaint()
Deprecated.
As of 7.0, use
markAsDirty() instead. Note that you
typically do not need to call markAsDirty() as
getState() will mark the connector dirty and the
framework will then check what, if anything, needs to be sent
to the client. LegacyComponents which rely on paint
might still need to call this or markAsDirty() . |
void |
requestRepaintAll()
Deprecated.
As of 7.0, use
markAsDirtyRecursive() instead |
List<ClientMethodInvocation> |
retrievePendingRpcCalls()
Returns the list of pending server to client RPC calls and clears the
list.
|
void |
setErrorHandler(ErrorHandler errorHandler)
Sets the error handler for the connector.
|
protected void |
setResource(String key,
Resource resource)
Registers a resource with this connector using the given key.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetParentpublic void addAttachListener(ClientConnector.AttachListener listener)
addAttachListener in interface ClientConnectorpublic void removeAttachListener(ClientConnector.AttachListener listener)
removeAttachListener in interface ClientConnectorpublic void addDetachListener(ClientConnector.DetachListener listener)
addDetachListener in interface ClientConnectorpublic void removeDetachListener(ClientConnector.DetachListener listener)
removeDetachListener in interface ClientConnector@Deprecated public void requestRepaint()
markAsDirty() instead. Note that you
typically do not need to call markAsDirty() as
getState() will mark the connector dirty and the
framework will then check what, if anything, needs to be sent
to the client. LegacyComponents which rely on paint
might still need to call this or markAsDirty() .requestRepaint in interface ClientConnectorpublic void markAsDirty()
ClientConnectorClientConnector.beforeClientResponse(boolean) followed by ClientConnector.encodeState()
for all connectors that are marked as dirty and send any updated state
info to the client.markAsDirty in interface ClientConnectorprotected <T extends ServerRpc> void registerRpc(T implementation, Class<T> rpcInterfaceType)
implementation - RPC interface implementationrpcInterfaceType - RPC interface class for which the implementation should be
registeredprotected <T extends ServerRpc> void registerRpc(T implementation)
implementation - RPC interface implementation. Also used to deduce the type.protected SharedState getState()
As a side effect, marks the connector dirty so any changes done to the
state will be sent to the client. Use getState(false) to avoid
marking the connector as dirty.
protected SharedState getState(boolean markAsDirty)
markAsDirty - true if the connector should automatically be marked dirty,
false otherwisegetState()public elemental.json.JsonObject encodeState()
ClientConnectorLegacyCommunicationManager.encodeState(ClientConnector, SharedState)
.encodeState in interface ClientConnectorprotected SharedState createState()
By default a state object of the defined return type of
getState() is created. Subclasses can override this method and
return a new instance of the correct state class but this should rarely
be necessary.
No configuration of the values of the state should be performed in
createState().
public Class<? extends SharedState> getStateType()
ClientConnectorgetStateType in interface ClientConnectorprotected <T extends ClientRpc> T getRpcProxy(Class<T> rpcInterface)
rpcInterface - RPC interface typeprotected void addMethodInvocationToQueue(String interfaceName, Method method, Object[] parameters)
interfaceName - RPC interface namemethod - RPC methodparameters - RPC all parameterspublic ServerRpcManager<?> getRpcManager(String rpcInterfaceName)
ClientConnectorgetRpcManager in interface ClientConnectorrpcInterfaceName - name of the interface for which the call was madepublic List<ClientMethodInvocation> retrievePendingRpcCalls()
ClientConnectorretrievePendingRpcCalls in interface ClientConnectorpublic String getConnectorId()
getConnectorId in interface Connectorprotected VaadinSession getSession()
VaadinSession to which this connector belongs. If the
connector has not been attached, null is returned.null if not attachedpublic UI getUI()
null is returned if
no UI ancestor is found (typically because the connector is not attached
to a proper hierarchy).getUI in interface ClientConnectornull if none
is found.@Deprecated public void requestRepaintAll()
markAsDirtyRecursive() insteadrequestRepaintAll in interface ClientConnectorpublic void markAsDirtyRecursive()
ClientConnectorThis should only be used in special cases, e.g when the state of a descendant depends on the state of an ancestor.
markAsDirtyRecursive in interface ClientConnectorClientConnector.markAsDirty()public static Iterable<? extends ClientConnector> getAllChildrenIterable(ClientConnector connector)
connector - the connector to get children forpublic Collection<Extension> getExtensions()
ClientConnectorgetExtensions in interface ClientConnectorprotected void addExtension(Extension extension)
extension - the extension to addpublic void removeExtension(Extension extension)
ClientConnectorremoveExtension in interface ClientConnectorextension - the extension to remove.public boolean isAttached()
ClientConnectorisAttached in interface ClientConnectorpublic void attach()
ClientConnector
The caller of this method is #setParent(ClientConnector) if the
parent is itself already attached to the session. If not, the parent will
call the ClientConnector.attach() for all its children when it is attached to
the session. This method is always called before the connector's data is
sent to the client-side for the first time.
The attachment logic is implemented in AbstractClientConnector.
attach in interface ClientConnectorpublic void detach()
The caller of this method is #setParent(ClientConnector) if the
parent is in the session. When the parent is detached from the session it
is its responsibility to call ClientConnector.detach() for each of its children.
The getSession() and getUI() methods might return
null after this method is called.
detach in interface ClientConnectorpublic boolean isConnectorEnabled()
ClientConnectorisConnectorEnabled in interface ClientConnectorpublic void beforeClientResponse(boolean initial)
ClientConnectorbeforeClientResponse in interface ClientConnectorinitial - true if the client-side connector will be created
and initialized after this method has been invoked.
false if there is already an initialized
client-side connector.public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException
ClientConnectorConnectorResources.
Requests to /APP/connector/[ui id]/[connector id]/ are
routed to this method with the remaining part of the requested path
available in the path parameter.
NOTE that the session is not locked when this method is called. It is the responsibility of the connector to ensure that the session is locked while handling state or other session related data. For best performance the session should be unlocked before writing a large response to the client.
handleConnectorRequest in interface ClientConnectorrequest - the request that should be handledresponse - the response object to which the response should be writtenpath - the requested relative pathtrue if the request has been handled,
false if no response has been written.IOException - if there is a problem generating a response.protected Resource getResource(String key)
setResource(String, Resource) with
the corresponding key.key - the string identifier of the resourcenull if there's no resource
associated with the given keysetResource(String, Resource)protected void setResource(String key, Resource resource)
com.vaadin.terminal.gwt.client.ui.AbstractConnector#getResourceUrl(String)
with the same key.key - the string key to associate the resource withresource - the resource to set, or null to clear a previous
association.protected void addListener(String eventIdentifier, Class<?> eventType, Object target, Method method)
Registers a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.
This method additionally informs the event-api to route events with the given eventIdentifier to the components handleEvent function call.
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
eventIdentifier - the identifier of the event to listen foreventType - the type of the listened event. Events of this type or its
subclasses activate the listener.target - the object instance who owns the activation method.method - the activation method.protected boolean hasListeners(Class<?> eventType)
Component.Event type is listened for this component.eventType - the event type to be checkedprotected void removeListener(String eventIdentifier, Class<?> eventType, Object target)
object's methods that are
registered to listen to events of type eventType generated
by this component.
This method additionally informs the event-api to stop routing events with the given eventIdentifier to the components handleEvent function call.
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
eventIdentifier - the identifier of the event to stop listening foreventType - the exact event type the object listens to.target - the target object that has registered to listen to events of
type eventType with one or more methods.public void addListener(Class<?> eventType, Object target, Method method)
Registers a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
addListener in interface MethodEventSourceeventType - the type of the listened event. Events of this type or its
subclasses activate the listener.target - the object instance who owns the activation method.method - the activation method.@Deprecated public void addListener(Class<?> eventType, Object target, String methodName)
addListener(Class, Object, Method) or
addListener(String, Class, Object, Method) instead.Convenience method for registering a new listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.
This version of addListener gets the name of the activation
method as a parameter. The actual method is reflected from
object, and unless exactly one match is found,
java.lang.IllegalArgumentException is thrown.
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
Note: Using this method is discouraged because it cannot be checked
during compilation. Use addListener(Class, Object, Method) or
#addListener(com.vaadin.ui.Component.Listener) instead.
addListener in interface MethodEventSourceeventType - the type of the listened event. Events of this type or its
subclasses activate the listener.target - the object instance who owns the activation method.methodName - the name of the activation method.public void removeListener(Class<?> eventType, Object target)
object's methods that are
registered to listen to events of type eventType generated
by this component.
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
removeListener in interface MethodEventSourceeventType - the exact event type the object listens to.target - the target object that has registered to listen to events of
type eventType with one or more methods.public void removeListener(Class<?> eventType, Object target, Method method)
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
removeListener in interface MethodEventSourceeventType - the exact event type the object listens to.target - target object that has registered to listen to events of type
eventType with one or more methods.method - the method owned by target that's registered to
listen to events of type eventType.@Deprecated public void removeListener(Class<?> eventType, Object target, String methodName)
removeListener(Class, Object, Method) instead.Removes one registered listener method. The given method owned by the given object will no longer be called when the specified events are generated by this component.
This version of removeListener gets the name of the
activation method as a parameter. The actual method is reflected from
target, and unless exactly one match is found,
java.lang.IllegalArgumentException is thrown.
For more information on the inheritable event mechanism see the
com.vaadin.event package documentation.
removeListener in interface MethodEventSourceeventType - the exact event type the object listens to.target - the target object that has registered to listen to events of
type eventType with one or more methods.methodName - the name of the method owned by target that's
registered to listen to events of type eventType.public Collection<?> getListeners(Class<?> eventType)
eventType - The type of event to return listeners for.protected void fireEvent(EventObject event)
event - the Event to be sent to all listeners.public ErrorHandler getErrorHandler()
ClientConnectorgetErrorHandler in interface ClientConnectorpublic void setErrorHandler(ErrorHandler errorHandler)
ClientConnectorsetErrorHandler in interface ClientConnectorerrorHandler - The error handler for this connector@Deprecated protected boolean isThis(Object that)
This method must be protected, because otherwise it will not be redefined by the proxy to actually be called on the underlying instance.
See #14639
Copyright © 2017 Vaadin Ltd. All rights reserved.