Class SpringBridge

java.lang.Object
com.vaadin.copilot.SpringBridge

public class SpringBridge extends Object
Acts as a bridge between Copilot and Spring specific API. Can be imported into copilot and must never itself import Spring classes.
  • Constructor Details

    • SpringBridge

      public SpringBridge()
  • Method Details

    • isSpringAvailable

      public static boolean isSpringAvailable(com.vaadin.flow.server.VaadinServletContext context)
      Returns whether Spring is available in the classpath and enabled for the given context.
      Parameters:
      context - the Vaadin context
      Returns:
      true if Spring is available and enabled, false otherwise
    • isSpringSecurityAvailable

      public static boolean isSpringSecurityAvailable()
      Returns whether Spring is available in the classpath.
      Returns:
      true if Spring is available, false otherwise
    • isSpringDataJpaAvailable

      public static boolean isSpringDataJpaAvailable(com.vaadin.flow.server.VaadinServletContext context)
      Returns whether Spring Data JPA is available in the classpath.
      Returns:
      true if Spring Data JPA is available, false otherwise
    • getPropertyValue

      public static String getPropertyValue(com.vaadin.flow.server.VaadinServletContext context, String property)
      Returns the value of the given property from the Spring environment of the given context.
      Parameters:
      context - the Vaadin servlet context
      property - the property name
      Returns:
      the property value or null if not found
    • getApplicationClass

      public static Class<?> getApplicationClass(com.vaadin.flow.server.VaadinServletContext context)
      Returns the Spring Boot application class of the given context.
      Parameters:
      context - the Vaadin servlet context
      Returns:
      the Spring Boot application class or null if not found
    • getApplicationClassName

      public static String getApplicationClassName(com.vaadin.flow.server.VaadinServletContext context)
      Returns the Spring Boot application class name of the given context.

      Mostly exists for tests where the class instance does not exist.

      Parameters:
      context - the Vaadin servlet context
      Returns:
      the Spring Boot application class or null if not found
    • isViewSecurityEnabled

      public static boolean isViewSecurityEnabled(com.vaadin.flow.server.VaadinServletContext context)
      Returns whether Spring Security is enabled in the given context.
      Parameters:
      context - the Vaadin servlet context
      Returns:
      true if Spring Security is enabled, false otherwise
    • getUrlPrefix

      public static String getUrlPrefix(com.vaadin.flow.server.VaadinServletContext context)
      Gets the prefix used for all route paths in the application
      Parameters:
      context - the Vaadin servlet context
      Returns:
      the prefix used for all route paths in the application, never ending in a "/" or an empty string if no prefix is used
    • getEndpoints

      public static List<SpringBridge.ServiceMethodInfo> getEndpoints(com.vaadin.flow.server.VaadinServletContext context)
      Gets a list of all endpoints / browser callables in the application.
      Returns:
      a list of endpoint info objects
    • getFlowUIServices

      public static List<SpringBridge.ServiceMethodInfo> getFlowUIServices(com.vaadin.flow.server.VaadinServletContext context)
      Gets a list of @Service classes that can potentially be used to get data to a component.
      Returns:
      a list service classes
    • getVersionInfo

      public static SpringBridge.VersionInfo getVersionInfo()
      Gets version information for Spring Boot and related libraries.
      Returns:
      version information
    • isSpringSecurityEnabled

      public static boolean isSpringSecurityEnabled(com.vaadin.flow.server.VaadinServletContext context)
      Checks whether Spring Security is enabled.
      Parameters:
      context - the Vaadin servlet context
      Returns:
      true if Spring Security is enabled, false otherwise
    • setActiveSpringSecurityUser

      public static void setActiveSpringSecurityUser(String username, com.vaadin.flow.server.VaadinSession session)
      Set active user for Spring Security.
      Parameters:
      username - the username
      session - the Vaadin session
    • getJpaEntityClasses

      public static List<Class<?>> getJpaEntityClasses(com.vaadin.flow.server.VaadinServletContext context)
      Lists the JPA entities in the project
      Parameters:
      context - the Vaadin context
      Returns:
      a list of JPA entity classes in the project
    • getH2Info

      public static Optional<SpringBridge.H2Info> getH2Info(com.vaadin.flow.server.VaadinServletContext context)
      Gets information about a H2 database.
      Parameters:
      context - the Vaadin context
      Returns:
      an optional H2Info object containing information about the H2 database, or empty if no H2 database is in use