org.apache.maven.j2ee
Class WarValidator

java.lang.Object
  extended byorg.apache.maven.j2ee.WarValidator

public class WarValidator
extends Object

A task to validate a war file. The following is checked:

  1. The war file exists
  2. The war file is readable
  3. The war file has a web.xml (warning)
  4. Servlets defined by a <servlet> tag are loadable from the war file and not the classpath
  5. JSPs defined by a <servlet> tag exist in the war
  6. Taglibs defined by a <taglib> have a <taglib-location> that exists in the war
  7. Error pages specified by a <location> nested within an <error-page> element must exist in the war file
  8. Login and error pages specified in the <form-login-config > element must exist in the war file

Version:
$Id: WarValidator.java 170200 2005-05-15 06:24:19Z brett $
Author:
dIon Gillard

Constructor Summary
WarValidator()
          Creates a new instance of WarValidator
 
Method Summary
 void addFormatter(ValidationFormatter formatter)
          Add a formatter to pick up events and display the output.
 void addValidationListener(ValidationListener listener)
          add a listener to the list to be notified
protected  void endValidation()
          End validation - fire an ended event
protected  void error(String message)
          Helper method to fire an error message using the broadcaster
 void execute()
          Perform the validation.
protected  ValidationBroadcaster getBroadcaster()
          Getter for property broadcaster.
 ValidationStatusListener getStatus()
          Provides access to the status listener that is automatically attached to the validation
 String getWarFileName()
          Getter for property warFileName.
protected  void info(String message)
          Helper method to fire an information message using the broadcaster
 boolean isFailOnError()
          Whether the build process will fail if a validation error occurs.
 void removeValidationListener(ValidationListener listener)
          remove a listener from the list to be notified
 void setFailOnError(boolean failOnError)
          Set whether the build process will fail if a validation error occurs.
 void setWarFileName(String warFileName)
          Setter for property warFileName.
protected  void startValidation()
          Start validation - issue a started event, and check the war file is ok from a filesystem perspective - exists and is readable
 String toString()
          Provide a string representation of the validator
 void validate()
          validate the provided war file
protected  void validateClass(String className, ClassLoader loader)
          Validate that the given className can be loaded by the given ClasssLoader
 void validateErrorPages(WarFile war)
          Validate the error pages defined in the war file (as defined by a <error-page> tag in web.xml), making sure that the location specifed by the nested <location> exists in the war file
 void validateFormLoginConfig(WarFile war)
          Validate that the <form-login-config> element, if it exists contains valid login and error pages
protected  void validateWarContents()
          Hook point for subclasses to add validations
protected  void warning(String message)
          Helper method to fire a warning message using the broadcaster
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WarValidator

public WarValidator()
Creates a new instance of WarValidator

Method Detail

getStatus

public ValidationStatusListener getStatus()
Provides access to the status listener that is automatically attached to the validation

Returns:
Value of property status.

execute

public void execute()
Perform the validation.

Throws:
IllegalStateException - when any error occurs

validate

public void validate()
validate the provided war file


startValidation

protected void startValidation()
Start validation - issue a started event, and check the war file is ok from a filesystem perspective - exists and is readable


validateWarContents

protected void validateWarContents()
Hook point for subclasses to add validations


endValidation

protected void endValidation()
End validation - fire an ended event


validateClass

protected void validateClass(String className,
                             ClassLoader loader)
Validate that the given className can be loaded by the given ClasssLoader

Parameters:
className - the name of a class to attempt loading
loader - a class loader

validateErrorPages

public void validateErrorPages(WarFile war)
                        throws IOException
Validate the error pages defined in the war file (as defined by a <error-page> tag in web.xml), making sure that the location specifed by the nested <location> exists in the war file

Parameters:
war - the war file to validate
Throws:
IOException - when there are any issues reading the war file

validateFormLoginConfig

public void validateFormLoginConfig(WarFile war)
                             throws IOException
Validate that the <form-login-config> element, if it exists contains valid login and error pages

Parameters:
war - the war file to validate
Throws:
IOException - when there are any issues reading the war file

addValidationListener

public void addValidationListener(ValidationListener listener)
add a listener to the list to be notified

Parameters:
listener - a ValidationListener

removeValidationListener

public void removeValidationListener(ValidationListener listener)
remove a listener from the list to be notified

Parameters:
listener - a ValidationListener

getWarFileName

public String getWarFileName()
Getter for property warFileName.

Returns:
Value of property warFileName.

setWarFileName

public void setWarFileName(String warFileName)
Setter for property warFileName.

Parameters:
warFileName - New value of property warFileName.

getBroadcaster

protected ValidationBroadcaster getBroadcaster()
Getter for property broadcaster.

Returns:
Value of property broadcaster.

addFormatter

public void addFormatter(ValidationFormatter formatter)
Add a formatter to pick up events and display the output. Used by ant when a nested formatter element is present.

Parameters:
formatter - a class to format validation events

toString

public String toString()
Provide a string representation of the validator

Returns:
"WarValidator(file)"

isFailOnError

public boolean isFailOnError()
Whether the build process will fail if a validation error occurs.

Returns:
Value of property failOnError.

setFailOnError

public void setFailOnError(boolean failOnError)
Set whether the build process will fail if a validation error occurs.

Parameters:
failOnError - New value of property failOnError.

info

protected void info(String message)
Helper method to fire an information message using the broadcaster

Parameters:
message - to be fired

error

protected void error(String message)
Helper method to fire an error message using the broadcaster

Parameters:
message - to be fired

warning

protected void warning(String message)
Helper method to fire a warning message using the broadcaster

Parameters:
message - to be fired


Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.