com.vaadin.server.ConnectorIdGenerator Maven / Gradle / Ivy
/*
* Copyright (C) 2000-2024 Vaadin Ltd
*
* This program is available under Vaadin Commercial License and Service Terms.
*
* See for the full
* license.
*/
package com.vaadin.server;
import java.io.Serializable;
/**
* Callback for generating the id for new connectors. A generator can be
* registered to be used with an application by overriding
* {@link VaadinService#initConnectorIdGenerator(java.util.List)} or by calling
* {@link ServiceInitEvent#addConnectorIdGenerator(ConnectorIdGenerator)} from a
* {@link VaadinServiceInitListener}.
*
* @author Vaadin Ltd
* @since 8.1
*/
@FunctionalInterface
public interface ConnectorIdGenerator extends Serializable {
/**
* Generates a connector id for a connector.
*
* @param event
* the event object that has a reference to the connector and the
* session, not null
* @return the connector id to use for the connector, not null
*/
public String generateConnectorId(ConnectorIdGenerationEvent event);
/**
* Generates a connector id using the default logic by using
* {@link VaadinSession#getNextConnectorId()}.
*
* @param event
* the event object that has a reference to the connector and the
* session, not null
* @return the connector id to use for the connector, not null
*/
public static String generateDefaultConnectorId(
ConnectorIdGenerationEvent event) {
assert event != null;
return event.getSession().getNextConnectorId();
}
}