org.jboss.deployers.vfs.spi.deployer
Class AbstractVFSParsingDeployer<T>

java.lang.Object
  extended by org.jboss.deployers.spi.deployer.helpers.AbstractDeployer
      extended by org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployer
          extended by org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput<T>
              extended by org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer<T>
Type Parameters:
T - the type of output
All Implemented Interfaces:
Deployer, JarExtensionProvider, Ordered, FileMatcher
Direct Known Subclasses:
AliasesParserDeployer, JAXBDeployer, ManifestDeployer, MultipleVFSParsingDeployer, Properties2BeansDeployer, UnmarshallerFactoryDeployer

public abstract class AbstractVFSParsingDeployer<T>
extends AbstractParsingDeployerWithOutput<T>
implements FileMatcher

AbstractVFSParsingDeployer.

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Ales Justin

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.deployers.spi.Ordered
Ordered.OrderedComparator
 
Field Summary
 
Fields inherited from class org.jboss.deployers.spi.deployer.helpers.AbstractDeployer
log
 
Fields inherited from interface org.jboss.deployers.spi.Ordered
COMPARATOR
 
Constructor Summary
AbstractVFSParsingDeployer(Class<T> output)
          Create a new AbstractVFSParsingDeployer.
 
Method Summary
protected  boolean accepts(DeploymentUnit unit)
          Callback to do prechecking on the deployment
protected  boolean accepts(VFSDeploymentUnit unit)
          Callback to do prechecking on the deployment
protected  boolean allowsMultipleFiles(List<org.jboss.virtual.VirtualFile> files)
          Check if we allow multiple files.
protected static Map<String,Class<?>> getAltMappings(DeploymentUnit unit)
          Get the alt mappings map.
protected  org.jboss.virtual.VirtualFile getMetadataFile(VFSDeploymentUnit unit, Class<?> altExpectedClass, String originalName, boolean checkMetaDataFile)
          Get metadata file.
protected  T handleMultipleFiles(VFSDeploymentUnit unit, T root, List<org.jboss.virtual.VirtualFile> files)
          Handle multiple files.
protected  void init(VFSDeploymentUnit unit, T metaData, org.jboss.virtual.VirtualFile file)
          Initialise the metadata
 boolean isDeployable(org.jboss.virtual.VirtualFile file)
          Check if file param is deployable.
protected  Class<?> matchFileToClass(DeploymentUnit unit, String fileName)
          Match file name to metadata class.
protected  T mergeFiles(VFSDeploymentUnit unit, T root, List<org.jboss.virtual.VirtualFile> files, Set<String> missingFiles)
          Merge files into one piece of metatdata
protected  InputStream openStreamAndValidate(org.jboss.virtual.VirtualFile file)
          Open stream and validate if not null.
protected  T parse(DeploymentUnit unit, Set<String> names, String suffix, T root)
          Parse exact file names or look for a suffix
protected  T parse(DeploymentUnit unit, Set<String> names, T root)
          Parse an multiple exact file names
protected  T parse(DeploymentUnit unit, String name, String suffix, T root)
          Parse an exact file name or look for a suffix
protected  T parse(DeploymentUnit unit, String name, T root)
          Parse an exact file name
protected abstract  T parse(VFSDeploymentUnit unit, org.jboss.virtual.VirtualFile file, T root)
          Parse a deployment
protected  T parseAndInit(VFSDeploymentUnit unit, org.jboss.virtual.VirtualFile file, T root)
          Parse the file, initialize the result if exists.
 void setAllowMultipleFiles(boolean allowMultipleFiles)
          Set allow multiple files.
 
Methods inherited from class org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput
allowsReparse, createMetaData, createMetaData, createMetaData, createMetaData, deploy, getAttachmentKey, getJarExtension, getMetaData, getName, getNames, getOutput, getSuffix, isBuildManagedObject, isIncludeDeploymentFile, setAttachmentKey, setBuildManagedObject, setIncludeDeploymentFile, setJarExtension, setName, setNames, setSuffix
 
Methods inherited from class org.jboss.deployers.spi.deployer.helpers.AbstractDeployer
addInput, addInput, addOutput, addOutput, getInput, getInputs, getOutputs, getRelativeOrder, getStage, isAllInputs, isComponentsOnly, isParentFirst, isTopLevelOnly, isWantComponents, setAllInputs, setComponentsOnly, setInput, setInputs, setInputs, setInputs, setOutput, setOutputs, setOutputs, setOutputs, setParentFirst, setRelativeOrder, setStage, setTopLevelOnly, setWantComponents, undeploy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractVFSParsingDeployer

public AbstractVFSParsingDeployer(Class<T> output)
Create a new AbstractVFSParsingDeployer.

Parameters:
output - the type of output
Throws:
IllegalArgumentException - for null output
Method Detail

isDeployable

public boolean isDeployable(org.jboss.virtual.VirtualFile file)
Description copied from interface: FileMatcher
Check if file param is deployable.

Specified by:
isDeployable in interface FileMatcher
Parameters:
file - the virtual file
Returns:
true if we have a match, false otherwise

accepts

protected boolean accepts(VFSDeploymentUnit unit)
                   throws DeploymentException
Callback to do prechecking on the deployment

Parameters:
unit - the unit
Returns:
true by default
Throws:
DeploymentException - for any error

accepts

protected boolean accepts(DeploymentUnit unit)
                   throws DeploymentException
Description copied from class: AbstractParsingDeployerWithOutput
Callback to do prechecking on the deployment

