Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Issue 351 In Liberty, BoosterConfigurator with wrong version leads to… #406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

import org.microshed.boost.common.BoostException;
import org.microshed.boost.common.BoostLoggerI;

/**
* Interface to describe common function across all technology Booster Pack
Expand Down Expand Up @@ -62,6 +63,7 @@ public abstract class AbstractBoosterConfig {
public static final String MP_RESTCLIENT_VERSION_11 = "1.1" + boostVersion + emptyString;
public static final String MP_RESTCLIENT_VERSION_12 = "1.2" + boostVersion + emptyString;
public static final String MP_RESTCLIENT_VERSION_13 = "1.3" + boostVersion + emptyString;
protected BoostLoggerI logger;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
Expand All @@ -81,8 +83,10 @@ public static String getCoordinates(Class<?> klass) throws BoostException {

private final String version;

protected AbstractBoosterConfig(String version) {
protected AbstractBoosterConfig(String version, BoostLoggerI logger) {
this.version = version;
this.logger = logger;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class BeanValidationBoosterConfig extends AbstractBoosterConfig {

public BeanValidationBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(BeanValidationBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(BeanValidationBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class CDIBoosterConfig extends AbstractBoosterConfig {

public CDIBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(CDIBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(CDIBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class JAXRSBoosterConfig extends AbstractBoosterConfig {

public JAXRSBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(JAXRSBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(JAXRSBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class JDBCBoosterConfig extends AbstractBoosterConfig {
private Map<String, String> driverInfo;

public JDBCBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(JDBCBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(JDBCBoosterConfig.class)), logger);

this.logger = logger;

Expand Down Expand Up @@ -122,11 +122,13 @@ public Properties getDatasourceProperties() {

// Verify correct property configuration
if (dependency.contains(DERBY_GROUP_ID)) {
// If there's no DB name and there's no server name then we can create an embedded DB at a default location
if ((!datasourceProperties.containsKey(BoostProperties.DATASOURCE_DATABASE_NAME)) &&
(!datasourceProperties.containsKey(BoostProperties.DATASOURCE_SERVER_NAME))) {
// If there's no DB name and there's no server name then we can create an
// embedded DB at a default location
if ((!datasourceProperties.containsKey(BoostProperties.DATASOURCE_DATABASE_NAME))
&& (!datasourceProperties.containsKey(BoostProperties.DATASOURCE_SERVER_NAME))) {
datasourceProperties.put(BoostProperties.DATASOURCE_DATABASE_NAME, DERBY_DB);
// Though we want to auto-create our default location DB, I guess if someone already specified a property will honor it
// Though we want to auto-create our default location DB, I guess if someone
// already specified a property will honor it
// even though not sure how useful that would be.
if (!datasourceProperties.containsKey(BoostProperties.DATASOURCE_CREATE_DATABASE)) {
datasourceProperties.put(BoostProperties.DATASOURCE_CREATE_DATABASE, "create");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class JPABoosterConfig extends AbstractBoosterConfig {

public JPABoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(JPABoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(JPABoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class JSONBBoosterConfig extends AbstractBoosterConfig {

public JSONBBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(JSONBBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(JSONBBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class JSONPBoosterConfig extends AbstractBoosterConfig {

public JSONPBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(JSONPBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(JSONPBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class MPConfigBoosterConfig extends AbstractBoosterConfig {

public MPConfigBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(MPConfigBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(MPConfigBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class MPFaultToleranceBoosterConfig extends AbstractBoosterConfig {

public MPFaultToleranceBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(MPFaultToleranceBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(MPFaultToleranceBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class MPHealthBoosterConfig extends AbstractBoosterConfig {

public MPHealthBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(MPHealthBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(MPHealthBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class MPJWTBoosterConfig extends AbstractBoosterConfig {

public MPJWTBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(MPJWTBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(MPJWTBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class MPMetricsBoosterConfig extends AbstractBoosterConfig {

public MPMetricsBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(MPMetricsBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(MPMetricsBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class MPOpenAPIBoosterConfig extends AbstractBoosterConfig {

public MPOpenAPIBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(MPOpenAPIBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(MPOpenAPIBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class MPOpenTracingBoosterConfig extends AbstractBoosterConfig {

public MPOpenTracingBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(MPOpenTracingBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(MPOpenTracingBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class MPRestClientBoosterConfig extends AbstractBoosterConfig {

public MPRestClientBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params.getProjectDependencies().get(getCoordinates(MPRestClientBoosterConfig.class)));
super(params.getProjectDependencies().get(getCoordinates(MPRestClientBoosterConfig.class)), logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.microshed.boost.common.boosters.JDBCBoosterConfig;
import org.microshed.boost.common.config.BoostProperties;
import org.microshed.boost.common.utils.BoostUtil;
import org.microshed.boost.common.BoostException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

Expand Down Expand Up @@ -118,29 +119,32 @@ private void generateVariablesXml() throws ParserConfigurationException {
* Add a Liberty feature to the server configuration
*
*/
public void addFeature(String featureName) {
if (!featuresAdded.contains(featureName)) {
Element feature = serverXml.createElement(FEATURE);
feature.appendChild(serverXml.createTextNode(featureName));
featureManager.appendChild(feature);
featuresAdded.add(featureName);
public void addFeature(String featureName) throws BoostException {
if (featureName != null) {
if (!featuresAdded.contains(featureName)) {
Element feature = serverXml.createElement(FEATURE);
feature.appendChild(serverXml.createTextNode(featureName));
featureManager.appendChild(feature);
featuresAdded.add(featureName);
}
} else {
throw new BoostException("Request to add feature failed");
}
}

/**
* Add a list of features to the server configuration
*
*/
public void addFeatures(List<String> features) {
public void addFeatures(List<String> features) throws BoostException {

for (String featureName : features) {
addFeature(featureName);
}
}

/**
* Write the server.xml and bootstrap.properties to the server config
* directory
* Write the server.xml and bootstrap.properties to the server config directory
*
* @throws TransformerException
* @throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@

public class LibertyBeanValidationBoosterConfig extends BeanValidationBoosterConfig implements LibertyBoosterI {

public LibertyBeanValidationBoosterConfig(BoosterConfigParams params, BoostLoggerI logger)
throws BoostException {
public LibertyBeanValidationBoosterConfig(BoosterConfigParams params, BoostLoggerI logger) throws BoostException {
super(params, logger);
}

public String getFeature() {
public String getFeature() throws BoostException {

String feature = null;
if (getVersion().startsWith(BEANVALIDATION_VERSION_20)) {
return BEANVALIDATION_20;
} else {
return null;
feature = BEANVALIDATION_20;
}
if (feature == null) {
String msg = "Invalid version " + getVersion() + " returned. Expected " + BEANVALIDATION_VERSION_20
+ "\n Unable to add Feature " + BEANVALIDATION_20 + " to the server configuration";
throw new BoostException(msg);
}
return feature;
}

public void addServerConfig(LibertyServerConfigGenerator libertyServerConfigGenerator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

public interface LibertyBoosterI {

public String getFeature();
public String getFeature() throws BoostException;

public void addServerConfig(LibertyServerConfigGenerator libertyServerConfigGenerator) throws BoostException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,23 @@ public LibertyCDIBoosterConfig(BoosterConfigParams params, BoostLoggerI logger)
super(params, logger);
}

public String getFeature() {
public String getFeature() throws BoostException {

String feature = null;
if (getVersion().startsWith(CDI_VERSION_20)) {
return CDI_20;
}
if (getVersion().startsWith(CDI_VERSION_12)) {
return CDI_12;
feature = CDI_20;
} else if (getVersion().startsWith(CDI_VERSION_12)) {
feature = CDI_12;
}
else {
return null;
if (feature == null) {
String msg = "Invalid version " + getVersion() + " returned. Expected " + CDI_VERSION_20 + " or "
+ CDI_VERSION_12 + "\n Unable to add " + CDI_20 + " or " + CDI_12 + " to the server configuration";
throw new BoostException(msg);
}
return feature;
}

public void addServerConfig(LibertyServerConfigGenerator libertyServerConfigGenerator) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ public LibertyJAXRSBoosterConfig(BoosterConfigParams params, BoostLoggerI logger
}

@Override
public String getFeature() {
public String getFeature() throws BoostException {

String feature = null;
if (getVersion().startsWith(JAXRS_VERSION_20)) {
return JAXRS_20;
feature = JAXRS_20;
} else if (getVersion().startsWith(JAXRS_VERSION_21)) {
return JAXRS_21;
feature = JAXRS_21;
}
if (feature == null) {
String msg = "Invalid version " + getVersion() + " returned. Expected " + JAXRS_VERSION_20 + " or "
+ JAXRS_VERSION_21;
throw new BoostException(msg);
}
return null;
return feature;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,22 @@ public LibertyJPABoosterConfig(BoosterConfigParams params, BoostLoggerI logger)
}

@Override
public String getFeature() {
public String getFeature() throws BoostException {

String feature = null;
if (getVersion().startsWith(JPA_VERSION_21)) {
return JPA_21;
feature = JPA_21;
} else if (getVersion().startsWith(JPA_VERSION_22)) {
return JPA_22;
feature = JPA_22;
}

if (feature == null) {
String msg = "Invalid version " + getVersion() + " returned. Expected " + JPA_VERSION_21 + " or "
+ JPA_VERSION_22 + ".\n Unable to add feature " + JPA_21 + " or " + JPA_22
+ " to the server configuration";
throw new BoostException(msg);
}
return null;
return feature;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ public LibertyJSONBBoosterConfig(BoosterConfigParams params, BoostLoggerI logger
}

@Override
public String getFeature() {
public String getFeature() throws BoostException {
String feature = null;
if (getVersion().startsWith(JSONB_VERSION_10)) {
return JSONB_10;
feature = JSONB_10;
}
return null;
if (feature == null) {
String msg = "Invalid version " + getVersion() + " returned. Expected " + JSONB_VERSION_10
+ ".\n Unable to add feature " + JSONB_10 + " to the server configuration";
throw new BoostException(msg);
}
return feature;
}

@Override
Expand Down
Loading