Package com.vaadin.copilot
Class SpringBridge
java.lang.Object
com.vaadin.copilot.SpringBridge
Acts as a bridge between Copilot and Spring specific API. Can be imported
into copilot and must never itself import Spring classes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final recordstatic final record -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?> getApplicationClass(com.vaadin.flow.server.VaadinServletContext context) Returns the Spring Boot application class of the given context.static StringgetApplicationClassName(com.vaadin.flow.server.VaadinServletContext context) Returns the Spring Boot application class name of the given context.static List<SpringBridge.ServiceMethodInfo> getEndpoints(com.vaadin.flow.server.VaadinServletContext context) Gets a list of all endpoints / browser callables in the application.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.static Optional<SpringBridge.H2Info> getH2Info(com.vaadin.flow.server.VaadinServletContext context) Gets information about a H2 database.getJpaEntityClasses(com.vaadin.flow.server.VaadinServletContext context) Lists the JPA entities in the projectstatic StringgetPropertyValue(com.vaadin.flow.server.VaadinServletContext context, String property) Returns the value of the given property from the Spring environment of the given context.static StringgetUrlPrefix(com.vaadin.flow.server.VaadinServletContext context) Gets the prefix used for all route paths in the applicationstatic SpringBridge.VersionInfoGets version information for Spring Boot and related libraries.static booleanisSpringAvailable(com.vaadin.flow.server.VaadinServletContext context) Returns whether Spring is available in the classpath and enabled for the given context.static booleanisSpringDataJpaAvailable(com.vaadin.flow.server.VaadinServletContext context) Returns whether Spring Data JPA is available in the classpath.static booleanReturns whether Spring is available in the classpath.static booleanisSpringSecurityEnabled(com.vaadin.flow.server.VaadinServletContext context) Checks whether Spring Security is enabled.static booleanisViewSecurityEnabled(com.vaadin.flow.server.VaadinServletContext context) Returns whether Spring Security is enabled in the given context.static voidsetActiveSpringSecurityUser(String username, com.vaadin.flow.server.VaadinSession session) Set active user for Spring Security.
-
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 contextproperty- the property name- Returns:
- the property value or null if not found
-
getApplicationClass
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
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
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
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 usernamesession- 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
-