Components:
Pruner

The Pruner Component

The Pruner component can be used to remove all structures (architecture structures), types, and version graphs that are not part of a selected architecture found in a xADL document. The algorithm used in the Pruner component traverses through the architectural elements hierarchicaly and discovers which elements are not linked up to architecture and need to be "pruned." The algorithm achieves this by taking a starting element, either a type or structure, and then hierarchically visiting each of the structures' architectural elements (components, connectors, and interfaces) and inspecting those elements' corresponding types as well as visiting the substructure (if any) of all component types and connector types. Any elements not visited in this fashion are removed from the document. Ultimately, this results in an architecture that consists only of architectural elements that can be reached by traveling hierarchically down the architecture from the specified starting element. Additionally, the pruner removes any version graph whose internal nodes are not referenced by any type included in the selected architecture. The entire document is cloned before pruning so that the pruning is performed on a copy of the document. For more information on xADL documents, visit the xADL 2.0 website.

The diagram below gives a simple illustration on what the Pruner component does to an architecture. The architecture on the left hand side includes a structure containing components A, B, and C. The architecture also contains the components' respective types (links to these types are shown with dotted arrows) as well as two extraneous types, component types D, and E. The resulting architecture after the pruning operation was performed (seen on the right) looks just like the original architecture; however, the extraneous types are removed. Also, supposing component type E had internal substructure its substructure would be removed too (not shown in diagram). Please click on the image to enlarge in a separate window.

This component could be used, for example, after an architecture has been run through the Selector component. The larger architecture will only have a subset selected from it and the unselected types and structures will then be removed after being run through the Pruner. Please refer to the Selector Driver component for instructions on how to use the Selector and Pruner components through a convenient GUI.


Using the Pruner

In order to use the Pruner component, it is necessary to create and fire off a PerformArchPrunerMessage within the component that wishes to make use of the Pruner service. The PerformArchPrunerMessage constructor is defined as follows:

PerformArchPrunerMessage

public PerformArchPrunerMessage(String archURL,
               String targetArchURL, String componentID,
               String startingID, boolean isStructural)
Parameters:
archURL - This is the URL of the xADL document that needs to be pruned
targetArchURL - This is the URL of the new xADL document that will be created and store the pruned architecture
componentID - ID of the component creating the message. This allows the requesting component to selectively listen in on the progress messages sent out by the Pruner component. This field can be null.
startingID - This is the ID of the element that the pruning algorithm should start from
isStructural - If this is true then the startingID is that of an archStruct, otherwise it is an ID to a type

The PerformArchPrunerMessage should be sent up the ArchStudio architecture. The following code demonstrates this:

/*
 * Create a PerformArchPrunerMessage message.
 * Assumes that arguments used exist and were
 * already assigned appropriately.
 */

PerformArchPrunerMessage pruneMessage =
  new PerformArchPrunerMessage(archURL, targetURL,
  componentID, startingID, isStructural);

// Send request up to the Pruner's bottom Iface
sendToAll(pruneMessage, topIface);

The Pruner component fires off ArchPrunerStatusMessage messages to indicate the progress of the "pruning." These messages can be intercepted and used to keep track of the progress of the Pruner operations. The ArchPrunerStatusMessage message holds the following values that can be used for determining the state of a "prune" operation:

ArchPrunerStatusMessage

public ArchPrunerStatusMessage(String prunedArchURL,
   String componentID, int currentValue, int upperBound ,boolean isDone,
   boolean errorOccurred, Exception error)
Parameters:
prunedArchURL - The URL of the pruned/pruning document
componentID - ID of the component that sent off the PerformArchPrunerMessage to initiate the pruning. This field may be null
currentValue - Current value of progress
upperBound - Upper bound on progress value
isDone - Indicates whether or not the pruning process is done
errorOccurred - Indicates whether or not an error occurred
error - The error, if there was one, or null, if no error occurred. Refer to the list below for possible exceptions.
Exceptions:
InvalidURLException - This exception is thrown if the provided URL to open an xArch document is invalid.
MissingElementException - This exception is thrown if an expected element is missing.
BrokenLinkException - This exception is thrown if a link between elements does not match up or exist.
InvalidElementIDException - This exception is thrown if the provided starting ID is invalid.
MissingAttributeException - This exception is thrown if an expected attribute on an element is missing.

All of these values can be obtained through a simple get operation. For example, getPrunedArchURL() would get the prunedArchURL value, getComponentID() would get the componentID value, and so forth.


Questions about the Pruner should be sent to Christopher Van der Westhuizen.