Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

nextapp.echoservlet.util
Class PeerFactory  view PeerFactory download PeerFactory.java

java.lang.Object
  extended bynextapp.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.


Nested Class Summary
 class PeerFactory.PeerFactoryException
          An exception used to describe a problem that was encountered loading a peer object.
 
Field Summary
private  java.util.Map associations
          A map of associations
 
Constructor Summary
PeerFactory()
          Creates a new PeerFactory.
PeerFactory(java.lang.String propertiesFile)
          Creates a new PeerFactory with initial associations.
 
Method Summary
 void addAssociation(java.lang.String className, java.lang.String peerClassName)
          Adds a single peer binding.
 void addAssociations(java.lang.String propertiesFile)
          Loads peer bindings.
 java.lang.Object createPeer(java.lang.Object object)
          Instantiates a new peer for the specified object by invoking its default constructor.
 java.lang.Class getPeerClass(java.lang.Class objectClass)
          Returns the peer class associated for the given object class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

associations

private java.util.Map associations
A map of associations

Constructor Detail

PeerFactory

public PeerFactory()
Creates a new PeerFactory.


PeerFactory

public PeerFactory(java.lang.String propertiesFile)
            throws PeerFactory.PeerFactoryException
Creates a new PeerFactory with initial associations.

Method Detail

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.