com.ibm.wsspi.anno.classsource
Interface ClassSource

All Known Subinterfaces:
ClassSource_Aggregate, ClassSource_ClassLoader, ClassSource_MappedContainer, ClassSource_MappedDirectory, ClassSource_MappedJar, ClassSource_MappedSimple

public interface ClassSource


Field Summary
static java.lang.String CLASS_EXTENSION
          Constant extension for class resource names.
static char CLASS_SEPARATOR_CHAR
          Constant class name separation character.
static char INNER_CLASS_SEPARATOR
          Constant for inner classes.
static char RESOURCE_SEPARATOR_CHAR
          Constant resource separation character.
static java.lang.String RESOURCE_SEPARATOR_STRING
          Constant resource separation string.
 
Method Summary
 void close()
          Close the class source.
 void closeClassStream(java.lang.String className, java.io.InputStream inputStream)
          Class the input stream which was opened for a specified class.
 void closeResourceStream(java.lang.String className, java.lang.String resourceName, java.io.InputStream inputStream)
          Class the input stream which was opened for a specified class.
 java.lang.String getCanonicalName()
          Answer the canonical name of the class source.
 int getClassExclusionCount()
          Answer the count of class resources which were excluded as duplicates resources for the same class.
 int getClassInclusionCount()
          Answer the count of class resources for distinct classes.
 java.lang.String getClassNameFromResourceName(java.lang.String resourceName)
          Convert a resource name to a class name.
 ClassSource_Factory getFactory()
          The factory used to create this class source.
 java.lang.String getHashText()
          A string representation of the class source suitable for logging.
 Util_InternMap getInternMap()
          Answer the string intern map of the class source.
 java.lang.String getName()
          A name for this class source.
 ClassSource getParentSource()
          Answer the parent of this class source.
 int getResourceExclusionCount()
          Answer the count of resources which were excluded from processing because they were not class resources.
 java.lang.String getResourceNameFromClassName(java.lang.String className)
          Convert a class name to a resource name.
 int getResult(ClassSource_ScanCounts.ResultField resultField)
          Answer a specific field from the scan results table.
 ClassSource_ScanCounts getScanResults()
          Answer statistics for a scan processing.
 java.lang.String inconvertResourceName(java.lang.String externalResourceName)
          Optional API for processing which uses an alternate form for resources.
 boolean isClassResource(java.lang.String resourceName)
          Tell if a specified resource is a class resource.
 boolean isDirectoryResource(java.lang.String resourceName)
          Tell if a specified resource is a directory resource.
 void log(com.ibm.websphere.ras.TraceComponent logger)
          Log state information for the class source to a specified logger.
 void logState()
          Log state information for the class source.
 void open()
          Open the class source for use.
 java.io.InputStream openClassStream(java.lang.String className)
          Open an input stream for a named class.
 java.io.InputStream openResourceStream(java.lang.String className, java.lang.String resourceName)
          Open an input stream for a named class which has a specified resource name.
 java.lang.String outconvertResourceName(java.lang.String internalResourceName)
          Optional API for processing which uses an alternate form for resources.
 java.lang.String resourceAppend(java.lang.String head, java.lang.String tail)
          Perform a resource append operation: This places a resource separator between the supplied values.
 void scanClasses(ClassSource_Streamer streamer, java.util.Set<java.lang.String> i_seedClassNamesSet, ClassSource_Aggregate.ScanPolicy scanPolicy)
          Entry point for scanning a class source which is a child of an aggregate class source.
 boolean scanReferencedClass(java.lang.String referencedClassNam, ClassSource_Streamer streamer)
          Required entry point for scans of referenced classes.
 boolean scanSpecificSeedClass(java.lang.String specificClassName, ClassSource_Streamer streamer)
          Alternate scan processing step: Perform scanning only on specific class.
 void setParentSource(ClassSource classSource)
          Set the parent of this class source.
 

Field Detail

RESOURCE_SEPARATOR_CHAR

static final char RESOURCE_SEPARATOR_CHAR

Constant resource separation character.

See Also:
Constant Field Values

RESOURCE_SEPARATOR_STRING

static final java.lang.String RESOURCE_SEPARATOR_STRING

Constant resource separation string.

See Also:
Constant Field Values

CLASS_SEPARATOR_CHAR

static final char CLASS_SEPARATOR_CHAR

Constant class name separation character.

See Also:
Constant Field Values

CLASS_EXTENSION

static final java.lang.String CLASS_EXTENSION

Constant extension for class resource names.

See Also:
Constant Field Values

INNER_CLASS_SEPARATOR

static final char INNER_CLASS_SEPARATOR

Constant for inner classes.

See Also:
Constant Field Values
Method Detail

