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

Commit c3288f6

Browse files
committed
wildfly runtime prototype
1 parent 8a9f981 commit c3288f6

50 files changed

Lines changed: 1654 additions & 276 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

boost-common/src/main/java/io/openliberty/boost/common/boosters/AbstractBoosterConfig.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
import java.lang.annotation.Retention;
1717
import java.lang.annotation.RetentionPolicy;
1818
import java.lang.annotation.Target;
19-
import java.util.Properties;
20-
21-
import org.w3c.dom.Document;
2219

2320
import io.openliberty.boost.common.BoostException;
2421

@@ -45,30 +42,12 @@ public static String getCoordindates(Class<?> klass) throws BoostException {
4542
return coordinates.value();
4643
}
4744

48-
protected static final String BOOSTERS_GROUP_ID = "io.openliberty.boosters";
45+
public static final String BOOSTERS_GROUP_ID = "io.openliberty.boosters";
4946
protected String EE_7_VERSION = "0.1-SNAPSHOT";
5047
protected String EE_8_VERSION = "0.2-SNAPSHOT";
5148
protected String MP_20_VERSION = "0.2-SNAPSHOT";
5249

53-
/**
54-
* Return the Liberty feature name
55-
*
56-
* @return
57-
*/
58-
public abstract String getFeature();
59-
60-
/**
61-
* Add the server.xml configuration for this booster
62-
*
63-
* @param doc
64-
*/
65-
public abstract void addServerConfig(Document doc);
66-
67-
/**
68-
* Return the properties required by this booster
69-
*/
70-
public abstract Properties getServerProperties();
71-
50+
7251
/**
7352
* Return the dependency that this booster requires
7453
*
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2018 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* IBM Corporation - initial API and implementation
10+
*******************************************************************************/
11+
12+
package io.openliberty.boost.common.boosters.liberty;
13+
14+
import java.util.Properties;
15+
16+
import org.w3c.dom.Document;
17+
18+
import io.openliberty.boost.common.boosters.AbstractBoosterConfig;
19+
20+
/**
21+
* Interface to describe common function across all technology Booster Pack
22+
* Config Objects
23+
*
24+
*/
25+
public abstract class AbstractBoosterLibertyConfig extends AbstractBoosterConfig {
26+
27+
/**
28+
* Return the Liberty feature name
29+
*
30+
* @return
31+
*/
32+
public abstract String getFeature();
33+
34+
/**
35+
* Add the server.xml configuration for this booster
36+
*
37+
* @param doc
38+
*/
39+
public abstract void addServerConfig(Document doc);
40+
41+
/**
42+
* Return the properties required by this booster
43+
*/
44+
public abstract Properties getServerProperties();
45+
46+
}

boost-common/src/main/java/io/openliberty/boost/common/boosters/CDIBoosterConfig.java renamed to boost-common/src/main/java/io/openliberty/boost/common/boosters/liberty/CDIBoosterLibertyConfig.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* Contributors:
99
* IBM Corporation - initial API and implementation
1010
*******************************************************************************/
11-
package io.openliberty.boost.common.boosters;
11+
package io.openliberty.boost.common.boosters.liberty;
1212

13-
import static io.openliberty.boost.common.config.ConfigConstants.CDI_20;
13+
import static io.openliberty.boost.common.config.LibertyConfigConstants.CDI_20;
1414

1515
import java.util.Map;
1616
import java.util.Properties;
@@ -21,14 +21,14 @@
2121
import io.openliberty.boost.common.BoostLoggerI;
2222
import io.openliberty.boost.common.boosters.AbstractBoosterConfig.BoosterCoordinates;
2323

