attrib4j
Class AttributeFactory

java.lang.Object
  |
  +--attrib4j.AttributeFactory
Direct Known Subclasses:
BCELFactory, CFParseFactory

public abstract class AttributeFactory
extends java.lang.Object

Factory for creating ClassAnnotator and AttributeExtractor instances, with discovery and configuration features similar to that employed by standard Java APIs such as JAXP. Current implementations are based on IBM CFParse and Jakarta's BCEL bytecode manipulation libraries.

Note:These classes are not used by client code. The factory does not create 'Attribute' instances. Attributes can be any serializable class and are independent of which bytecode manipulation library is used.

Implementation taken from the jakarata commons logging package.

Version:
$Revision: 1.5 $ $Date: 2003/04/10 03:36:16 $
Author:
Mark Pollack

Field Summary
protected static java.util.Hashtable factories
          The previously constructed AttributeFactory instances, keyed by the ClassLoader with which it was created.
static java.lang.String FACTORY_DEFAULT
          The fully qualified class name of the fallback AttributeFactory implementation class to use, if no other can be found.
static java.lang.String FACTORY_PROPERTIES
          The name of the properties file to search for.
static java.lang.String FACTORY_PROPERTY
          The name of the property used to identify the AttributeFactory implementation class name.
protected static java.lang.String SERVICE_ID
          JDK1.3+ 'Service Provider' specification ( http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html )
 
Constructor Summary
protected AttributeFactory()
          Protected constructor that is not available for public use.
 
Method Summary
abstract  AttributeExtractor getAttributeExtractor()
          Method to return a AttributeExtractor.
abstract  ClassAnnotator getClassAnnotator(java.io.InputStream is, java.lang.String classfileName)
          Method to return a ClassAnnotator.
protected static java.lang.ClassLoader getContextClassLoader()
          Return the thread context class loader if available.
static AttributeFactory getFactory()
          Construct (if necessary) and return a AttributeFactory instance, using the following ordered lookup procedure to determine the name of the implementation class to be loaded.
protected static AttributeFactory newFactory(java.lang.String factoryClass, java.lang.ClassLoader classLoader)
          Return a new instance of the specified AttributeFactory implementation class, loaded by the specified class loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY_PROPERTY

public static final java.lang.String FACTORY_PROPERTY
The name of the property used to identify the AttributeFactory implementation class name.

See Also:
Constant Field Values

FACTORY_DEFAULT

public static final java.lang.String FACTORY_DEFAULT
The fully qualified class name of the fallback AttributeFactory implementation class to use, if no other can be found.

See Also:
Constant Field Values

FACTORY_PROPERTIES

public static final java.lang.String FACTORY_PROPERTIES
The name of the properties file to search for.

See Also:
Constant Field Values

SERVICE_ID

protected static final java.lang.String SERVICE_ID
JDK1.3+ 'Service Provider' specification ( http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html )

See Also:
Constant Field Values

factories

protected static java.util.Hashtable factories
The previously constructed AttributeFactory instances, keyed by the ClassLoader with which it was created.

Constructor Detail

AttributeFactory

protected AttributeFactory()
Protected constructor that is not available for public use.

Method Detail

getFactory

public static AttributeFactory getFactory()
                                   throws AttributeException

Construct (if necessary) and return a AttributeFactory instance, using the following ordered lookup procedure to determine the name of the implementation class to be loaded.

Throws:
AttributeException - if the implementation class is not available or cannot be instantiated.

getAttributeExtractor

public abstract AttributeExtractor getAttributeExtractor()
                                                  throws AttributeException
Method to return a AttributeExtractor.

Throws:
AttributeException - if a suitable AttributeExtractor instance cannot be returned

getClassAnnotator

public abstract ClassAnnotator getClassAnnotator(java.io.InputStream is,
                                                 java.lang.String classfileName)
                                          throws AttributeException
Method to return a ClassAnnotator.

Parameters:
classfileName - the name of the .class file.
Returns:
a value of type 'ClassAnnotator'
Throws:
AttributeException - if a suitable AttributeFactor instance cannot be returned

getContextClassLoader

protected static java.lang.ClassLoader getContextClassLoader()
                                                      throws AttributeException
Return the thread context class loader if available. Otherwise return null. The thread context class loader is available for JDK 1.2 or later, if certain security conditions are met.

Throws:
AttributeException - if a suitable class loader cannot be identified.

newFactory

protected static AttributeFactory newFactory(java.lang.String factoryClass,
                                             java.lang.ClassLoader classLoader)
                                      throws AttributeException
Return a new instance of the specified AttributeFactory implementation class, loaded by the specified class loader. If that fails, try the class loader used to load this (abstract) AttributeFactory.

Parameters:
factoryClass - Fully qualified name of the AttributeFactory implementation class
classLoader - ClassLoader from which to load this class
Throws:
AttributeException - if a suitable instance cannot be created


Copyright © 2002-2003 Mark Pollack. All Rights Reserved.