Class MockMetadataFactory

  extended by org.eigenbase.jmi.mem.JmiMemFactory
      extended by net.sf.farrago.catalog.MockMetadataFactory
Direct Known Subclasses:

public abstract class MockMetadataFactory
extends JmiMemFactory

Helps create a mock implementation of an MDR metadata factory interface. Mock implementation of metadata factories which implements the MDR interfaces using dynamic proxies. Since this implementation does not persist objects, or even require a repository instance, it is ideal for testing purposes.

The name of the class is misleading; it is not itself a metadata factory. MockMetadataFactory uses dynamic proxies (see Proxy) to generate the necessary interfaces on the fly. Inside every proxy is an instance of JmiMemFactory.ElementImpl, which stores attributes in a HashMap and implements the InvocationHandler interface required by the proxy. There are specialized subtypes of ElementImpl for packages and classes.

Since there is no repository to provide metadata, the factory infers the object model from the Java interfaces:

$Id: //open/dev/farrago/src/net/sf/farrago/catalog/ $

Nested Class Summary
static class MockMetadataFactory.JmiPrinter
          Formats a JMI object as XML.
(package private) static class MockMetadataFactory.JmiVisitor
          Abstract base class for an iterator over a JMI object and its children.
Nested classes/interfaces inherited from class org.eigenbase.jmi.mem.JmiMemFactory
JmiMemFactory.ElementImpl, JmiMemFactory.MofPackageImpl, JmiMemFactory.RefAssociationImpl, JmiMemFactory.RefClassImpl, JmiMemFactory.RefPackageImpl
Constructor Summary
Method Summary
protected  void initRelationshipMap()
          Registers relationships which we want to be maintained as two-way relationships.
Methods inherited from class org.eigenbase.jmi.mem.JmiMemFactory
createImpl, createRelationship, createRelationship, defineMetaObject, getModelGraph, getPersistentMofId, getRootPackage, getRootPackageImpl, mapMofId, newRefPackage, newRootPackage, parseGetter, setPersistentMofId, sortMethods
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public MockMetadataFactory()
Method Detail


protected void initRelationshipMap()
Registers relationships which we want to be maintained as two-way relationships. This is necessary because we cannot deduce inverse relationships using Java reflection.

Derived classes can add override to define additional relationships.