Media Authoring
with Java API

tv.amwa.maj.industry
Class ClassDefinitionWarehouse

java.lang.Object
  extended by tv.amwa.maj.industry.ClassDefinitionWarehouse

public final class ClassDefinitionWarehouse
extends Object

Stores and provides access to class definitions, dynamically linking them to the underlying implementation if they are not yet known. If a fully specified class name is used to point to a class annotated as a AAF class, the set of classes supported by the API can be dynamically extended at runtime.

This class maintains an internal runtime cache of previously seen class definitions so that a runtime environment should have exactly one class definition per class in use.

Author:
Richard Cartwright
See Also:
ClassDefinition, AAFClass, AAFFactory.classDefinitionForName(java.lang.String), AAFFactory.classDefinitionForClass(java.lang.Class), makeClassDefinition()

Method Summary
static ClassDefinition forClass(Class<?> aafClass)
          For any given Java class, this method finds the corresponding AAF class definition or creates it if it does not yet exists within the current Java virtual machine.
static ClassDefinition forName(String name)
          Finds and returns a class definition for the given AAF class name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

forClass

public static final ClassDefinition forClass(Class<?> aafClass)
                                      throws NullPointerException,
                                             IllegalArgumentException

For any given Java class, this method finds the corresponding AAF class definition or creates it if it does not yet exists within the current Java virtual machine. The creation of class definitions is done by lazy evaluation as required using Java reflection and annotations. All generated values are cached in a local, static hashtable so that once generated, the work is not repeated.

The values returned by this method are only as good as the annotations provided with the sourcecode, as labelled using AAFClass and AAFProperty. If an AAFClass annotation is not present in the given class, an IllegalArgumentException is thrown. Any problems found with the AAFProperty annotations, such as two properties having the same name, will also result in an IllegalArgumentException.

Parameters:
aafClass - Java class to find the AAF class definition of.
Returns:
AAF class definition associated with the given Java class.
Throws:
NullPointerException - Argument is null.
IllegalArgumentException - The given Java class is not annotated with AAFClass or the AAFProperty annotations contain errors.
See Also:
AAFClass, AAFProperty, AAFFactory.classDefinitionForClass(java.lang.Class), ClassDefinition.forClass(java.lang.Class)

forName

public static final ClassDefinition forName(String name)
                                     throws NullPointerException,
                                            IllegalArgumentException

Finds and returns a class definition for the given AAF class name. Firstly, the search takes place using the class name specified in the AAF object specification and then by using a Java class name.

The search order used by this method is:

  1. Is the name an alias used in Java for an AAF class name in the specification? In which case, substitute the given Java-like name with the AAF alias. Look for the class in the current cache and, if present, return it.
  2. If the class name contains no path separator character, prepend MAJ API package names to the front of it and call Class.forName(String) followed by AAFFactory.classDefinitionForClass(Class) with the result. Return the value.
  3. If the given class name already contains a path separator, use it directly for a call to Class.forName(String) followed by AAFFactory.classDefinitionForClass(Class) with the result. Return the value.

Once the class has been located and linked into the running virtual machine, the forClass(Class) method is called.

Parameters:
name - Name of the class definition to find, specified using a name from the AAF object specification, a MAJ API class name or a fully qualified java class name.
Returns:
Class definition for the given name.
Throws:
NullPointerException - The given class name is null.
IllegalArgumentException - The given class name could not be resolved to an AAF class.
See Also:
Class.forName(java.lang.String)

Media Authoring
with Java API

(c) 2007-2008 Richard Cartwright, all rights reserved. Subject to the terms of the AAF SDK Public Source License.