414635 Modular start.d and jetty.base property

+ More mod cleanup
 + Adding cyclic module reference detection and reporting
This commit is contained in:
Joakim Erdfelt 2013-08-22 14:21:52 -07:00
parent 5b2d9bc825
commit b8e1f42b37
16 changed files with 116 additions and 28 deletions

View File

@ -3,10 +3,7 @@
#
DEPEND=server
DEPEND=plus
LIB=lib/jetty-jndi-${jetty.version}.jar
LIB=lib/jndi/*.jar
# Annotations needs annotations configuration
etc/jetty-server.xml

View File

@ -3,6 +3,8 @@
#
DEPEND=server
DEPEND=security
DEPEND=jndi
LIB=lib/jetty-plus-${jetty.version}.jar

View File

@ -53,6 +53,23 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>config</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>

View File

@ -29,6 +29,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
/**
* Access for all modules declared, as well as what is enabled.
@ -59,8 +60,6 @@ public class Modules implements Iterable<Module>
*/
public void buildGraph()
{
// TODO: Validate / Enforce Directed Acyclic Graph
// Connect edges
for (Module module : modules.values())
{
@ -75,6 +74,15 @@ public class Modules implements Iterable<Module>
}
}
// Verify there is no cyclic references
Stack<String> refs = new Stack<>();
for (Module module : modules.values())
{
refs.push(module.getName());
assertNoCycle(module,refs);
refs.pop();
}
// Calculate depth of all modules for sorting later
for (Module module : modules.values())
{
@ -85,6 +93,33 @@ public class Modules implements Iterable<Module>
}
}
private void assertNoCycle(Module module, Stack<String> refs)
{
for (Module parent : module.getParentEdges())
{
if (refs.contains(parent.getName()))
{
// Cycle detected.
StringBuilder err = new StringBuilder();
err.append("A cyclic reference in the modules has been detected: ");
for (int i = 0; i < refs.size(); i++)
{
if (i > 0)
{
err.append(" -> ");
}
err.append(refs.get(i));
}
err.append(" -> ").append(parent.getName());
throw new IllegalStateException(err.toString());
}
refs.push(parent.getName());
assertNoCycle(parent,refs);
refs.pop();
}
}
public Integer count()
{
return modules.size();

View File

@ -39,7 +39,7 @@ public class ModulesTest
Modules modules = new Modules();
modules.registerAll(basehome);
Assert.assertThat("Module count",modules.count(),is(24));
Assert.assertThat("Module count",modules.count(),is(26));
}
@Test
@ -63,6 +63,7 @@ public class ModulesTest
// Assert names are correct, and in the right order
List<String> expectedNames = new ArrayList<>();
expectedNames.add("base");
expectedNames.add("xml");
expectedNames.add("server");
expectedNames.add("http");
@ -78,6 +79,7 @@ public class ModulesTest
List<String> expectedLibs = new ArrayList<>();
expectedLibs.add("lib/jetty-util-${jetty.version}.jar");
expectedLibs.add("lib/jetty-io-${jetty.version}.jar");
expectedLibs.add("lib/jetty-xml-${jetty.version}.jar");
expectedLibs.add("lib/servlet-api-3.1.jar");
expectedLibs.add("lib/jetty-schemas-3.1.jar");
expectedLibs.add("lib/jetty-http-${jetty.version}.jar");
@ -118,8 +120,11 @@ public class ModulesTest
// Assert names are correct, and in the right order
List<String> expectedNames = new ArrayList<>();
expectedNames.add("base");
expectedNames.add("xml");
expectedNames.add("server");
expectedNames.add("http");
expectedNames.add("jndi");
expectedNames.add("security");
expectedNames.add("plus");
expectedNames.add("annotations");
expectedNames.add("websocket");
@ -136,11 +141,15 @@ public class ModulesTest
List<String> expectedLibs = new ArrayList<>();
expectedLibs.add("lib/jetty-util-${jetty.version}.jar");
expectedLibs.add("lib/jetty-io-${jetty.version}.jar");
expectedLibs.add("lib/jetty-xml-${jetty.version}.jar");
expectedLibs.add("lib/servlet-api-3.1.jar");
expectedLibs.add("lib/jetty-schemas-3.1.jar");
expectedLibs.add("lib/jetty-http-${jetty.version}.jar");
expectedLibs.add("lib/jetty-continuation-${jetty.version}.jar");
expectedLibs.add("lib/jetty-server-${jetty.version}.jar");
expectedLibs.add("lib/jetty-jndi-${jetty.version}.jar");
expectedLibs.add("lib/jndi/*.jar");
expectedLibs.add("lib/jetty-security-${jetty.version}.jar");
expectedLibs.add("lib/jetty-plus-${jetty.version}.jar");
expectedLibs.add("lib/jetty-annotations-${jetty.version}.jar");
expectedLibs.add("lib/annotations/*.jar");

View File

