org.apache.maven.plugin.war.util
Class WebappStructure

java.lang.Object
  extended by org.apache.maven.plugin.war.util.WebappStructure

public class WebappStructure
extends Object

Represents the structure of a web application composed of multiple overlays. Each overlay is registered within this structure with the set of files it holds.

Note that this structure is persisted to disk at each invocation to store which owner holds which path (file).

Version:
$Id: WebappStructure.java 1390192 2012-09-25 22:16:06Z dennisl $
Author:
Stephane Nicoll

Nested Class Summary
static interface WebappStructure.DependenciesAnalysisCallback
          Callback interface to handle events related to dependencies analysis.
static interface WebappStructure.RegistrationCallback
          Callback interface to handle events related to filepath registration in the webapp.
 
Constructor Summary
WebappStructure(List dependencies)
          Creates a new empty instance.
WebappStructure(List dependencies, WebappStructure cache)
          Creates a new instance with the specified cache.
 
Method Summary
 void analyseDependencies(WebappStructure.DependenciesAnalysisCallback callback)
          Analyze the dependencies of the project using the specified callback.
 String getCachedTargetFileName(Dependency dependency)
          Returns the cached target file name that matches the specified dependency, that is the target file name of the previous run.
 List getDependencies()
          Returns the dependencies of the project.
 List getDependenciesInfo()
          Returns the list of DependencyInfo for the project.
 PathSet getFullStructure()
          Returns all paths that have been registered so far.
 String getOwner(String path)
          Returns the owner of the specified path.
 Set getOwners()
          Returns the owners.
 PathSet getStructure(String id)
          Returns the list of registered files for the specified owner.
 boolean isRegistered(String path)
          Specify if the specified path is registered or not.
 boolean registerFile(String id, String path)
          Registers the specified path for the specified owner.
 void registerFile(String id, String path, WebappStructure.RegistrationCallback callback)
          Registers the specified path for the specified owner.
 boolean registerFileForced(String id, String path)
          Forces the registration of the specified path for the specified owner.
 void registerTargetFileName(Artifact artifact, String targetFileName)
          Registers the target file name for the specified artifact.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebappStructure

public WebappStructure(List dependencies)
Creates a new empty instance.

Parameters:
dependencies - the dependencies of the project

WebappStructure

public WebappStructure(List dependencies,
                       WebappStructure cache)
Creates a new instance with the specified cache.

Parameters:
dependencies - the dependencies of the project
cache - the cache
Method Detail

getDependenciesInfo

public List getDependenciesInfo()
Returns the list of DependencyInfo for the project.

Returns:
the dependencies information of the project

getDependencies

public List getDependencies()
Returns the dependencies of the project.

Returns:
the dependencies of the project

isRegistered

public boolean isRegistered(String path)
Specify if the specified path is registered or not.

Parameters:
path - the relative path from the webapp root directory
Returns:
true if the path is registered, false otherwise

registerFile

public boolean registerFile(String id,
                            String path)
Registers the specified path for the specified owner. Returns true if the path is not already registered, false otherwise.

Parameters:
id - the owner of the path
path - the relative path from the webapp root directory
Returns:
true if the file was registered successfully

registerFileForced

public boolean registerFileForced(String id,
                                  String path)
Forces the registration of the specified path for the specified owner. If the file is not registered yet, a simple registration is performed. If the file already exists, the owner changes to the specified one.

Beware that the semantic of the return boolean is different than the one from registerFile(String, String); returns true if an owner replacement was made and false if the file was simply registered for the first time.

Parameters:
id - the owner of the path
path - the relative path from the webapp root directory
Returns:
false if the file did not exist, true if the owner was replaced

registerFile

public void registerFile(String id,
                         String path,
                         WebappStructure.RegistrationCallback callback)
                  throws IOException
Registers the specified path for the specified owner. Invokes the callback with the result of the registration.

Parameters:
id - the owner of the path
path - the relative path from the webapp root directory
callback - the callback to invoke with the result of the registration
Throws:
IOException - if the callback invocation throws an IOException

getOwner

public String getOwner(String path)
Returns the owner of the specified path. If the file is not registered, returns null

Parameters:
path - the relative path from the webapp root directory
Returns:
the owner or null.

getOwners

public Set getOwners()
Returns the owners. Note that this the returned Set may be inconsistent since it represents a persistent cache across multiple invocations.

For instance, if an overlay was removed in this execution, it will be still be there till the cache is cleaned. This happens when the clean mojo is invoked.

Returns:
the list of owners

getFullStructure

public PathSet getFullStructure()
Returns all paths that have been registered so far.

Returns:
all registered path

getStructure

public PathSet getStructure(String id)
Returns the list of registered files for the specified owner.

Parameters:
id - the owner
Returns:
the list of files registered for that owner

analyseDependencies

public void analyseDependencies(WebappStructure.DependenciesAnalysisCallback callback)
Analyze the dependencies of the project using the specified callback.

Parameters:
callback - the callback to use to report the result of the analysis

registerTargetFileName

public void registerTargetFileName(Artifact artifact,
                                   String targetFileName)
Registers the target file name for the specified artifact.

Parameters:
artifact - the artifact
targetFileName - the target file name

getCachedTargetFileName

public String getCachedTargetFileName(Dependency dependency)
Returns the cached target file name that matches the specified dependency, that is the target file name of the previous run.

The dependency object may have changed so the comparison is based on basic attributes of the dependency.

Parameters:
dependency - a dependency
Returns:
the target file name of the last run for this dependency


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.