net.sf.daileon
Class ResourcesFactory

java.lang.Object
  extended by net.sf.daileon.ResourcesFactory

public class ResourcesFactory
extends Object

The ResourcesFactory class is a static factory that retrieves a particular Strategy implementation, or a particular AbstractAnnotationsReplacer implementation.

One can define how the annotations that correspond to the domain annotations are organized. If they are organized in annotations, then it is possible to use the default implementation of the Strategy interface, which is the AnnotationsStrategy class. If no values are indicated in the <strategy-class> element of the XML configuration file, then the default implementation is used. However, if they are organized in other forms, such as XML files, or even database tables, then the fully-qualified name of this implementation has to be indicated in the XML configuration file.

The user can also define if the domain annotations will be either kept or not in the final bytecode. The framework provides two implementations for each situation, which are the DomainAnnotationsKeeper and the DomainAnnotationsDiscarder classes. However, the user may define situations where the domain annotations should be kept in the final bytecode. To do so, a class that extends the AbstractAnnotationsReplacer has to be built and indicated in the XML configuration file. If no values are indicated in the <domain-annotations-replacer> element of the XML configuration file, then the default implementation is used.

Version:
1.0 01/01/2010
Author:
Roberto Perillo

Field Summary
private static String DEFAULT_REPLACER
          The default class that extends the AbstractAnnotationsReplacer class.
private static String DEFAULT_STRATEGY
          The default implementation of the net.sf.daileon.notsupported.Strategy interface.
private static AbstractAnnotationsReplacer replacer
          A reference to the AbstractAnnotationsReplacer object, indicated in the XML configuration file
private static Strategy strategy
          A reference to the Strategy object, indicated in the XML configuration file
 
Constructor Summary
private ResourcesFactory()
          Default class constructor.
 
Method Summary
static AbstractAnnotationsReplacer getAnnotationsReplacer(org.objectweb.asm.ClassVisitor visitor)
          Returns the implementation that extends the AbstractAnnotationsReplacer.
static Strategy getAnnotationsTranslator()
          Returns the Strategy object, indicated in the XML configuration file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_STRATEGY

private static final String DEFAULT_STRATEGY
The default implementation of the net.sf.daileon.notsupported.Strategy interface. If no values are indicated in the <strategy-class> of the XML configuration file, this value is used by the getAnnotationsTranslator() method.

See Also:
Constant Field Values

DEFAULT_REPLACER

private static final String DEFAULT_REPLACER
The default class that extends the AbstractAnnotationsReplacer class. If no values are indicated in the <domain-annotations-replacer> of the XML configuration file, this value is used by the #getAnnotationsReplacer(ClassVisitor) method.

See Also:
Constant Field Values

strategy

private static Strategy strategy
A reference to the Strategy object, indicated in the XML configuration file


replacer

private static AbstractAnnotationsReplacer replacer
A reference to the AbstractAnnotationsReplacer object, indicated in the XML configuration file

Constructor Detail

ResourcesFactory

private ResourcesFactory()
Default class constructor. Has the private constructor, since the ResourcesFactory class is a static factory, and only its static methods should be used.

Method Detail

getAnnotationsTranslator

public static Strategy getAnnotationsTranslator()
Returns the Strategy object, indicated in the XML configuration file. This object identifies how to translate the domain annotations to their corresponding annotations. If no values are indicated in the XML configuration file, then the default implementation is returned.

Returns:
The Strategy implementation.
Throws:
RuntimeException - If the class provided in the XML configuration file cannot be instantiated.

getAnnotationsReplacer

public static AbstractAnnotationsReplacer getAnnotationsReplacer(org.objectweb.asm.ClassVisitor visitor)
Returns the implementation that extends the AbstractAnnotationsReplacer. This object defines whether the domain annotations should be kept or not in the code. If no values are indicated in the XML configuration file, then the default implementation is returned.

Parameters:
visitor - The ClassVisitor object, provided by the ClassTransformer.transform(String, String) method.
Returns:
The implementation of the AbstractAnnotationsReplacer class.
Throws:
RuntimeException - If the class provided in the XML configuration file cannot be instantiated.