24-
@BoosterCoordinates(AbstractBoosterConfig.BOOSTERS_GROUP_ID + ":cdi")
25-
public class CDIBoosterConfig extends AbstractBoosterConfig {
24+
@BoosterCoordinates(AbstractBoosterLibertyConfig.BOOSTERS_GROUP_ID + ":cdi")
25+
public class CDIBoosterLibertyConfig extends AbstractBoosterLibertyConfig {
2626

2727
String libertyFeature = null;
2828

29-
public CDIBoosterConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
29+
public CDIBoosterLibertyConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
3030
String version = dependencies.get(getCoordindates(this.getClass()));
31-
31+
3232
// if it is the 1.0 version = EE7 feature level
3333
if (version.equals(MP_20_VERSION)) {
3434
libertyFeature = CDI_20;

boost-common/src/main/java/io/openliberty/boost/common/boosters/JAXRSBoosterConfig.java renamed to boost-common/src/main/java/io/openliberty/boost/common/boosters/liberty/JAXRSBoosterLibertyConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
* Contributors:
99
* IBM Corporation - initial API and implementation
1010
*******************************************************************************/
11-
package io.openliberty.boost.common.boosters;
11+
package io.openliberty.boost.common.boosters.liberty;
1212

1313
import org.w3c.dom.Document;
1414

1515
import io.openliberty.boost.common.BoostException;
1616
import io.openliberty.boost.common.BoostLoggerI;
1717
import io.openliberty.boost.common.boosters.AbstractBoosterConfig.BoosterCoordinates;
1818

19-
import static io.openliberty.boost.common.config.ConfigConstants.*;
19+
import static io.openliberty.boost.common.config.LibertyConfigConstants.*;
2020

2121
import java.util.Map;
2222
import java.util.Properties;
2323

24-
@BoosterCoordinates(AbstractBoosterConfig.BOOSTERS_GROUP_ID + ":jaxrs")
25-
public class JAXRSBoosterConfig extends AbstractBoosterConfig {
24+
@BoosterCoordinates(AbstractBoosterLibertyConfig.BOOSTERS_GROUP_ID + ":jaxrs")
25+
public class JAXRSBoosterLibertyConfig extends AbstractBoosterLibertyConfig {
2626

2727
String libertyFeature = null;
2828

29-
public JAXRSBoosterConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
29+
public JAXRSBoosterLibertyConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
3030
String version = dependencies.get(getCoordindates(this.getClass()));
3131
if (version.equals(EE_7_VERSION)) {
3232
libertyFeature = JAXRS_20;

boost-common/src/main/java/io/openliberty/boost/common/boosters/JDBCBoosterConfig.java renamed to boost-common/src/main/java/io/openliberty/boost/common/boosters/liberty/JDBCBoosterLibertyConfig.java

Lines changed: 76 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
* Contributors:
99
* IBM Corporation - initial API and implementation
1010
*******************************************************************************/
11-
package io.openliberty.boost.common.boosters;
11+
package io.openliberty.boost.common.boosters.liberty;
1212

1313
import io.openliberty.boost.common.config.BoostProperties;
1414
import io.openliberty.boost.common.BoostException;
1515
import io.openliberty.boost.common.BoostLoggerI;
1616
import io.openliberty.boost.common.boosters.AbstractBoosterConfig.BoosterCoordinates;
1717
import io.openliberty.boost.common.utils.BoostUtil;
1818

19-
import static io.openliberty.boost.common.config.ConfigConstants.*;
19+
import static io.openliberty.boost.common.config.LibertyConfigConstants.*;
2020

2121
import java.util.Map;
2222
import java.util.Properties;
@@ -25,8 +25,8 @@
2525
import org.w3c.dom.Element;
2626
import org.w3c.dom.NodeList;
2727

28-
@BoosterCoordinates(AbstractBoosterConfig.BOOSTERS_GROUP_ID + ":jdbc")
29-
public class JDBCBoosterConfig extends AbstractBoosterConfig {
28+
@BoosterCoordinates(AbstractBoosterLibertyConfig.BOOSTERS_GROUP_ID + ":jdbc")
29+
public class JDBCBoosterLibertyConfig extends AbstractBoosterLibertyConfig {
3030

3131
public static String DERBY_DEPENDENCY = "org.apache.derby:derby";
3232
public static String DB2_DEPENDENCY = "com.ibm.db2.jcc:db2jcc";
@@ -39,22 +39,22 @@ public class JDBCBoosterConfig extends AbstractBoosterConfig {
3939

4040
private Properties serverProperties;
4141

42-
public JDBCBoosterConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
42+
public JDBCBoosterLibertyConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
4343

4444
// Check for user defined database dependencies
4545
String configuredDatabaseDep = null;
4646

47-
if (dependencies.containsKey(JDBCBoosterConfig.DERBY_DEPENDENCY)) {
48-
String derbyVersion = dependencies.get(JDBCBoosterConfig.DERBY_DEPENDENCY);
49-
configuredDatabaseDep = JDBCBoosterConfig.DERBY_DEPENDENCY + ":" + derbyVersion;
50-
51-
} else if (dependencies.containsKey(JDBCBoosterConfig.DB2_DEPENDENCY)) {
52-
String db2Version = dependencies.get(JDBCBoosterConfig.DB2_DEPENDENCY);
53-
configuredDatabaseDep = JDBCBoosterConfig.DB2_DEPENDENCY + ":" + db2Version;
54-
55-
} else if (dependencies.containsKey(JDBCBoosterConfig.MYSQL_DEPENDENCY)) {
56-
String mysqlVersion = dependencies.get(JDBCBoosterConfig.MYSQL_DEPENDENCY);
57-
configuredDatabaseDep = JDBCBoosterConfig.MYSQL_DEPENDENCY + ":" + mysqlVersion;
47+
if (dependencies.containsKey(JDBCBoosterLibertyConfig.DERBY_DEPENDENCY)) {
48+
String derbyVersion = dependencies.get(JDBCBoosterLibertyConfig.DERBY_DEPENDENCY);
49+
configuredDatabaseDep = JDBCBoosterLibertyConfig.DERBY_DEPENDENCY + ":" + derbyVersion;
50+
51+
} else if (dependencies.containsKey(JDBCBoosterLibertyConfig.DB2_DEPENDENCY)) {
52+
String db2Version = dependencies.get(JDBCBoosterLibertyConfig.DB2_DEPENDENCY);
53+
configuredDatabaseDep = JDBCBoosterLibertyConfig.DB2_DEPENDENCY + ":" + db2Version;
54+
55+
} else if (dependencies.containsKey(JDBCBoosterLibertyConfig.MYSQL_DEPENDENCY)) {
56+
String mysqlVersion = dependencies.get(JDBCBoosterLibertyConfig.MYSQL_DEPENDENCY);
57+
configuredDatabaseDep = JDBCBoosterLibertyConfig.MYSQL_DEPENDENCY + ":" + mysqlVersion;
5858
}
5959

6060
Properties boostConfigProperties = BoostProperties.getConfiguredBoostProperties(logger);
@@ -86,41 +86,49 @@ private void init(Properties boostConfigProperties, String configuredDatabaseDep
8686
// Set server properties
8787
this.serverProperties = new Properties();
8888

89-
// Initialize defaults and required properties for each datasource vendor
89+
// Initialize defaults and required properties for each datasource
90+
// vendor
9091
if (this.dependency.startsWith(DERBY_DEPENDENCY)) {
91-
// Embedded Derby requires a database name. Set a default for this and create it.
92+
// Embedded Derby requires a database name. Set a default for this
93+
// and create it.
9294
this.serverProperties.put(BoostProperties.DATASOURCE_DATABASE_NAME, DERBY_DB);
9395
this.serverProperties.put(BoostProperties.DATASOURCE_CREATE_DATABASE, "create");
94-
96+
9597
} else if (this.dependency.startsWith(DB2_DEPENDENCY)) {
96-
// For DB2, since we are expecting the database to exist, there is no
97-
// default value we can set for databaseName that would be of any use.
98-
// Likewise, for user and password, there isn't anything we could set
99-
// here that would make sense. Since these properties are required,
100-
// set empty strings as there values to create place holders. If they
101-
// are not overridden by the user at package time, they can be overridden
102-
// at runtime.
103-
this.serverProperties.put(BoostProperties.DATASOURCE_DATABASE_NAME, "");
104-
this.serverProperties.put(BoostProperties.DATASOURCE_USER, "");
105-
this.serverProperties.put(BoostProperties.DATASOURCE_PASSWORD, "");
98+
// For DB2, since we are expecting the database to exist, there is
99+
// no
100+
// default value we can set for databaseName that would be of any
101+
// use.
102+
// Likewise, for user and password, there isn't anything we could
103+
// set
104+
// here that would make sense. Since these properties are required,
105+
// set empty strings as there values to create place holders. If
106+
// they
107+
// are not overridden by the user at package time, they can be
108+
// overridden
109+
// at runtime.
110+
this.serverProperties.put(BoostProperties.DATASOURCE_DATABASE_NAME, "");
111+
this.serverProperties.put(BoostProperties.DATASOURCE_USER, "");
112+
this.serverProperties.put(BoostProperties.DATASOURCE_PASSWORD, "");
106113
this.serverProperties.put(BoostProperties.DATASOURCE_SERVER_NAME, LOCALHOST);
107-
this.serverProperties.put(BoostProperties.DATASOURCE_PORT_NUMBER, DB2_DEFAULT_PORT_NUMBER);
108-
114+
this.serverProperties.put(BoostProperties.DATASOURCE_PORT_NUMBER, DB2_DEFAULT_PORT_NUMBER);
115+
109116
} else if (this.dependency.startsWith(MYSQL_DEPENDENCY)) {
110-
// Same set of minimum requirements for MySQL
111-
this.serverProperties.put(BoostProperties.DATASOURCE_DATABASE_NAME, "");
112-
this.serverProperties.put(BoostProperties.DATASOURCE_USER, "");
113-
this.serverProperties.put(BoostProperties.DATASOURCE_PASSWORD, "");
117+
// Same set of minimum requirements for MySQL
118+
this.serverProperties.put(BoostProperties.DATASOURCE_DATABASE_NAME, "");
119+
this.serverProperties.put(BoostProperties.DATASOURCE_USER, "");
120+
this.serverProperties.put(BoostProperties.DATASOURCE_PASSWORD, "");
114121
this.serverProperties.put(BoostProperties.DATASOURCE_SERVER_NAME, LOCALHOST);
115-
this.serverProperties.put(BoostProperties.DATASOURCE_PORT_NUMBER, MYSQL_DEFAULT_PORT_NUMBER);
116-
}
117-
118-
// Find and add all "boost.db." properties. This will override any default values
122+
this.serverProperties.put(BoostProperties.DATASOURCE_PORT_NUMBER, MYSQL_DEFAULT_PORT_NUMBER);
123+
}
124+
125+
// Find and add all "boost.db." properties. This will override any
126+
// default values
119127
for (String key : boostConfigProperties.stringPropertyNames()) {
120-
if ( key.startsWith(BoostProperties.DATASOURCE_PREFIX)) {
121-
String value = (String) boostConfigProperties.get(key);
122-
this.serverProperties.put(key, value);
123-
}
128+
if (key.startsWith(BoostProperties.DATASOURCE_PREFIX)) {
129+
String value = (String) boostConfigProperties.get(key);
130+
this.serverProperties.put(key, value);
131+
}
124132
}
125133
}
126134

@@ -145,14 +153,14 @@ public String getDependency() {
145153
public void addServerConfig(Document doc) {
146154

147155
if (dependency.startsWith(DERBY_DEPENDENCY)) {
148-
addDatasourceConfig(doc, PROPERTIES_DERBY_EMBEDDED, DERBY_JAR);
156+
addDatasourceConfig(doc, PROPERTIES_DERBY_EMBEDDED, DERBY_JAR);
149157

150158
} else if (dependency.startsWith(DB2_DEPENDENCY)) {
151-
addDatasourceConfig(doc, PROPERTIES_DB2_JCC, DB2_JAR);
152-
159+
addDatasourceConfig(doc, PROPERTIES_DB2_JCC, DB2_JAR);
160+
153161
} else if (dependency.startsWith(MYSQL_DEPENDENCY)) {
154-
// Use generic <properties> element for MySQL
155-
addDatasourceConfig(doc, PROPERTIES, MYSQL_JAR);
162+
// Use generic <properties> element for MySQL
163+
addDatasourceConfig(doc, PROPERTIES, MYSQL_JAR);
156164
}
157165
}
158166

@@ -194,27 +202,30 @@ private void addDatasourceConfig(Document doc, String datasourcePropertiesElemen
194202
jdbcDriver.setAttribute("id", JDBC_DRIVER_1);
195203
jdbcDriver.setAttribute(LIBRARY_REF, JDBC_LIBRARY_1);
196204
serverRoot.appendChild(jdbcDriver);
197-
205+
198206
// Add container authentication
199-
if (this.serverProperties.containsKey(BoostProperties.DATASOURCE_USER) && this.serverProperties.containsKey(BoostProperties.DATASOURCE_PASSWORD)) {
200-
dataSource.setAttribute(CONTAINER_AUTH_DATA_REF, DATASOURCE_AUTH_DATA);
201-
202-
Element containerAuthData = doc.createElement(AUTH_DATA);
203-
containerAuthData.setAttribute("id", DATASOURCE_AUTH_DATA);
204-
containerAuthData.setAttribute(USER, BoostUtil.makeVariable(BoostProperties.DATASOURCE_USER));
205-
containerAuthData.setAttribute(PASSWORD, BoostUtil.makeVariable(BoostProperties.DATASOURCE_PASSWORD));
206-
serverRoot.appendChild(containerAuthData);
207+
if (this.serverProperties.containsKey(BoostProperties.DATASOURCE_USER)
208+
&& this.serverProperties.containsKey(BoostProperties.DATASOURCE_PASSWORD)) {
209+
dataSource.setAttribute(CONTAINER_AUTH_DATA_REF, DATASOURCE_AUTH_DATA);
210+
211+
Element containerAuthData = doc.createElement(AUTH_DATA);
212+
containerAuthData.setAttribute("id", DATASOURCE_AUTH_DATA);
213+
containerAuthData.setAttribute(USER, BoostUtil.makeVariable(BoostProperties.DATASOURCE_USER));
214+
containerAuthData.setAttribute(PASSWORD, BoostUtil.makeVariable(BoostProperties.DATASOURCE_PASSWORD));
215+
serverRoot.appendChild(containerAuthData);
207216
}
208217
}
209-
218+
210219
private void addDatasourceProperties(Element properties) {
211-
for (String property : this.serverProperties.stringPropertyNames()) {
212-
// We are using container authentication. Do not include user or password here
213-
if ( !property.equals(BoostProperties.DATASOURCE_USER) && !property.equals(BoostProperties.DATASOURCE_PASSWORD)) {
214-
215-
String attribute = property.replace(BoostProperties.DATASOURCE_PREFIX, "");
216-
properties.setAttribute(attribute, BoostUtil.makeVariable(property));
217-
}
220+
for (String property : this.serverProperties.stringPropertyNames()) {
221+
// We are using container authentication. Do not include user or
222+
// password here
223+
if (!property.equals(BoostProperties.DATASOURCE_USER)
224+
&& !property.equals(BoostProperties.DATASOURCE_PASSWORD)) {
225+
226+
String attribute = property.replace(BoostProperties.DATASOURCE_PREFIX, "");
227+
properties.setAttribute(attribute, BoostUtil.makeVariable(property));
228+
}
218229
}
219230
}
220231
}

boost-common/src/main/java/io/openliberty/boost/common/boosters/JPABoosterConfig.java renamed to boost-common/src/main/java/io/openliberty/boost/common/boosters/liberty/JPABoosterLibertyConfig.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
* Contributors:
99
* IBM Corporation - initial API and implementation
1010
*******************************************************************************/
11-
package io.openliberty.boost.common.boosters;
11+
package io.openliberty.boost.common.boosters.liberty;
1212

1313
import org.w3c.dom.Document;
1414

1515
import io.openliberty.boost.common.BoostException;
1616
import io.openliberty.boost.common.BoostLoggerI;
1717
import io.openliberty.boost.common.boosters.AbstractBoosterConfig.BoosterCoordinates;
1818

19-
import static io.openliberty.boost.common.config.ConfigConstants.*;
19+
import static io.openliberty.boost.common.config.LibertyConfigConstants.*;
2020

2121
import java.util.Map;
2222
import java.util.Properties;
2323

24-
@BoosterCoordinates(AbstractBoosterConfig.BOOSTERS_GROUP_ID + ":jpa")
25-
public class JPABoosterConfig extends AbstractBoosterConfig {
24+
@BoosterCoordinates(AbstractBoosterLibertyConfig.BOOSTERS_GROUP_ID + ":jpa")
25+
public class JPABoosterLibertyConfig extends AbstractBoosterLibertyConfig {
2626

2727
String libertyFeature = null;
2828

29-
public JPABoosterConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
29+
public JPABoosterLibertyConfig(Map<String, String> dependencies, BoostLoggerI logger) throws BoostException {
3030
String version = dependencies.get(getCoordindates(this.getClass()));
3131
if (version.equals(EE_7_VERSION)) {
3232
libertyFeature = JPA_21;

0 commit comments

Comments
 (0)