getHashText

java.lang.String getHashText()

A string representation of the class source suitable for logging. The hash text should include a unique identifier (usually the base hash code of the class source) plus the most relevant descriptive information for the class source.

Returns:
A string representation of the class source suitable for logging.

logState

void logState()

Log state information for the class source.


log

void log(com.ibm.websphere.ras.TraceComponent logger)

Log state information for the class source to a specified logger. State information uses 'debug' log enablement.

Parameters:
logger - A logger which is to receive state information.

getFactory

ClassSource_Factory getFactory()

The factory used to create this class source. Other factory based objects created by the class source will use this factory.

Returns:
The factory used to create this class source.

getParentSource

ClassSource getParentSource()

Answer the parent of this class source. Answer null if none is set.

Returns:
The parent of this class source.

setParentSource

void setParentSource(ClassSource classSource)

Set the parent of this class source.

Parameters:
parent - The parent of this class source.

getName

java.lang.String getName()

A name for this class source.

The class source name is used as a unique ID when storing values to annotation targets. See com.ibm.wsspi.anno.targets.AnnotationTargets_Targets#getClassSourceNames().

When adding class sources to an aggregate, the names of the child class sources must be unique.

Returns:
A name for this class source.

getCanonicalName

java.lang.String getCanonicalName()

Answer the canonical name of the class source. All use of the class source uses the canonical name.

Returns:
The canonical name of the class source.
See Also:
ClassSource_Factory.getCanonicalName(String)

open

void open()
          throws ClassSource_Exception
Open the class source for use. This will open any underlying objects.

Throws:
ClassSource_Exception - Thrown if the class source could not be opened.

close

void close()
           throws ClassSource_Exception
Close the class source. Close any underlying objects.

Throws:
ClassSource_Exception - Thrown if the class source could not be closed.

getInternMap

Util_InternMap getInternMap()

Answer the string intern map of the class source.

Class sources intern all class names of scanned classes.

Returns:
The intern map of the class source.

scanClasses

void scanClasses(ClassSource_Streamer streamer,
                 java.util.Set<java.lang.String> i_seedClassNamesSet,
                 ClassSource_Aggregate.ScanPolicy scanPolicy)

Entry point for scanning a class source which is a child of an aggregate class source.

Parameters:
streamer - A selection and processing helper for the scan operation.
i_seedClassNamesSet - The accumulated seed class names.
scanPolicy - The scan policy of the class source (recorded by the parent).

getScanResults

ClassSource_ScanCounts getScanResults()

Answer statistics for a scan processing. (These are only available after scanning is complete.)

Returns:
Statistics for scan processing.

getResult

int getResult(ClassSource_ScanCounts.ResultField resultField)

Answer a specific field from the scan results table.

Parameters:
resultField - The scan results field which is to be retrieved.
Returns:
The value of the requested scan results field.

scanSpecificSeedClass

boolean scanSpecificSeedClass(java.lang.String specificClassName,
                              ClassSource_Streamer streamer)
                              throws ClassSource_Exception

Alternate scan processing step: Perform scanning only on specific class.

Parameters:
specificClassNamesThe - name of the class which is to be scanned.
streamer - A selection and processing helper for the scan operation.
Returns:
True if the streamer processed the class. Otherwise, false.
Throws:
ClassSource_Exception - Thrown in case of an error during scan processing.

scanReferencedClass

boolean scanReferencedClass(java.lang.String referencedClassNam,
                            ClassSource_Streamer streamer)
                            throws ClassSource_Exception

Required entry point for scans of referenced classes.

Parameters:
referencedClassNam - The names of a referenced classes which requires scanning.
streamer - A selection and processing helper for the scan operation.
Returns:
True if the streamer processed the class. Otherwise, false.
Throws:
ClassSource_Exception - Thrown in case of an error during scan processing.

resourceAppend

java.lang.String resourceAppend(java.lang.String head,
                                java.lang.String tail)

Perform a resource append operation: This places a resource separator between the supplied values.

Parameters:
head - The first value to put into the concatenated value.
tail - The second value to put into the concatenated value.
Returns:
The first value concatenated with a resource separator and with the second value.

isDirectoryResource

boolean isDirectoryResource(java.lang.String resourceName)

Tell if a specified resource is a directory resource. Resources which end with the resource separator are directory resources.

Parameters:
resourceName - The resource name to test.
Returns:
True if the resource is a directory resource. Otherwise, false.

isClassResource

boolean isClassResource(java.lang.String resourceName)

Tell if a specified resource is a class resource. A resource is a class resource if and only if it has the class extension.

Parameters:
resourceName - The resource which is to be tested.
Returns:
True if the resource is a class resource. Otherwise, false.

