bring configuration back into webapp verifier to trim artifact count

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/sandbox/trunk@818 7e9141cc-0065-0410-87d8-b60c137991c4
diff --git a/jetty-webapp-verifier/pom.xml b/jetty-webapp-verifier/pom.xml
index 626642f..b346f11 100644
--- a/jetty-webapp-verifier/pom.xml
+++ b/jetty-webapp-verifier/pom.xml
@@ -65,6 +65,11 @@
       <artifactId>jetty-xml</artifactId>
       <version>${version}</version>
     </dependency>
+     <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-webapp</artifactId>
+      <version>${version}</version>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
diff --git a/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/config/WebappVerifierConfiguration.java b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/config/WebappVerifierConfiguration.java
new file mode 100644
index 0000000..c79bd65
--- /dev/null
+++ b/jetty-webapp-verifier/src/main/java/org/eclipse/jetty/webapp/verifier/config/WebappVerifierConfiguration.java
@@ -0,0 +1,99 @@
+// ========================================================================
+// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+// The Eclipse Public License is available at 
+// http://www.eclipse.org/legal/epl-v10.html
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+// You may elect to redistribute this code under either of these licenses. 
+// ========================================================================
+package org.eclipse.jetty.webapp.verifier.config;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Collection;
+
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.webapp.Configuration;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.eclipse.jetty.webapp.verifier.RuleSet;
+import org.eclipse.jetty.webapp.verifier.Severity;
+import org.eclipse.jetty.webapp.verifier.Violation;
+import org.eclipse.jetty.webapp.verifier.WebappVerifier;
+
+/**
+ * WebappVerifierConfiguration
+ */
+public class WebappVerifierConfiguration implements Configuration
+{
+    /* ------------------------------------------------------------ */
+    /**
+     * @see org.eclipse.jetty.webapp.Configuration#configure(org.eclipse.jetty.webapp.WebAppContext)
+     */
+    public void configure(WebAppContext context) throws Exception
+    {
+
+    }
+
+    /* ------------------------------------------------------------ */
+    /**
+     * @see org.eclipse.jetty.webapp.Configuration#deconfigure(org.eclipse.jetty.webapp.WebAppContext)
+     */
+    public void deconfigure(WebAppContext context) throws Exception
+    {
+
+    }
+
+    /* ------------------------------------------------------------ */
+    /**
+     * @see org.eclipse.jetty.webapp.Configuration#postConfigure(org.eclipse.jetty.webapp.WebAppContext)
+     */
+    public void postConfigure(WebAppContext context) throws Exception
+    {
+
+    }
+
+    /* ------------------------------------------------------------ */
+    /**
+     * @see org.eclipse.jetty.webapp.Configuration#preConfigure(org.eclipse.jetty.webapp.WebAppContext)
+     */
+    public void preConfigure(WebAppContext context) throws Exception
+    {
+        if(Log.isDebugEnabled())
+        {
+            Log.debug("Configuring webapp verifier");
+        }
+        
+        URI configurationUri = new File( System.getProperty( "jetty.home" )).toURI().resolve( "etc/default-webapp-verifier.xml" );
+                
+        RuleSet suite = RuleSet.load( configurationUri.toURL() );
+        
+        WebappVerifier verifier = suite.createWebappVerifier( new URI( context.getWar() ) );
+        
+        verifier.visitAll();
+        
+        Collection<Violation> violations = verifier.getViolations();
+        
+        boolean haltWebapp = false;
+        
+        Log.info( " Webapp Verifier Report: " + violations.size()  + " violations" );
+        
+        for (Violation violation : violations)
+        {
+            if ( violation.getSeverity() == Severity.ERROR )
+            {
+                haltWebapp = true;
+            }
+            
+            Log.info( violation.toString() );           
+        }
+        
+        if ( haltWebapp )
+        {
+            throw new InstantiationException( "Configuration exception: webapp failed webapp verification" );
+        }
+    }
+}