@ -8,18 +8,23 @@ XML|${jetty.home}/etc/jetty-websockets.xml
XML|${jetty.home}/etc/jetty-logging.xml
# The LIBs we expect (order is irrelevant)
LIB|${jetty.home}/lib/jetty-http-TEST.jar
LIB|${jetty.home}/lib/jetty-util-TEST.jar
LIB|${jetty.home}/lib/jetty-schemas-3.1.jar
LIB|${jetty.home}/lib/jetty-jmx-TEST.jar
LIB|${jetty.home}/lib/annotations/javax.annotation-api-1.2.jar
LIB|${jetty.home}/lib/servlet-api-3.1.jar
LIB|${jetty.home}/lib/jetty-annotations-TEST.jar
LIB|${jetty.home}/lib/jetty-plus-TEST.jar
LIB|${jetty.home}/lib/jetty-io-TEST.jar
LIB|${jetty.home}/lib/jetty-continuation-TEST.jar
LIB|${jetty.home}/lib/annotations/org.objectweb.asm-TEST.jar
LIB|${jetty.home}/lib/jetty-annotations-TEST.jar
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-jndi-TEST.jar
LIB|${jetty.home}/lib/jetty-plus-TEST.jar
LIB|${jetty.home}/lib/jetty-schemas-3.1.jar
LIB|${jetty.home}/lib/jetty-security-TEST.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/jndi/javax.activation-1.1.jar
LIB|${jetty.home}/lib/jndi/javax.transaction-api-1.2.jar
LIB|${jetty.home}/lib/servlet-api-3.1.jar
# The Properties we expect (order is irrelevant)
# PROP|jetty.port=9090

View File

@ -7,18 +7,23 @@ XML|${jetty.home}/etc/jetty-annotations.xml
XML|${jetty.home}/etc/jetty-websockets.xml
# The LIBs we expect (order is irrelevant)
LIB|${jetty.home}/lib/jetty-http-TEST.jar
LIB|${jetty.home}/lib/jetty-util-TEST.jar
LIB|${jetty.home}/lib/jetty-schemas-3.1.jar
LIB|${jetty.home}/lib/jetty-jmx-TEST.jar
LIB|${jetty.home}/lib/annotations/javax.annotation-api-1.2.jar
LIB|${jetty.home}/lib/servlet-api-3.1.jar
LIB|${jetty.home}/lib/jetty-annotations-TEST.jar
LIB|${jetty.home}/lib/jetty-plus-TEST.jar
LIB|${jetty.home}/lib/jetty-io-TEST.jar
LIB|${jetty.home}/lib/jetty-continuation-TEST.jar
LIB|${jetty.home}/lib/annotations/org.objectweb.asm-TEST.jar
LIB|${jetty.home}/lib/jetty-annotations-TEST.jar
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-jndi-TEST.jar
LIB|${jetty.home}/lib/jetty-plus-TEST.jar
LIB|${jetty.home}/lib/jetty-schemas-3.1.jar
LIB|${jetty.home}/lib/jetty-security-TEST.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/jndi/javax.activation-1.1.jar
LIB|${jetty.home}/lib/jndi/javax.transaction-api-1.2.jar
LIB|${jetty.home}/lib/servlet-api-3.1.jar
# The Properties we expect (order is irrelevant)
PROP|jetty.port=9090

View File

@ -3,10 +3,7 @@
#
DEPEND=server
DEPEND=plus
LIB=lib/jetty-jndi-${jetty.version}.jar
LIB=lib/jndi/*.jar
# Annotations needs annotations configuration
etc/jetty-server.xml

View File

@ -3,6 +3,8 @@
#
DEPEND=server
DEPEND=security
DEPEND=jndi
LIB=lib/jetty-plus-${jetty.version}.jar

View File

@ -3,6 +3,7 @@
#
DEPEND=server
DEPEND=client
LIB=lib/jetty-proxy-${jetty.version}.jar

View File

@ -0,0 +1,7 @@
#
# Jetty Security Module
#
DEPEND=server
LIB=lib/jetty-security-${jetty.version}.jar

View File

@ -3,6 +3,7 @@
#
DEPEND=base
DEPEND=xml
LIB=lib/servlet-api-3.1.jar
LIB=lib/jetty-schemas-3.1.jar

View File

@ -0,0 +1,7 @@
#
# Jetty Servlet Module
#
DEPEND=server
LIB=lib/jetty-servlet-${jetty.version}.jar

View File

@ -1,5 +1,7 @@
DEPEND=server
LIB=lib/spdy/*.jar
etc/jetty-ssl.xml
etc/jetty-spdy.xml

View File

@ -2,6 +2,6 @@
# Base server
#
DEPEND=deploy
DEPEND=servlet
LIB=lib/jetty-webapp-${jetty.version}.jar

View File

@ -11,3 +11,4 @@ LIB=lib/websockets/*.jar
# WebSocket needs websocket configuration
etc/jetty-websockets.xml