Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs.optional.ejb

public Class DescriptorHandler

extends HandlerBase
Class Inheritance
Imports
java.io.File, .IOException, .InputStream, java.net.MalformedURLException, .URL, java.nio.file.Files, java.util.Collections, .Hashtable, .Map, org.apache.tools.ant.Project, .Task, org.xml.sax.AttributeList, .HandlerBase, .InputSource, .SAXException

Deprecated

as a consequence of HandlerBase being deprecated. See corresponding docs for further information.

Inner class used by EjbJar to facilitate the parsing of deployment descriptors and the capture of appropriate information. Extends HandlerBase so it only implements the methods needed. During parsing creates a hashtable consisting of entries mapping the name it should be inserted into an EJB jar as to a File representing the file on disk. This list can then be accessed through the getFiles() method.

Field Summary

Modifier and TypeField and Description
private static final String
protected String
currentElement

Instance variable used to store the name of the current element being processed by the SAX parser.

protected String
currentText

The text of the current element

private static final int
private static final String
private static final String
private static final String
private static final String
EJB_REF

Bunch of constants used for storing entries in a hashtable, and for constructing the filenames of various parts of the ejb jar.

protected Hashtable<String, File>
ejbFiles

Instance variable that stores the names of the files as they will be put into the jar file, mapped to File objects Accessed by the SAX parser call-back method characters().

protected String
ejbName

Instance variable that stores the value found in the <ejb-name> element

private static final String
private static final String
private Map<String, File>
private static final String
private boolean
private static final String
private static final String
private static final String
private Task
private int
parseState

The state of the parsing

private static final String
private String
private static final String
private Map<String, String>
private static final String
private File
srcDir

The directory containing the bean classes and interfaces.

private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private Map<String, URL>

Constructor Summary

AccessConstructor and Description
public
DescriptorHandler(Task
the task that owns this descriptor
task
,
File
the source directory
srcDir
)

Constructor for DescriptorHandler.

Method Summary

Modifier and TypeMethod and Description
public void
characters(char[]
A character array containing all the characters in the element, and maybe others that should be ignored.
ch
,
int
An integer marking the position in the char array to start reading from.
start
,
int
An integer representing an offset into the char array where the current data terminates.
length
)

Overrides org.xml.sax.HandlerBase.characters.

Implements org.xml.sax.DocumentHandler.characters.

SAX parser call-back method invoked whenever characters are located within an element.
public void
endElement(String
The name of the attribute being exited. Ignored in this implementation.
name
)

Overrides org.xml.sax.HandlerBase.endElement.

Implements org.xml.sax.DocumentHandler.endElement.

SAX parser call-back method that is invoked when an element is exited.
public String

Returns:

the ejb name
getEjbName
()

Getter method that returns the value of the <ejb-name> element.

public Hashtable<String, File>

Returns:

the map of files
getFiles
()

Getter method that returns the set of files to include in the EJB jar.

public String

Returns:

the public id
getPublicId
()

Get the publicId of the DTD

protected void
processElement()

Called when an endelement is seen.

public void
registerDTD(String
the public identity of the dtd
publicId
,
String
the location of the dtd
location
)

Register a dtd with a location.

public InputSource

Returns:

an inputsource for this identifier
resolveEntity
(String
The public identifier, or null if none is available.
publicId
,
String
The system identifier provided in the XML document. Will not be null.
systemId
)

Overrides org.xml.sax.HandlerBase.resolveEntity.

Implements org.xml.sax.EntityResolver.resolveEntity.

Resolve the entity.
public void
startDocument()

Overrides org.xml.sax.HandlerBase.startDocument.

Implements org.xml.sax.DocumentHandler.startDocument.

SAX parser call-back method that is used to initialize the values of some instance variables to ensure safe operation.
public void
startElement(String
The name of the element being entered.
name
,
AttributeList
Attributes associated to the element.
attrs
)

Overrides org.xml.sax.HandlerBase.startElement.

Implements org.xml.sax.DocumentHandler.startElement.

Deprecated as a consequence of AttributeList being deprecated.
SAX parser call-back method that is invoked when a new element is entered into.
Inherited from org.xml.sax.HandlerBase:
endDocumenterrorfatalErrorignorableWhitespacenotationDeclprocessingInstructionsetDocumentLocatorunparsedEntityDeclwarning

Field Detail

BEAN_CLASSback to summary
private static final String BEAN_CLASS
currentElementback to summary
protected String currentElement

Instance variable used to store the name of the current element being processed by the SAX parser. Accessed by the SAX parser call-back methods startElement() and endElement().

currentTextback to summary
protected String currentText

The text of the current element

DEFAULT_HASH_TABLE_SIZEback to summary
private static final int DEFAULT_HASH_TABLE_SIZE
EJB_JARback to summary
private static final String EJB_JAR
EJB_LOCAL_REFback to summary
private static final String EJB_LOCAL_REF
EJB_NAMEback to summary
private static final String EJB_NAME
EJB_REFback to summary
private static final String EJB_REF

Bunch of constants used for storing entries in a hashtable, and for constructing the filenames of various parts of the ejb jar.

ejbFilesback to summary
protected Hashtable<String, File> ejbFiles

Instance variable that stores the names of the files as they will be put into the jar file, mapped to File objects Accessed by the SAX parser call-back method characters().

ejbNameback to summary
protected String ejbName

Instance variable that stores the value found in the <ejb-name> element