Overrides:
accepts in class AbstractParsingDeployerWithOutput<T>
Parameters:
unit - the unit
Returns:
true by default
Throws:
DeploymentException - for any error

openStreamAndValidate

protected InputStream openStreamAndValidate(org.jboss.virtual.VirtualFile file)
                                     throws Exception
Open stream and validate if not null.

Parameters:
file - the virtual file
Returns:
non-null input stream
Throws:
Exception - for any error or if file's stream is null

getAltMappings

protected static Map<String,Class<?>> getAltMappings(DeploymentUnit unit)
Get the alt mappings map.

Parameters:
unit - the deployment unit
Returns:
alt mappings map from attachments

getMetadataFile

protected org.jboss.virtual.VirtualFile getMetadataFile(VFSDeploymentUnit unit,
                                                        Class<?> altExpectedClass,
                                                        String originalName,
                                                        boolean checkMetaDataFile)
Get metadata file. First try altDD, then fallback to original name.

Parameters:
unit - the vfs deployment unit
altExpectedClass - the expected class of altDD
originalName - the original file name
checkMetaDataFile - should we fall back to metadata file
Returns:
metadata file or null if it doesn't exist

matchFileToClass

protected Class<?> matchFileToClass(DeploymentUnit unit,
                                    String fileName)
Match file name to metadata class.

Parameters:
unit - the deployment unit
fileName - the file name
Returns:
matching metadata class

parse

protected T parse(DeploymentUnit unit,
                  String name,
                  T root)
           throws Exception
Description copied from class: AbstractParsingDeployerWithOutput
Parse an exact file name

Specified by:
parse in class AbstractParsingDeployerWithOutput<T>
Parameters:
unit - the unit
name - the exact name to match
root - - possibly null pre-existing root
Returns:
the metadata or null if it doesn't exist
Throws:
Exception - for any error

parse

protected T parse(DeploymentUnit unit,
                  Set<String> names,
                  T root)
           throws Exception
Description copied from class: AbstractParsingDeployerWithOutput
Parse an multiple exact file names

Specified by:
parse in class AbstractParsingDeployerWithOutput<T>
Parameters:
unit - the unit
names - the exact names to match
root - - possibly null pre-existing root
Returns:
the metadata or null if it doesn't exist
Throws:
Exception - for any error

parse

protected T parse(DeploymentUnit unit,
                  String name,
                  String suffix,
                  T root)
           throws Exception
Description copied from class: AbstractParsingDeployerWithOutput
Parse an exact file name or look for a suffix

Specified by:
parse in class AbstractParsingDeployerWithOutput<T>
Parameters:
unit - the unit
name - the exact name to match
suffix - the suffix to match
root - - possibly null pre-existing root
Returns:
the metadata or null if it doesn't exist
Throws:
Exception - for any error

parseAndInit

protected T parseAndInit(VFSDeploymentUnit unit,
                         org.jboss.virtual.VirtualFile file,
                         T root)
                  throws Exception
Parse the file, initialize the result if exists.

Parameters:
unit - the deployment unit
file - the file
root - the root
Returns:
parsed result
Throws:
Exception - for any error

parse

protected T parse(DeploymentUnit unit,
                  Set<String> names,
                  String suffix,
                  T root)
           throws Exception
Description copied from class: AbstractParsingDeployerWithOutput
Parse exact file names or look for a suffix

Specified by:
parse in class AbstractParsingDeployerWithOutput<T>
Parameters:
unit - the unit
names - the exact names to match
suffix - the suffix to match
root - - possibly null pre-existing root
Returns:
the metadata or null if it doesn't exist
Throws:
Exception - for any error

mergeFiles

protected T mergeFiles(VFSDeploymentUnit unit,
                       T root,
                       List<org.jboss.virtual.VirtualFile> files,
                       Set<String> missingFiles)
                throws Exception
Merge files into one piece of metatdata

Parameters:
unit - the unit
root - possibly null pre-existing root
files - matching meta files
missingFiles - file names that are missing matching file
Returns:
merged metadata
Throws:
Exception - for any error

handleMultipleFiles

protected T handleMultipleFiles(VFSDeploymentUnit unit,
                                T root,
                                List<org.jboss.virtual.VirtualFile> files)
                         throws Exception
Handle multiple files.

Parameters:
unit - the vfs deployment unit
root - possibly null pre-existing root
files - the matching files
Returns:
null or merged single result
Throws:
Exception - for any error

allowsMultipleFiles

protected boolean allowsMultipleFiles(List<org.jboss.virtual.VirtualFile> files)
Check if we allow multiple files. Make sure you have deployers down the chain that will handle generated multiple attachments if this method returns true.

Parameters:
files - the matching files
Returns:
true if we allow, false otherwise

parse

protected abstract T parse(VFSDeploymentUnit unit,
                           org.jboss.virtual.VirtualFile file,
                           T root)
                    throws Exception
Parse a deployment

Parameters:
unit - the deployment unit
file - the metadata file
root - - possibly null pre-existing root
Returns:
the metadata
Throws:
Exception - for any error

init

protected void init(VFSDeploymentUnit unit,
                    T metaData,
                    org.jboss.virtual.VirtualFile file)
             throws Exception
Initialise the metadata

Parameters:
unit - the unit
metaData - the metadata
file - the metadata file
Throws:
Exception - for any error

setAllowMultipleFiles

public void setAllowMultipleFiles(boolean allowMultipleFiles)
Set allow multiple files.

Parameters:
allowMultipleFiles - the allow multiple files flag


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.