Skip to content

Commit

Permalink
Determine init parameters by reflection over com.vaadin.flow.server.I…
Browse files Browse the repository at this point in the history
…nitParameters (#627) (#630)

* Determine init parameters by reflection over com.vaadin.flow.server.InitParameters (#627)
  • Loading branch information
Johannes Eriksson authored Jun 1, 2020
1 parent b43c1ae commit bc3f629
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 168 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<maven.compiler.target>1.8</maven.compiler.target>

<!-- These are typically overridden with BOMs -->
<vaadin.flow.version>2.2-SNAPSHOT</vaadin.flow.version>
<vaadin.flow.version>2.3-SNAPSHOT</vaadin.flow.version>
<spring-boot.version>2.2.0.RELEASE</spring-boot.version>

<!-- Additional manifest fields -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.mvc.ServletForwardingController;

import com.vaadin.flow.function.DeploymentConfiguration;
import com.vaadin.flow.server.Constants;
import com.vaadin.flow.server.InitParameters;
import com.vaadin.flow.server.ServiceException;
import com.vaadin.flow.server.VaadinServlet;
import com.vaadin.flow.server.VaadinServletService;
import com.vaadin.flow.server.VaadinSession;

/**
* Spring application context aware Vaadin servlet implementation.
Expand All @@ -54,35 +54,22 @@ public class SpringServlet extends VaadinServlet {
/**
* Property names that are read from the application.properties file
*/
protected static final List<String> PROPERTY_NAMES = Arrays.asList(
Constants.SERVLET_PARAMETER_PRODUCTION_MODE,
Constants.SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION,
Constants.SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS,
Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL,
Constants.SERVLET_PARAMETER_SEND_URLS_AS_PARAMETERS,
Constants.SERVLET_PARAMETER_PUSH_MODE,
Constants.SERVLET_PARAMETER_PUSH_URL,
Constants.SERVLET_PARAMETER_SYNC_ID_CHECK,
Constants.SERVLET_PARAMETER_PUSH_SUSPEND_TIMEOUT_LONGPOLLING,
Constants.SERVLET_PARAMETER_REQUEST_TIMING,
Constants.SERVLET_PARAMETER_COMPATIBILITY_MODE,
Constants.SERVLET_PARAMETER_DEVMODE_WEBPACK_ERROR_PATTERN,
Constants.SERVLET_PARAMETER_DEVMODE_WEBPACK_OPTIONS,
Constants.SERVLET_PARAMETER_DEVMODE_WEBPACK_SUCCESS_PATTERN,
Constants.SERVLET_PARAMETER_DEVMODE_WEBPACK_TIMEOUT,
Constants.SERVLET_PARAMETER_ENABLE_DEV_SERVER,
Constants.SERVLET_PARAMETER_JSBUNDLE,
Constants.SERVLET_PARAMETER_POLYFILLS,
Constants.SERVLET_PARAMETER_STATISTICS_JSON,
Constants.SERVLET_PARAMETER_ENABLE_PNPM,
Constants.DISABLE_WEBJARS, Constants.SERVLET_PARAMETER_BROTLI,
Constants.LOAD_ES5_ADAPTERS,
Constants.USE_ORIGINAL_FRONTEND_RESOURCES,
Constants.FRONTEND_URL_ES5, Constants.FRONTEND_URL_ES6,
Constants.I18N_PROVIDER,
Constants.DISABLE_AUTOMATIC_SERVLET_REGISTRATION,
"devmode.liveReload.enabled",
VaadinSession.UI_PARAMETER);

protected static final List<String> PROPERTY_NAMES = Arrays
.stream(InitParameters.class.getDeclaredFields())
// thanks to java code coverage which adds non-existent
// initially variables everywhere: we should skip this extra
// field
.filter(field -> !field.isSynthetic())
.map(field -> {
try {
return (String) field.get(null);
} catch (IllegalAccessException e) {
throw new IllegalStateException("unable to access field",
e);
}
})
.collect(Collectors.toList());

private final ApplicationContext context;
private final boolean forwardingEnforced;
Expand Down

This file was deleted.

0 comments on commit bc3f629

Please sign in to comment.