PageBox |
|
|
|
|
|
Presentation | User guide | Token API | Active naming | Extensions | Implementation | Token implementation |
Implementation of the PageBox APIForewordObjectiveThis document presents the implementation of the PageBox API. AudienceProgrammers who want:
PrincipleWhen it installs an archive, PageBox
The PageBox working directory contains four files of interest for the PageBox API:
The archive calls the PageBox API constructor with the archive directory as parameter. Then the PageBox API reads API.txt to find the PageBox working directory. Next the PageBox API reads and parses the rules.xml, mode.txt and pbArchives.xml files and can process the requests of the archive. DesignThe PageBox API is made of two classes:
The PageBoxAPI is implemented in the PageBoxLib package. APIImpl.javagetAPIAPIImpl defines an APIs static Map that contains an entry for each PageBox on the Application server. APIs keys are PageBox working directories and APIs values are APIImpl instances. getAPI retrieves the working directory from the archive’s API.txt and returns the corresponding instance of APIImpl from APIs if it exists. Otherwise getAPI creates an APIImpl instance and stores this instance in APIs. APIImplThe APIImpl constructors
getLoggetLog returns the logging object retrieved by the APIImpl constructor. getConnectionAPIImpl maintains an ArrayList of JDBC connections called pool. Each connection is represented by a PoolEntry object. The PoolEntry class implements the Connection interface:
busy is true when the connection conn is used by an archive. Connection methods call the corresponding method of the embedded conn object except the close and isClosed methods we present below. PoolEntryThe PoolEntry constructor gets a new connection from the Driver Manager. locklock returns false when the connection is used by an archive (busy == true). Otherwise lock sets busy to true and returns true. releaseunlock closes the conn connection. getConnection enumerates the pool entries. For each PoolEntry getConnection calls its lock method and returns the entry if lock returns true. If all connections are used getConnection creates a new PoolEntry and returns this new entry. closeclose sets the connection in auto commit mode and set the busy variable to false. isClosedisClosed returns true is the connection is not used (busy == false) or if the connection is closed. relConnectionsrelConnection removes the APIImpl entry from the APIs map and calls the relConns method. The static version of relConnections retrieves the working directory from the archive’s API.txt, removes the corresponding instance of APIImpl from APIs and calls the relConns method. relConnsrelConns enumerates the PoolEntry objects in pool and calls their release method. Then relConns clears the pool ArrayList. getResourcegetResource first looks in the allowedResources map to check if the archive is granted permission to use the resource. If the archive doesn’have the permission getResource returns null. Otherwise getResource returns the ResourceInfo object from the resources map. getExtensiongetExtension has three parameters:
getExtension first looks in the allowedExtensions map to check if the archive is granted permission to use the extension. If the archive doesn’have the permission getExtension returns null. Otherwise getExtension
Like the extension class ExtensionImpl implements the ExtensionIF interface:
ExtensionImpls calls the call method of the extension class in privileged code. getClonesgetClones calls the GetSubscribers method of the RepoQuery Web service of the Repository that deployed the archive. GetSubscribers returns an array made of the URLs of the Deploy Web services of the PageBoxes where the archive was installed. Then for each PageBox where the archive was installed getClones calls the getArchPath method of the PageBox Deploy Web service. Eventually getClones returns an array of archive full URL that contains:
getResourceUsagegetResourceUsage calls UsageFactory.getUsageProbe to get a resource probe if it is not yet instantiated and then calls the collect and init methods of this probe. Resource probes and UsageFactory are described in the Resource probes section of the porting guide. GetResourceUsage is called by the homonymous method of PageBoxAPI. relInactiveConnsrelInactiveConns is called by relInactiveConnections. relInactiveConns enumerates the connections (PoolEntry objects) in the APIImpl pool and calls their isInactive method. When isInactive returns true relInactiveConns removes the connection from the pool. PoolEntry.isInactive checks if the connection was not used for more than a timeout. If this is the case PoolEntry.isInactive closes the connection. relInactiveConnectionsThe DynDns thread periodically calls this static method with the PageBox directory, which uniquely defines the PageBox as parameter. relInactiveConnections enumerates the APIImpl instances of this PageBox and calls their relInactiveConns method.
Contact:support@pagebox.net |
|