java.lang.Object
nextapp.echoservlet.util.PeerFactory
- All Implemented Interfaces:
- java.io.Serializable
- public class PeerFactory
- extends java.lang.Object
- implements java.io.Serializable
Generates "peer" objects for objects based on associations.
Associations are stored in a properties files, where the keys are the fully
qualified class names of objects and the values are the fully qualified
class names of their peers. When an object is passed to the createPeer()
method its peer will be returned based on the bindings in the properties file.
An objects superclass(es) will also be tested for available peers if none is
available for the derived class. If no peer is found, a PeerFactoryException
is thrown.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
associations
private java.util.Map associations
- A map of associations
PeerFactory
public PeerFactory()
- Creates a new
PeerFactory.
PeerFactory
public PeerFactory(java.lang.String propertiesFile)
throws PeerFactory.PeerFactoryException
- Creates a new
PeerFactory with initial associations.
addAssociation
public void addAssociation(java.lang.String className,
java.lang.String peerClassName)
- Adds a single peer binding.
addAssociations
public void addAssociations(java.lang.String propertiesFile)
throws PeerFactory.PeerFactoryException
- Loads peer bindings. Invoking this method will result in the new
associations supplementing existing associations. Existing associations
will not be removed. If two associations have the same key, the most
recently added one will be used.
createPeer
public java.lang.Object createPeer(java.lang.Object object)
throws PeerFactory.PeerFactoryException
- Instantiates a new peer for the specified object by invoking its
default constructor.
getPeerClass
public java.lang.Class getPeerClass(java.lang.Class objectClass)
throws PeerFactory.PeerFactoryException
- Returns the peer class associated for the given object class.