com.plumtree.openfoundation.util
Class XPDynamicDiscovery

java.lang.Object
  extended bycom.plumtree.openfoundation.util.XPDynamicDiscovery

public final class XPDynamicDiscovery
extends java.lang.Object

Given a set of class objects, and an interface type, the methods of this class will iterate through the set of available classes and return an instantiated array of classes that implement the given interface.


Constructor Summary
XPDynamicDiscovery()
           
 
Method Summary
static java.lang.Object[] GetInstancesFromLib(java.lang.String pathName, java.lang.String interfaceJARFileName, java.lang.String classesJARFileName, java.lang.String interfaceName)
          This method takes a war file or a jar file, iterates through that file and instantiates all classes of type represented by interfaceName.
static java.lang.Object[] GetInstancesFromXML(java.lang.String XMLFilePath, java.lang.String JARFolderPath)
          This method takes an XML file and a WAR/web home path/or a .Net/bin path.
static java.lang.Object GetObject(java.lang.String fullyQualifiedClassName, java.lang.String assemblyName)
          This method returns an instantiated class object, given a fully-qualified class name and the path to a jar or zip file which must contain its binary implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPDynamicDiscovery

public XPDynamicDiscovery()
Method Detail

GetInstancesFromLib

public static final java.lang.Object[] GetInstancesFromLib(java.lang.String pathName,
                                                           java.lang.String interfaceJARFileName,
                                                           java.lang.String classesJARFileName,
                                                           java.lang.String interfaceName)
This method takes a war file or a jar file, iterates through that file and instantiates all classes of type represented by interfaceName.

Parameters:
pathName - The location (directory or WAR file) of the jar file, i.e. "com\\plumtree\\openfoundation\\util\\test\\help\\RTSI" (use XPFileSystemObject.GetPathSeparator() in place of \\). or if it's a war file, the pathname should have ".war" as an extension (For example: "/opt/plumtree/ellington/SunOS/ptportal/5.0/webapp/portal.war"
interfaceJARFileName - This parameter is only used by the .NET version of the class, which refers to the interface assembly file. For consistency, its value may refer to the jar file, if any, where the interface represented by interfaceName resides.
classesJARFileName - The jar file wherein all classes to be instantiated reside. Will be appended to the pathName to for the fully-qualified path.
interfaceName - Interface name qualified by the package i.e. "com.plumtree.uiinfrastructure.web.IVarPack"
Returns:
Object[] An array of instantiated class objects from the given jar file that implement the provided interface

GetInstancesFromXML

public static final java.lang.Object[] GetInstancesFromXML(java.lang.String XMLFilePath,
                                                           java.lang.String JARFolderPath)
This method takes an XML file and a WAR/web home path/or a .Net/bin path. It looks up the interface assembly name, interface name, class name(s), specified in the xml file as nodes, iterates through the interface assembly to instantiate all classes listed in the xml file that are of type interface, returns an object array with all the instantiated classes in the order they are specified in the xml file. interface - interface name that all returned class objects implements class - fully-qualified name of the class to check if it implements the interface interfaceassembly - in Java, refers to jar file wherein all classes to be instantiated reside; in .Net, refers to the interface assembly file

Parameters:
XMLFilePath - Path to xml file (eg. com\\plumtree\\openfoundation\\util\\test\\help\\config.xml),
JARFolderPath - The jar file wherein all classes to be instantiated reside (eg. com\\plumtree\\openfoundation\\util\\test\\dynamicdiscoverytest\\Assembly), or the location of the war file, which has a ".war" extension (eg. com\\plumtree\\openfoundation\\util\\test\\dynamicdiscoverytest\\Assembly\\testWar.war)
Returns:
Object[] An array of instantiated class objects listed in the xml file that implement the specified interface in the interface assembly file

GetObject

public static java.lang.Object GetObject(java.lang.String fullyQualifiedClassName,
                                         java.lang.String assemblyName)
This method returns an instantiated class object, given a fully-qualified class name and the path to a jar or zip file which must contain its binary implementation. If the assembly file is a WAR file, the current implementation will assume that the class is already available in the classloader made available by the runtime environment (for example, an application server). The class should have a public no-argument constructor.

Parameters:
fullyQualifiedClassName - The fully-qualified class name, i.e. "com.plumtree.openfoundation.util.XPDynamicDiscovery"
assemblyName - Name of the JAR file in which the desired class is found, extension optional if a .jar, e.g. "openfoundation" or "uiinfrastructure". In .NET it is interpreted as the AssemblyName. In Java it will be used to attempt to create a URLClassLoader over the named jar file, including filesystem path information if provided, and falling back to the system classloader (classpath) if unsuccessful. The assumed cross-platform practice is that there will be an application binary/library directory containing the application which uses Open Foundation as well as any plug-in libraries referred to by GetObject().
Returns:
Object A single instance of the desired class


Copyright 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.