getClassNameFromResourceName

java.lang.String getClassNameFromResourceName(java.lang.String resourceName)

Convert a resource name to a class name. Conversion strips the class extension and converts all resource separators to class separators. Note that the inner class separator is not changed by the conversion.

Parameters:
resourceName - The resource to convert to a class name.
Returns:
The class name for the resource.

getResourceNameFromClassName

java.lang.String getResourceNameFromClassName(java.lang.String className)

Convert a class name to a resource name. Conversion changes the class separator to the resource separator and adds the class extension. The inner class separator is not changed by the conversion.

Parameters:
className - The class name to convert to a resource.
Returns:
The resource for the class name.

inconvertResourceName

java.lang.String inconvertResourceName(java.lang.String externalResourceName)

Optional API for processing which uses an alternate form for resources. For example, directory based processing may change the resource separator to a platform specific separator.

Parameters:
externalResourceName - The external form of the resource.
Returns:
The internal form of the resource.

outconvertResourceName

java.lang.String outconvertResourceName(java.lang.String internalResourceName)

Optional API for processing which uses an alternate form for resources. For example, directory based processing may change the resource separator to a platform specific separator.

Parameters:
internalResourceName - The internal form of the resource.
Returns:
The external form of the resource.

openClassStream

java.io.InputStream openClassStream(java.lang.String className)
                                    throws ClassSource_Exception

Open an input stream for a named class.

Note the distinct cases: If no resource is available for the class, answer null. If a resource is available but cannot be opened, throw an exception.

Parameters:
className - The name of the class for which to open an input stream.
Returns:
The input stream for the named class. Null if no resource is available for the class.
Throws:
ClassSource_Exception - Thrown in case a resource is available for the class, but that resource could not be opened.

openResourceStream

java.io.InputStream openResourceStream(java.lang.String className,
                                       java.lang.String resourceName)
                                       throws ClassSource_Exception

Open an input stream for a named class which has a specified resource name.

This code point is exposed to minimize class name to resource name conversion: Processing which prefers to use the resource name will generate a class name, but should not be forced to discard the resource name.

Note the distinct cases: If no resource is available for the class, answer null. If a resource is available but cannot be opened, throw an exception.

Parameters:
className - The name of the class for which to open an input stream.
Returns:
The input stream for the named class. Null if no resource is available for the class.
Throws:
ClassSource_Exception - Thrown in case a resource is available for the class, but that resource could not be opened.

closeClassStream

void closeClassStream(java.lang.String className,
                      java.io.InputStream inputStream)
                      throws ClassSource_Exception

Class the input stream which was opened for a specified class.

Parameters:
className - The class for which the input stream was opened.
inputStream - The input stream which is to be closed.
Throws:
ClassSource_Exception - Thrown in case the input stream could not be closed.

closeResourceStream

void closeResourceStream(java.lang.String className,
                         java.lang.String resourceName,
                         java.io.InputStream inputStream)
                         throws ClassSource_Exception

Class the input stream which was opened for a specified class.

This code point is exposed to minimize class name to resource name conversion: Processing which prefers to use the resource name will generate a class name, but should not be forced to discard the resource name.

Parameters:
className - The class for which the input stream was opened.
inputStream - The input stream which is to be closed.
Throws:
ClassSource_Exception - Thrown in case the input stream could not be closed.

getResourceExclusionCount

int getResourceExclusionCount()

Answer the count of resources which were excluded from processing because they were not class resources. This includes all container resources and all resources which do not have the class extension.

Returns:
The count of resources excluded from processing as non-class resources.
See Also:
isClassResource(String)

getClassExclusionCount

int getClassExclusionCount()

Answer the count of class resources which were excluded as duplicates resources for the same class. For example, an aggregate class source may contain a resource for the same class in two different child class sources. Only one of these is processed; the others are excluded and will contribute to the exclusion count.

Class resources skipping by the stream are not included in this count.

The class inclusion count plus the class exclusion count add up to the count of all class resources encountered during processing.

Classes from non-seed class sources are not included in either statistic.

Returns:
The count of class resources for duplicate classes.
See Also:
getClassInclusionCount(), isClassResource(String), ClassSource_Streamer#doProcess(String)

getClassInclusionCount

int getClassInclusionCount()

Answer the count of class resources for distinct classes. For example, an aggregate class source may contain a resource for the same class in two different child class sources. The class inclusion count is incremented just once for the entire set of duplicating class resources. The exclusion count is incremented once for each of the other duplicating class resources.

Class resources skipping by the stream are not included in this count.

Returns:
The count of class resources for distinct classes.
See Also:
getClassExclusionCount(), isClassResource(String), ClassSource_Streamer#doProcess(String)