org.jboss.deployers.vfs.spi.deployer
Class MultipleVFSParsingDeployer<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>
                  extended by org.jboss.deployers.vfs.spi.deployer.MultipleVFSParsingDeployer<T>
Type Parameters:
T - the expected type
All Implemented Interfaces:
Deployer, JarExtensionProvider, Ordered, FileMatcher
Direct Known Subclasses:
MultipleJBossXBDeployer

public abstract class MultipleVFSParsingDeployer<T>
extends AbstractVFSParsingDeployer<T>

Multiple VFS parsing deployer.

Author:
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
MultipleVFSParsingDeployer(Class<T> output, Map<String,Class<?>> mappings)
           
MultipleVFSParsingDeployer(Class<T> output, Map<String,Class<?>> mappings, String suffix, Class<?> suffixClass)
           
 
Method Summary
protected
<S> S
getInstance(Map<Class<?>,List<Object>> metadata, Class<S> clazz)
          Get single metadata instance from metadata.
 Map<String,Class<?>> getMappings()
          Get mappings.
 Class<?> getSuffixClass()
          Get suffix class.
protected  Class<?> matchFileToClass(DeploymentUnit unit, String fileName)
          Match file name to metadata class.
protected  Class<?> matchFileToClass(DeploymentUnit unit, String fileName, boolean throwException)
          Match file name mappings.
protected  Class<?> matchFileToClass(DeploymentUnit unit, org.jboss.virtual.VirtualFile file)
          Match file to mapping 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 abstract  T mergeMetaData(VFSDeploymentUnit unit, Map<Class<?>,List<Object>> metadata)
          Merge metadatas into single piece of metatdata
protected  T mergeMetaData(VFSDeploymentUnit unit, T root, Map<Class<?>,List<Object>> metadata, Set<String> missingFiles)
          Merge metadatas into single piece of metatdata
protected abstract
<U> U
parse(Class<U> expectedType, org.jboss.virtual.VirtualFile file, Object root)
          Parse file to produce expected class metadata.
protected  T parse(VFSDeploymentUnit unit, org.jboss.virtual.VirtualFile file, T root)
          Parse a deployment
 
Methods inherited from class org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer
accepts, accepts, allowsMultipleFiles, getAltMappings, getMetadataFile, handleMultipleFiles, init, isDeployable, openStreamAndValidate, parse, parse, parse, parse, parseAndInit, setAllowMultipleFiles
 
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

MultipleVFSParsingDeployer

public MultipleVFSParsingDeployer(Class<T> output,
                                  Map<String,Class<?>> mappings)

MultipleVFSParsingDeployer

public MultipleVFSParsingDeployer(Class<T> output,
                                  Map<String,Class<?>> mappings,
                                  String suffix,
                                  Class<?> suffixClass)
Method Detail

matchFileToClass

protected Class<?> matchFileToClass(DeploymentUnit unit,
                                    org.jboss.virtual.VirtualFile file)
Match file to mapping metadata class.

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

matchFileToClass

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

Overrides:
matchFileToClass in class AbstractVFSParsingDeployer<T>
Parameters:
unit - the deployment unit
fileName - the file name
Returns:
matching metadata class

matchFileToClass

protected Class<?> matchFileToClass(DeploymentUnit unit,
                                    String fileName,
                                    boolean throwException)
Match file name mappings.

Parameters:
unit - the deployment unit
fileName - the file name
throwException - should we throw an exception if no match found
Returns:
match or null or IllegalArgumentException

parse

protected T parse(VFSDeploymentUnit unit,
                  org.jboss.virtual.VirtualFile file,
                  T root)
           throws Exception
Description copied from class: AbstractVFSParsingDeployer
Parse a deployment

Specified by:
parse in class AbstractVFSParsingDeployer<T>
Parameters:
unit - the deployment unit
file - the metadata file
root - - possibly null pre-existing root
Returns:
the metadata
Throws:
Exception - for any error

parse

protected abstract <U> U parse(Class<U> expectedType,
                               org.jboss.virtual.VirtualFile file,
                               Object root)
                    throws Exception
Parse file to produce expected class metadata. Root doesn't have U signature, since it conflicts with its usage in the parse(VFSDeployment unit, VirtualFile file, T root) method.

Type Parameters:
U - the expect type
Parameters:
expectedType - the expected class
file - the file to parse
root - the previous root
Returns:
new metadata instance
Throws:
Exception - for any error

mergeFiles

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

Overrides:
mergeFiles in class AbstractVFSParsingDeployer<T>
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

mergeMetaData

protected T mergeMetaData(VFSDeploymentUnit unit,
                          T root,
                          Map<Class<?>,List<Object>> metadata,
                          Set<String> missingFiles)
                   throws Exception
Merge metadatas into single piece of metatdata

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

mergeMetaData

protected abstract T mergeMetaData(VFSDeploymentUnit unit,
                                   Map<Class<?>,List<Object>> metadata)
                            throws Exception
Merge metadatas into single piece of metatdata

Parameters:
unit - the unit
metadata - the metadatas
Returns:
merged metadata
Throws:
Exception - for any error

getInstance

protected <S> S getInstance(Map<Class<?>,List<Object>> metadata,
                            Class<S> clazz)
Get single metadata instance from metadata.

Type Parameters:
S - the metadata type
Parameters:
metadata - the metadatas map
clazz - metadata class
Returns:
matching metadata instance

getMappings

public Map<String,Class<?>> getMappings()
Get mappings.

Returns:
the mappings

getSuffixClass

public Class<?> getSuffixClass()
Get suffix class.

Returns:
the suffix mathing class


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