com.sun.jmitck.vendorwrapper
Interface Generator


public interface Generator

Interface for interacting with the code generation features of different vendors' implementations of JMI.

These methods are necessary for the TCK to gain access to objects, for which JMI has not specified the means of access.


Method Summary
 RefPackage createRefPackage(java.lang.String packageName, java.lang.String prefix)
          Returns a new RefPackage, returning a unique identifier, which can be used to access the new RefPackage.
 XmiReader createXmiReader()
          Return an object which implements the XmiReader interface.
 com.sun.javatest.Status generate(java.lang.String metamodel, java.lang.String xmiImportPath, boolean interfacesOnly)
          Generate the code corresponding to the named metamodel.
 java.lang.String getMetamodelLoadPath(java.lang.String metamodel)
          Returns the classpath required for the generated code.
 void init(java.util.Properties p, java.io.File rootDir)
          Perform any required iniialization of the generator.
 void retire(RefPackage refPackage)
          Clean-up after a list of RefPackage instances, after completion of a test.
 

Method Detail

init

public void init(java.util.Properties p,
                 java.io.File rootDir)
Perform any required iniialization of the generator.

Parameters:
p - properties loaded from a properties file, if provided by the vendor (may be null)
rootDir - the root directory for the Javatest execution

generate

public com.sun.javatest.Status generate(java.lang.String metamodel,
                                        java.lang.String xmiImportPath,
                                        boolean interfacesOnly)
Generate the code corresponding to the named metamodel. This method must load the XMI file corresponding to the metamodel name, and generate the corresponding byte code according to the JMI specification.

Parameters:
metamodel - a fully-qualified name of the metamodel, which will correspond to an XMI file in the metamodels directory
interfacesOnly - true, when only the interfaces, enum classes, and exceptions specified by the JMI need be generated. When false, the implementation of those interfaces must also be geneated.
Returns:
a Status instance, set to either passed, if code generation completed, or to error, if not.

getMetamodelLoadPath

public java.lang.String getMetamodelLoadPath(java.lang.String metamodel)
Returns the classpath required for the generated code. This method only needs to create the classpath if the classpath of generated code changes from one generation execution to the next. For instance, if the implemention places the generated code in a jar file named after the metamodel, this method would be invoked. The choice whether this method is invoked or not is controlled by a configuration parameter set in the configuration editor.

Parameters:
metamodel - the fully-qualified name of the metamodel (the same name that is passed in to the generate method).
Returns:
a classpath, using the classpath separators appropriate for the current platform

createRefPackage

public RefPackage createRefPackage(java.lang.String packageName,
                                   java.lang.String prefix)
Returns a new RefPackage, returning a unique identifier, which can be used to access the new RefPackage.

Parameters:
packageName - the name of the Model.Package defining the RefPackage
prefix - the package prefix used in code generation (as defined by a tag in the metamodel)
Returns:
a unique identifier, which can be used to retrieve the new RefPackage.

createXmiReader

public XmiReader createXmiReader()
Return an object which implements the XmiReader interface.

Returns:
a XmiReader value

retire

public void retire(RefPackage refPackage)
Clean-up after a list of RefPackage instances, after completion of a test. An implementation is given the oportunity to remove objects created in the extents as the result of the test, or perform any other useful cleanup. No action is necessary; however, cleanup activities may avoid issues such as running out of memory, failing subsequent tests due to a previous test failure that corrupts an extent, etc.