Skip to content

Commit

Permalink
refactor: extract common config functionality and introduce add config
Browse files Browse the repository at this point in the history
part of #9417
  • Loading branch information
Denis Anisimov committed Dec 16, 2020
1 parent fafc0f2 commit ec54511
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,6 @@ public interface DeploymentConfiguration
<T> T getApplicationOrSystemProperty(String propertyName, T defaultValue,
Function<String, T> converter);

/**
* A shorthand of
* {@link DeploymentConfiguration#getApplicationOrSystemProperty(String, Object, Function)}
* for {@link String} type.
*
* @param propertyName
* The simple of the property, in some contexts, lookup might be
* performed using variations of the provided name.
* @param defaultValue
* the default value that should be used if no value has been
* defined
* @return the property value, or the passed default value if no property
* value is found
*/
@Override
default String getStringProperty(String propertyName, String defaultValue) {
return getApplicationOrSystemProperty(propertyName, defaultValue,
Function.identity());
}

/**
* A shorthand of
* {@link DeploymentConfiguration#getApplicationOrSystemProperty(String, Object, Function)}
Expand Down Expand Up @@ -297,9 +277,22 @@ default List<String> getPolyfills() {
}

/**
* Get if the dev server should be reused on each reload. True by default,
* set it to false in tests so as dev server is not kept as a daemon after
* the test.
* <<<<<<< Upstream, based on master ======= Get if the dev server should be
* enabled. True by default
*
* @return true if dev server should be used
*/
@Override
default boolean enableDevServer() {
return getBooleanProperty(
InitParameters.SERVLET_PARAMETER_ENABLE_DEV_SERVER, true);
}

/**
* >>>>>>> 01eb234 refactor: extract common config functionality and
* introduce add config Get if the dev server should be reused on each
* reload. True by default, set it to false in tests so as dev server is not
* kept as a daemon after the test.
*
* @return true if dev server should be reused
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Properties;

import com.vaadin.flow.function.DeploymentConfiguration;
import com.vaadin.flow.server.startup.ApplicationConfiguration;
import com.vaadin.flow.shared.communication.PushMode;

import static com.vaadin.flow.server.InitParameters.SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS;
Expand All @@ -47,16 +48,19 @@ public class PropertyDeploymentConfiguration

/**
* Create a new property deployment configuration instance.
*
*
* @param parentConfig
* a parent application configuration
* @param systemPropertyBaseClass
* the class that should be used as a basis when reading system
* properties
* @param initParameters
* the init parameters that should make up the foundation for
* this configuration
*/
public PropertyDeploymentConfiguration(Class<?> systemPropertyBaseClass,
Properties initParameters) {
public PropertyDeploymentConfiguration(
ApplicationConfiguration parentConfig,
Class<?> systemPropertyBaseClass, Properties initParameters) {
super(filterStringProperties(initParameters));
initialParameters = initParameters;
this.systemPropertyBaseClass = systemPropertyBaseClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class AbstractConfigurationFactory implements Serializable {
* the token file data
* @return the config parameters
*/
public Map<String, String> getConfigParametersUsingTokenData(
protected Map<String, String> getConfigParametersUsingTokenData(
JsonObject buildInfo) {
Map<String, String> params = new HashMap<>();
if (buildInfo.hasKey(SERVLET_PARAMETER_PRODUCTION_MODE)) {
Expand Down Expand Up @@ -151,16 +151,6 @@ public Map<String, String> getConfigParametersUsingTokenData(
return params;
}

/**
* Sets to the dev mode properties to the configuration parameters.
*
* @see #getConfigParametersUsingTokenData(JsonObject)
*
* @param params
* the configuration parameters to set dev mode properties to
* @param buildInfo
* the token file data
*/
protected void setDevModePropertiesUsingTokenData(
Map<String, String> params, JsonObject buildInfo) {
// read dev mode properties from the token and set init parameter only
Expand Down

0 comments on commit ec54511

Please sign in to comment.