Class WebappStructure
- java.lang.Object
-
- org.apache.maven.plugins.war.util.WebappStructure
-
public class WebappStructure extends java.lang.ObjectRepresents 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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceWebappStructure.RegistrationCallbackCallback interface to handle events related to filepath registration in the webapp.
-
Field Summary
Fields Modifier and Type Field Description private PathSetallFilesprivate java.util.List<DependencyInfo>dependenciesInfoprivate java.util.Map<java.lang.String,PathSet>registeredFiles
-
Constructor Summary
Constructors Constructor Description WebappStructure(java.util.List<org.apache.maven.model.Dependency> dependencies)Creates a new empty instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List<DependencyInfo>createDependenciesInfoList(java.util.List<org.apache.maven.model.Dependency> dependencies)private voiddoRegister(java.lang.String id, java.lang.String path)java.util.List<org.apache.maven.model.Dependency>getDependencies()Returns the dependencies of the project.java.util.List<DependencyInfo>getDependenciesInfo()Returns the list ofDependencyInfofor the project.PathSetgetFullStructure()Returns all paths that have been registered so far.java.lang.StringgetOwner(java.lang.String path)Returns the owner of the specifiedpath.java.util.Set<java.lang.String>getOwners()Returns the owners.PathSetgetStructure(java.lang.String id)Returns the list of registered files for the specified owner.booleanisRegistered(java.lang.String path)Specify if the specifiedpathis registered or not.private java.lang.ObjectreadResolve()booleanregisterFile(java.lang.String id, java.lang.String path)Registers the specified path for the specified owner.voidregisterFile(java.lang.String id, java.lang.String path, WebappStructure.RegistrationCallback callback)Registers the specified path for the specified owner.booleanregisterFileForced(java.lang.String id, java.lang.String path)Forces the registration of the specified path for the specified owner.voidregisterTargetFileName(org.apache.maven.artifact.Artifact artifact, java.lang.String targetFileName)Registers the target file name for the specified artifact.
-
-
-
Field Detail
-
registeredFiles
private java.util.Map<java.lang.String,PathSet> registeredFiles
-
dependenciesInfo
private java.util.List<DependencyInfo> dependenciesInfo
-
allFiles
private transient PathSet allFiles
-
-
Method Detail
-
getDependenciesInfo
public java.util.List<DependencyInfo> getDependenciesInfo()
Returns the list ofDependencyInfofor the project.- Returns:
- the dependencies information of the project
-
getDependencies
public java.util.List<org.apache.maven.model.Dependency> getDependencies()
Returns the dependencies of the project.- Returns:
- the dependencies of the project
-
isRegistered
public boolean isRegistered(java.lang.String path)
Specify if the specifiedpathis 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(java.lang.String id, java.lang.String path)Registers the specified path for the specified owner. Returnstrueif the path is not already registered,falseotherwise.- Parameters:
id- the owner of the pathpath- the relative path from the webapp root directory- Returns:
- true if the file was registered successfully
-
registerFileForced
public boolean registerFileForced(java.lang.String id, java.lang.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); returnstrueif an owner replacement was made andfalseif the file was simply registered for the first time.- Parameters:
id- the owner of the pathpath- 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(java.lang.String id, java.lang.String path, WebappStructure.RegistrationCallback callback) throws java.io.IOExceptionRegisters the specified path for the specified owner. Invokes thecallbackwith the result of the registration.- Parameters:
id- the owner of the pathpath- the relative path from the webapp root directorycallback- the callback to invoke with the result of the registration- Throws:
java.io.IOException- if the callback invocation throws an IOException
-
getOwner
public java.lang.String getOwner(java.lang.String path)
Returns the owner of the specifiedpath. If the file is not registered, returnsnull- Parameters:
path- the relative path from the webapp root directory- Returns:
- the owner or
null
-
getOwners
public java.util.Set<java.lang.String> getOwners()
Returns the owners.- 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(java.lang.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
-
registerTargetFileName
public void registerTargetFileName(org.apache.maven.artifact.Artifact artifact, java.lang.String targetFileName)Registers the target file name for the specified artifact.- Parameters:
artifact- the artifacttargetFileName- the target file name
-
doRegister
private void doRegister(java.lang.String id, java.lang.String path)
-
createDependenciesInfoList
private java.util.List<DependencyInfo> createDependenciesInfoList(java.util.List<org.apache.maven.model.Dependency> dependencies)
-
readResolve
private java.lang.Object readResolve()
-
-