The Component-Watch tool describes the components and structure of java programs. It is based on the six following concepts:
Those five concepts maps to the five main tabs of the Component-Watch tool.
The tool GUI
The Component-Watch tool is composed of
- A title bar: showing the current project title
- A tabbed pane: showing list of available object (project, components, classes, jars, rules, diagrams)
- A detail view: showing the selected object. The detail view allows, in addition, to browse between objects (usually using the View button)
Note: the list and detail view are read-only. Any edition must be triggered by a toolbar button (or the edit button in some detail view) and is performed in a separate popup window.
The project tab
The Project tab shows the status of the currently open project. If a project is opened, the tab shows a list of messages describing project status. This list contains at least one information message showing the number of components defined in the project.
After an analysis, this list shows the number of classes in the classpath plus all warnings/errors encountered.
When you select a row in the message list, the associated object is shown in the right details pane.
The project details
The project details view shows the following fields
- Name: The project name (mandatory)
- Description: a textual description of the project
- Analysed classes: A name matcher selecting all the classes that should be analysed. An analysed class is parsed by the tool during analysis to find all outgoing references to other classes. So, for the non-analysed classes you will only see the incoming references from the analysed classes.
- Ignored classes: A name matcher selecting all the classes that should be totally ignored. Ignored means that references to those classes are not even mentioned in the tool. This matcher is initialised to include by default all the core java classes (pattern is 'java*') because it's not really interesting to know that such or such component references 'java.lang.string' or 'java.util.Date'. But, if you want, you can change it to watch references to sensitive core API (like java.lang.Thread, java.lang.reflect.* ...)
- Jar files location: either Directory or Maven
If you choose Directory as location, you should provide a base directory and the tool will analyse all the jar files found under this directory (recursively).
- Base directory: The directory where the jar files to analyse are located. If the provided path is relative, the directory is resolved relatively to the Root directory for analyse global setting (available from menu Action/edit settings)
If you choose Maven as location, the tool will get the jar to analyse from your local maven repository. Ensure that the Maven repository directory global setting (available from menu Action/edit settings) is correctly set.
- Maven root projects: The names of maven root project to analyse in the form groupid:artifactid:version (for example 'org.apache.ant:ant:1.8.2'). The tool will analyse those projects and recursively all their dependencies present in the local repository.
- Ignored Maven projects: A name matcher selecting maven project to skip during the recursive resolution of maven project dependencies. The matcher also uses the groupid:artifactid:version form to denote maven projects.
The components and diagrams of the project are shown as sub-list in the project details for completeness but the content of those two lists is the same as the content of the list in the "Component" and "Diagrams" main tabs.
As you might have guessed from its name, the component is the central object in the tool. It is the base block used to build the project.
Each component has a unique name and a type. The type is any string (by default "component") allowing categories of components (like "layer", "subsystem", "interface", "sub-component"...).
The component is used in two ways:
- As a set of classes: those classes will be parsed to define components references.
- As a set of sub-components: This is used to express the application structure.
The two can be combined (but it is rarely the case).
The components tab
The "Components" tab shows the list of all components defined in the project.
After an analysis, the analysed components (those containing analysed classes) are shown in black, while the non-analysed components (not containing an analysed class) are shown in grey.
The component definition
The component definition is the set of field of the component object that can be edited. They are grouped in the "Definition" tab of the Component details view. All other fields of the component are calculated during analysis and, hence, are read-only.
The "Definition" tab of component details view shows the following fields
- Component name: The unique component name (mandatory)
- Component type: The component type (mandatory)
- Description: a textual description of the component
- Classes: A name matcher selecting all the classes that are part of the component. All classes selected here are direct content of the component. The same class cannot be direct content of two different components (this result in an analysis error) but it can belong indirectly (as a class of a sub-component) to more than one component.
- Exported classes: A name matcher selecting all the classes that are exported by the component. If a class (or interface) is exported, it means that other component can reference it. If it is internal, then other component cannot use it. It is like public/private but at a higher level. This name matcher is applied to direct content of the component (i.e. the result of previous matcher) and not on the entire class set.
- Sub-components: A name matcher selecting the sub-components of this component. Grouping components into bigger components allow defining structure of a program. Typical grouping components are: layers, silos, subsystems, tiers, plug-ins...
A component can have several parents (i.e. the parent-child relation has a n-m cardinality).
- Forbidden refs.: A name matcher selecting the components that cannot be referenced from this one. Forbidden references are often expressed at the level of grouping components, so they apply for all their sub-components. For example if I say that layer "A" cannot reference layer "B", it means that none of the sub-components of layer "A" can reference a sub-component of layer "B" (because this implies that layer "A" references layer "B").
The component calculated fields.
The fields outside the "Definition" tab of the component details view show the result of the analysis and are not editable. Those fields show the state of the component and its link to other components & classes. All links can be browsed by clicking on the View button or double-clicking in the lists.
- In the details view header
- Is analysed: true if the component is analysed = if it contains at least one analysed class.
- Direct class count: Count of classes that are directly owned by this components
- Sub-component class count: Count of classes that are owned by all the sub-components (recursively) of this component.
- Accessing internal classes: true if this component does references to classes of other components that are marked as 'internal'. In this case, an error is also reported in the project message list.
- Do forbidden references: true if this component does forbidden references to other components. In this case, an error is also reported in the project message list.
- In the parent/child tab
- Parents: List of all the components that are direct parent of this one.
- Children: List of all the components that are direct child of this one.
- In the Component refs. tab
- Referenced: List of all the components that are referenced by this one.
- Referencing: List of all the components that are referencing this one.
- In the Classes tab
- Component classes: List of all the classes owned by this component.
- In the Class Refs. tab
- Referenced: List of all the classes that are referenced by this component.
- Referencing: List of all the classes that are referencing this component.