net.sf.farrago.catalog
Class MockMetadataFactory
java.lang.Object
org.eigenbase.jmi.mem.JmiMemFactory
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:
- Each 'get' method is assumed to be an attribute.
- If the return type extends
RefClass
, a factory is created when
the object is initialized.
- If the return type extends
RefPackage
, a sub-package is created
when the object is initialized.
- If the return type extends
Collection
, a collection attribute is
created.
- All other types are presumed to be regular attributes.
- Version:
- $Id: //open/dev/farrago/src/net/sf/farrago/catalog/MockMetadataFactory.java#15 $
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 |
MockMetadataFactory
public MockMetadataFactory()
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.