add optional module support and jmx example

This commit is contained in:
Jesse McConnell 2013-08-23 17:27:26 -05:00
parent 135a4b4c45
commit cfbd3ec488
6 changed files with 55 additions and 2 deletions

View File

@ -60,6 +60,8 @@ public class Module extends TextFile
private String name;
/** List of Modules, by name, that this Module depends on */
private Set<String> parentNames;
/** List of Modules, by name, that this Module optionally depend on */
private Set<String> optionalParentNames;
/** The Edges to parent modules */
private Set<Module> parentEdges;
/** The Edges to child modules */
@ -143,6 +145,11 @@ public class Module extends TextFile
return name;
}
public Set<String> getOptionalParentNames()
{
return optionalParentNames;
}
public Set<Module> getParentEdges()
{
return parentEdges;
@ -176,6 +183,7 @@ public class Module extends TextFile
this.name = Pattern.compile(".mod$",Pattern.CASE_INSENSITIVE).matcher(name).replaceFirst("");
this.parentNames = new HashSet<>();
this.optionalParentNames = new HashSet<>();
this.parentEdges = new HashSet<>();
this.childEdges = new HashSet<>();
this.xmls = new ArrayList<>();
@ -206,6 +214,10 @@ public class Module extends TextFile
switch (key.toUpperCase(Locale.ENGLISH))
{
case "OPTIONAL":
optionalParentNames.add(value);
handled = true;
break;
case "DEPEND":
parentNames.add(value);
handled = true;

View File

@ -84,13 +84,13 @@ public class Modules implements Iterable<Module>
}
/**
* Using the provided dependenies, build the module graph
* Using the provided dependencies, build the module graph
*/
public void buildGraph()
{
// Connect edges
for (Module module : modules.values())
{
{
for (String parentName : module.getParentNames())
{
Module parent = get(parentName);
@ -100,6 +100,17 @@ public class Modules implements Iterable<Module>
parent.addChildEdge(module);
}
}
for (String optionalParentName : module.getOptionalParentNames())
{
Module optional = get(optionalParentName);
if (optional != null && optional.isEnabled())
{
module.addParentEdge(optional);
optional.addChildEdge(module);
}
}
}
// Verify there is no cyclic references

View File

@ -50,4 +50,10 @@ public class TestUseCases
{
assertUseCase("home","base.barebones","assert-barebones.txt");
}
@Test
public void testJMX() throws Exception
{
assertUseCase("home","base.jmx","assert-jmx.txt");
}
}

View File

@ -0,0 +1,18 @@
# The XMLs we expect (order is important)
XML|${jetty.home}/etc/jetty-jmx.xml
XML|${jetty.home}/etc/jetty.xml
XML|${jetty.home}/etc/jetty-http.xml
# The LIBs we expect (order is irrelevant)
LIB|${jetty.home}/lib/jetty-continuation-TEST.jar
LIB|${jetty.home}/lib/jetty-http-TEST.jar
LIB|${jetty.home}/lib/jetty-io-TEST.jar
LIB|${jetty.home}/lib/jetty-jmx-TEST.jar
LIB|${jetty.home}/lib/jetty-schemas-3.1.jar
LIB|${jetty.home}/lib/jetty-server-TEST.jar
LIB|${jetty.home}/lib/jetty-util-TEST.jar
LIB|${jetty.home}/lib/jetty-xml-TEST.jar
LIB|${jetty.home}/lib/servlet-api-3.1.jar
# The Properties we expect (order is irrelevant)
PROP|jetty.port=9090

View File

@ -0,0 +1,4 @@
MODULES=server,http,jmx
jetty.port=9090

View File

@ -2,5 +2,7 @@
# Base Module
#
OPTIONAL=jmx
LIB=lib/jetty-util-${jetty.version}.jar
LIB=lib/jetty-io-${jetty.version}.jar