All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.server.ConnectorIdGenerator Maven / Gradle / Ivy

There is a newer version: 8.27.3
Show newest version
/*
 * 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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy