net.sf.farrago.catalog
Class MockMetadataFactory

java.lang.Object
  extended by org.eigenbase.jmi.mem.JmiMemFactory
      extended by net.sf.farrago.catalog.MockMetadataFactory
Direct Known Subclasses:
MockFarragoMetadataFactory.FactoryImpl

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:

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/catalog/MockMetadataFactory.java#15 $

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
MockMetadataFactory()
           
 
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

MockMetadataFactory

public MockMetadataFactory()
Method Detail

initRelationshipMap

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.