1 22 package org.jboss.verifier; 23 24 47 48 import java.io.File ; 50 import java.net.URL ; 51 import java.net.URLClassLoader ; 52 53 import org.jboss.verifier.event.VerificationListener; 55 import org.jboss.verifier.event.VerificationEvent; 56 57 import org.jboss.metadata.XmlFileLoader; 58 59 69 public class Main 70 { 71 public final static int OK = 0; 72 public final static int WARNING = 1; 73 74 static int returnCode = OK; 75 76 81 public static void main(String [] args) 82 { 83 try 84 { 85 if( args.length < 1 ) 86 { 87 throw new IllegalArgumentException ( 88 "Usage: beanverifier mybeans.jar"); 89 } 90 91 URL url = new File (args[0]).toURL(); 92 URLClassLoader cl = new URLClassLoader ( new URL [] {url}, 93 Thread.currentThread().getContextClassLoader()); 94 XmlFileLoader xfl = new XmlFileLoader(); 95 BeanVerifier verifier = new BeanVerifier(); 96 97 xfl.setClassLoader(cl); 98 verifier.addVerificationListener(new Listener()); 99 100 verifier.verify(url, xfl.load(null)); 101 } 102 catch (Exception e) 103 { 104 System.err.println("Problem starting the application:"); 105 System.err.println("Exception: " + e); 106 System.err.println("Message: " + e.getMessage()); 107 e.printStackTrace(); 108 109 System.exit(-1); 110 } 111 112 System.exit(returnCode); 113 } 114 } 115 116 class Listener 117 implements VerificationListener 118 { 119 public void specViolation(VerificationEvent event) 120 { 121 System.out.println(event.getVerbose()); 122 123 Main.returnCode = Main.WARNING; 124 } 125 126 public void beanChecked(VerificationEvent event) 127 { 128 System.out.println(event.getMessage()); 129 } 130 } 131 134 | Popular Tags |