ENTERPRISE_BEANSback to summary
private static final String ENTERPRISE_BEANS
ENTITY_BEANback to summary
private static final String ENTITY_BEAN
fileDTDsback to summary
private Map<String, File> fileDTDs
HOME_INTERFACEback to summary
private static final String HOME_INTERFACE
inEJBRefback to summary
private boolean inEJBRef
LOCAL_HOME_INTERFACEback to summary
private static final String LOCAL_HOME_INTERFACE
LOCAL_INTERFACEback to summary
private static final String LOCAL_INTERFACE
MESSAGE_BEANback to summary
private static final String MESSAGE_BEAN
owningTaskback to summary
private Task owningTask
parseStateback to summary
private int parseState

The state of the parsing

PK_CLASSback to summary
private static final String PK_CLASS
publicIdback to summary
private String publicId
REMOTE_INTERFACEback to summary
private static final String REMOTE_INTERFACE
resourceDTDsback to summary
private Map<String, String> resourceDTDs
SESSION_BEANback to summary
private static final String SESSION_BEAN
srcDirback to summary
private File srcDir

The directory containing the bean classes and interfaces. This is used for performing dependency file lookups.

STATE_IN_BEANSback to summary
private static final int STATE_IN_BEANS
STATE_IN_EJBJARback to summary
private static final int STATE_IN_EJBJAR
STATE_IN_ENTITYback to summary
private static final int STATE_IN_ENTITY
STATE_IN_MESSAGEback to summary
private static final int STATE_IN_MESSAGE
STATE_IN_SESSIONback to summary
private static final int STATE_IN_SESSION
STATE_LOOKING_EJBJARback to summary
private static final int STATE_LOOKING_EJBJAR
urlDTDsback to summary
private Map<String, URL> urlDTDs

Constructor Detail

DescriptorHandlerback to summary
public DescriptorHandler(Task task, File srcDir)

Constructor for DescriptorHandler.

Parameters
task:Task

the task that owns this descriptor

srcDir:File

the source directory

Method Detail

charactersback to summary
public void characters(char[] ch, int start, int length) throws SAXException

Overrides org.xml.sax.HandlerBase.characters.

Implements org.xml.sax.DocumentHandler.characters.

SAX parser call-back method invoked whenever characters are located within an element. currentAttribute (modified by startElement and endElement) tells us whether we are in an interesting element (one of the up to four classes of an EJB). If so then converts the classname from the format org.apache.tools.ant.Parser to the convention for storing such a class, org/apache/tools/ant/Parser.class. This is then resolved into a file object under the srcdir which is stored in a Hashtable.

Parameters
ch:char[]

A character array containing all the characters in the element, and maybe others that should be ignored.

start:int

An integer marking the position in the char array to start reading from.

length:int

An integer representing an offset into the char array where the current data terminates.

Annotations
@Override
Exceptions
SAXException:
on error
endElementback to summary
public void endElement(String name) throws SAXException

Overrides org.xml.sax.HandlerBase.endElement.

Implements org.xml.sax.DocumentHandler.endElement.

SAX parser call-back method that is invoked when an element is exited. Used to blank out (set to the empty string, not nullify) the name of the currentAttribute. A better method would be to use a stack as an instance variable, however since we are only interested in leaf-node data this is a simpler and workable solution.

Parameters
name:String

The name of the attribute being exited. Ignored in this implementation.

Annotations
@Override
Exceptions
SAXException:
on error
getEjbNameback to summary
public String getEjbName()

Getter method that returns the value of the <ejb-name> element.

Returns:String

the ejb name

getFilesback to summary
public Hashtable<String, File> getFiles()

Getter method that returns the set of files to include in the EJB jar.

Returns:Hashtable<String, File>

the map of files

getPublicIdback to summary
public String getPublicId()

Get the publicId of the DTD

Returns:String

the public id

processElementback to summary
protected void processElement()

Called when an endelement is seen. This may be overridden in derived classes. This updates the ejbfiles if the element is an interface or a bean class. This updates the ejbname if the element is an ejb name.

registerDTDback to summary
public void registerDTD(String publicId, String location)

Register a dtd with a location. The location is one of a filename, a resource name in the classpath, or a URL.

Parameters
publicId:String

the public identity of the dtd

location:String

the location of the dtd

resolveEntityback to summary
public InputSource resolveEntity(String publicId, String systemId) throws SAXException

Overrides org.xml.sax.HandlerBase.resolveEntity.

Implements org.xml.sax.EntityResolver.resolveEntity.

Resolve the entity.

Parameters
publicId:String

The public identifier, or null if none is available.

systemId:String

The system identifier provided in the XML document. Will not be null.

Returns:InputSource

an inputsource for this identifier

Annotations
@Override
Exceptions
SAXException:
if there is a problem.
See Also
org.xml.sax.EntityResolver#resolveEntity(String, String)
startDocumentback to summary
public void startDocument() throws SAXException

Overrides org.xml.sax.HandlerBase.startDocument.

Implements org.xml.sax.DocumentHandler.startDocument.

SAX parser call-back method that is used to initialize the values of some instance variables to ensure safe operation.

Annotations
@Override
Exceptions
SAXException:
on error
startElementback to summary
public void startElement(String name, AttributeList attrs) throws SAXException

Overrides org.xml.sax.HandlerBase.startElement.

Implements org.xml.sax.DocumentHandler.startElement.

Deprecated

as a consequence of AttributeList being deprecated. See corresponding docs for further information.

SAX parser call-back method that is invoked when a new element is entered into. Used to store the context (attribute name) in the currentAttribute instance variable.

Parameters
name:String

The name of the element being entered.

attrs:AttributeList

Attributes associated to the element.

Annotations
@Override
Exceptions
SAXException:
on error