1616import javax .servlet .http .HttpServletRequest ;
1717import javax .servlet .http .HttpServletResponse ;
1818
19- import com .vaadin .pro .licensechecker .BuildType ;
20- import com .vaadin .pro .licensechecker .LicenseChecker ;
2119import org .slf4j .Logger ;
2220import org .slf4j .LoggerFactory ;
2321
4038import com .vaadin .flow .server .HandlerHelper .RequestType ;
4139import com .vaadin .flow .server .startup .ApplicationConfiguration ;
4240import com .vaadin .flow .shared .JsonConstants ;
41+ import com .vaadin .pro .licensechecker .BuildType ;
42+ import com .vaadin .pro .licensechecker .LicenseChecker ;
43+ import com .vaadin .pro .licensechecker .LicenseException ;
4344
4445/**
4546 * The main servlet, which handles all incoming requests to the application.
@@ -59,6 +60,8 @@ public class VaadinServlet extends HttpServlet {
5960
6061 public static final String INTERNAL_VAADIN_SERVLET_VITE_DEV_MODE_FRONTEND_PATH = "VAADIN_SERVLET_VITE_DEV_MODE_FRONTEND_PATH" ;
6162
63+ private static final String PROJECT_NAME = "flow" ;
64+
6265 private VaadinServletService servletService ;
6366 private StaticFileHandler staticFileHandler ;
6467
@@ -123,7 +126,8 @@ public void init(ServletConfig servletConfig) throws ServletException {
123126
124127 try {
125128 servletService = createServletService ();
126- validateLicense (servletService .getDeploymentConfiguration ());
129+ verifyLicense (servletService .getDeploymentConfiguration ()
130+ .isProductionMode ());
127131 } catch (ServiceException e ) {
128132 throw new ServletException ("Could not initialize VaadinServlet" ,
129133 e );
@@ -142,6 +146,25 @@ public void init(ServletConfig servletConfig) throws ServletException {
142146 }
143147 }
144148
149+ private void verifyLicense (boolean productionMode ) {
150+ String frameworkVersion = Version .getFullVersion ();
151+ if (productionMode ) {
152+ try {
153+ LicenseChecker .checkLicense (PROJECT_NAME , frameworkVersion ,
154+ BuildType .PRODUCTION , null );
155+ } catch (LicenseException e ) {
156+ getLogger ().error (
157+ "This Vaadin version requires an extended maintenance subscription."
158+ + "Provide either a server key or an online license checking key,"
159+ + "which you can get from: https://vaadin.com/myaccount/licenses#latest." ,
160+ e );
161+ }
162+ } else {
163+ LicenseChecker .checkLicense (PROJECT_NAME , frameworkVersion ,
164+ BuildType .DEVELOPMENT );
165+ }
166+ }
167+
145168 private void detectFrontendMapping () {
146169 synchronized (VaadinServlet .class ) {
147170 if (frontendMapping != null ) {
@@ -622,13 +645,4 @@ private VaadinServletContext initializeContext() {
622645 public static String getFrontendMapping () {
623646 return frontendMapping ;
624647 }
625-
626- private void validateLicense (
627- DeploymentConfiguration deploymentConfiguration ) {
628- // Check the license at runtime if in development mode
629- if (!deploymentConfiguration .isProductionMode ()) {
630- LicenseChecker .checkLicense ("flow" , Version .getFullVersion (),
631- BuildType .DEVELOPMENT );
632- }
633- }
634648}
0 commit comments