Name
ClassFactory
Synopsis
JXTA class factories map abstract types to
their type. For example, the advertisement factory maps advertisement
types (e.g., jxta:PGA
) to the classes that
implement them (e.g.,
net.jxta.impl.protocol.PeerGroupAdv
). The
implementing class must have the same type as the factory returns
from the getClassOfInstantiators( )
method. The
type is usually a string, but generally must be the same type as that
returned from the getClassForKey( )
method.
The hashtable containing the mapping is
populated during initialization time. The
jxta.jar file contains a file
(config.properties) that contains the
information from which the ID and advertisement factories are
initialized. If you want to create your own class factory, you must
arrange for its association table to be populated when the factory is
first used. The table is populated by calling the
registerAssoc( )
method, which passes it the
appropriate key and value strings.
public abstract class ClassFactory { // Protected Constructors protected ClassFactory(); // Protected Instance Methods protected abstract java.util.Hashtable getAssocTable(); protected java.util.Enumeration getAvailableKeys(); protected abstract Class getClassForKey(); protected abstract Class getClassOfInstantiators(); protected Object getInstantiator(Object key) throws java.util.NoSuchElementException; protected boolean registerAssoc(String className) throws Exception; protected boolean registerAssoc(Object key, Object instantiator ...
Get JXTA in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.