User: starksm
Date: 01/12/08 17:37:02
Modified: src/main/org/jboss/verifier Tag: Branch_2_4 Main.java
Log:
Validate the xml descriptor by default. Use -novalidate to disable validation
Revision Changes Path
No revision
No revision
1.5.6.1 +75 -60 jboss/src/main/org/jboss/verifier/Main.java
Index: Main.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/verifier/Main.java,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- Main.java 2001/03/24 21:14:14 1.5
+++ Main.java 2001/12/09 01:37:02 1.5.6.1
@@ -8,23 +8,23 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* This package and its source code is available at www.jboss.org
- * $Id: Main.java,v 1.5 2001/03/24 21:14:14 juhalindfors Exp $
+ * $Id: Main.java,v 1.5.6.1 2001/12/09 01:37:02 starksm Exp $
*
* You can reach the author by sending email to [EMAIL PROTECTED]
*/
-
+
// standard imports
import java.io.File;
import java.net.URL;
@@ -36,72 +36,87 @@
import org.jboss.metadata.XmlFileLoader;
-
/**
* Main class for bean verifier.
*
* For more detailed documentation, refer to the
- * <a href="http://www.ejboss.org">JBoss project</a>
+ * <a href="http://www.jboss.org">JBoss project</a>
*
* @see << OTHER RELATED CLASSES >>
*
* @author Juha Lindfors
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.5.6.1 $
* @since JDK 1.3
*/
-public class Main {
-
- public final static int OK = 0;
- public final static int WARNING = 1;
-
- static int returnCode = OK;
-
- /**
- * Starts the application.
- *
- * @param args argument strings
- */
- public static void main(String[] args) {
-
- try {
- if (args.length < 1)
- throw new IllegalArgumentException("Usage: beanverifier
mybeans.jar");
-
- URL url = new File(args[0]).toURL();
- ClassLoader cl = new URLClassLoader(new URL[] {url},
Thread.currentThread().getContextClassLoader());
- XmlFileLoader xfl = new XmlFileLoader();
- BeanVerifier verifier = new BeanVerifier();
-
- xfl.setClassLoader(cl);
- verifier.addVerificationListener(new Listener());
-
- verifier.verify(url, xfl.load());
- }
- catch (Exception e) {
- System.err.println("Problem starting the application:");
- System.err.println("Exception: " + e);
- System.err.println("Message: " + e.getMessage());
- e.printStackTrace();
-
- System.exit(-1);
- }
-
- System.exit(returnCode);
- }
-
+public class Main
+{
+
+ public final static int OK = 0;
+ public final static int WARNING = 1;
+
+ static int returnCode = OK;
+
+ /**
+ * Starts the application.
+ *
+ * @param args argument strings
+ */
+ public static void main(String[] args)
+ {
+
+ try
+ {
+ if (args.length < 1)
+ throw new IllegalArgumentException("Usage: beanverifier [-novalidate]
mybeans.jar");
+
+ boolean validate = true;
+ String jar = null;
+ for(int a = 0; a < args.length; a ++)
+ {
+ if( args[a].startsWith("-no") )
+ validate = false;
+ else
+ jar = args[a];
+ }
+ URL url = new File(jar).toURL();
+ URL[] urls = {url};
+ ClassLoader parent = Thread.currentThread().getContextClassLoader();
+ ClassLoader cl = new URLClassLoader(urls, parent);
+ XmlFileLoader xfl = new XmlFileLoader(validate);
+ BeanVerifier verifier = new BeanVerifier();
+
+ xfl.setClassLoader(cl);
+ verifier.addVerificationListener(new Listener());
+
+ verifier.verify(url, xfl.load());
+ }
+ catch (Exception e)
+ {
+ System.err.println("Problem starting the application:");
+ System.err.println("Exception: " + e);
+ System.err.println("Message: " + e.getMessage());
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ System.exit(returnCode);
+ }
+
}
-class Listener implements VerificationListener {
-
- public void specViolation(VerificationEvent event) {
- System.out.println(event.getVerbose());
-
- Main.returnCode = Main.WARNING;
- }
-
- public void beanChecked(VerificationEvent event) {
- System.out.println(event.getMessage());
- }
+class Listener implements VerificationListener
+{
+
+ public void specViolation(VerificationEvent event)
+ {
+ System.out.println(event.getVerbose());
+
+ Main.returnCode = Main.WARNING;
+ }
+
+ public void beanChecked(VerificationEvent event)
+ {
+ System.out.println(event.getMessage());
+ }
}
-
-
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development