Jump to: navigation, search

Difference between revisions of "MoDisco/ModelFilter"

(Install)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The goal of the ModelFilter plug-in is to extract specific information from java projects, and to show it as UML models.
+
The goal of the '''ModelFilter''' plug-in is to extract specific information from java projects, and to show it as UML models.
  
First application is to initialize a dependencies graph from one selected element, the level of recursion has been provided as a parameter.
+
* First application is to initialize a graph of dependencies from one selected element, with the level of recursion provided as a parameter.
 +
* Second application is to show method calls as a pseudo sequence diagram using dependencies between methods, numbered from 1 to n to indicate the order.
 +
* Third application is to represent the real type of properties when an interface has been used in java code.
  
Second application is to show method calls as a pseudo sequence diagram, using dependencies between methods, numbered from one to n to indicate the order.
+
=Description=
  
Third application is to represent real type of properties when an interface has been used in java code.
+
To discover an application, you may use [[MoDisco/SimpleTransformationChain|SimpleTransformationsChain]] to obtain a UML model which represents the whole application structure. Or you may use the '''ModelFilter''' plug-in to focus on different aspects. It could be represented by little models dedicated to one element, or a complete model but with added information. Depending on the complexity of the application and resulting UML model, you will have to select a different kind of model.
 
+
=Description=
+
  
To discover an application, you may use SimpleTransformationsChain to obtain a UML model which represents the whole application structure. Or you may use the ModelFilter plug-in to focus on different aspects. It could be represented by little models dedicated to one element, or a complete model but with added informations. Depending on the complexity of the application and resulted UML model, you will have to select one or other kind of model.
+
The dependencies graph is clearly well fitted to show how several little models could be useful. Representation of method calls as a pseudo sequence could be done by little models or by one complete model; it has been implemented as one model to show how different diagrams have to be used to mask complexity of model elements. And representation of real type for properties show how a complete model could be improved with a few details.
The dependencies graph is clearly well fitted to show how several little models could be useful. Representation of method calls as pseudo sequence could be done by little models or by one complete model, it has been implemented as one model to show how different diagrams have to be used to mask complexity of model elements. And representation of real type for properties show how a complete model could be improved with few details.
+
  
 
==Dependencies graph==
 
==Dependencies graph==
  
From a selected class in a java application, you choose the recursion level of dependencies search and you will get a UML model which represents a dependencies graph from selected class. Structural links, like association, inheritance, etc. are of course available, but we have added UML dependencies to show local use of a type, or method parameters. It is very useful to detect qualified type usage or type in same package usage.
+
From a selected class in a java application, you choose the recursion level of the search for dependencies and you will get a UML model which represents a dependencies graph from the selected class. Structural links, like association, inheritance, etc. are of course available, but we have added UML dependencies to show local uses of a type, or method parameters. It is very useful to detect usage of qualified types or usage of a type in the same package.
  
[[Image:MoDisco_Dependencies_ClassDiagram_MapBeanSample.jpg|center|Sample of target UML model with local and method parameters dependencies.]]
+
[[Image:MoDisco_DependenciesOfMapBean_PrefuseGraph.png|frame|center|Sample dependencies graph with local and method parameter dependencies.]]
  
 
==Method calls==
 
==Method calls==
  
To represent method calls as pseudo sequence, we will use UML dependencies from one method (caller) to other methods (called), each dependency has been named with name of called method suffixed by a number which represent its order in sequence of method calls.
+
To represent method calls as pseudo sequence, we use UML dependencies from one method (caller) to other methods (callee). Each dependency is named with the name of the called method suffixed by a number which represents its order in the sequence of method calls.
  
[[Image:MoDisco_MethodCalls_MapBeanSample_UmlDiagramView.jpg|center|Sample of target UML model with method calls as dependencies.]]
+
[[Image:MoDisco_PetStore_MapBean_MethodCalls_PrefuseGraph.png|frame|center|Sample method calls graph]]
  
 
==Real type of properties==
 
==Real type of properties==
  
When the type of a property is an interface, it is interesting to represent its real type dependency in a UML model.
+
When the type of a property is an interface, it is interesting to represent its real type as a dependency in a UML model:
  
 
[[Image:MoDisco_RealType_BidirectionalAssociation_UmlDiagramView.jpg|center|Sample of target UML model with real types as dependencies.]]
 
[[Image:MoDisco_RealType_BidirectionalAssociation_UmlDiagramView.jpg|center|Sample of target UML model with real types as dependencies.]]
 
=Requirements=
 
 
Eclipse Galileo with modeling plugins:
 
* EMF
 
* EMF UML2
 
* UML2 Tools
 
* ATL 3.0.0
 
 
For advanced users in modeling, we advice to use [http://www.papyrusuml.org/ Papyrus] modeler instead of UML2 Tools.
 
 
A complete bundle of Modeling components could be found at this url :  [http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/R/eclipse-modeling-galileo-incubation-win32.zip Eclipse Modeling Galileo Bundle]
 
 
Warning : after installation, you will have to change your eclipse settings (file eclipse.ini) to increase memory size allowed to 1Go at least, parameter « -Xmx1024m ».
 
 
Example :
 
-startup
 
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
 
--launcher.library
 
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
 
-product
 
org.eclipse.epp.package.modeling.product
 
--launcher.XXMaxPermSize
 
256M
 
-showsplash
 
org.eclipse.platform
 
--launcher.XXMaxPermSize
 
256m
 
-vmargs
 
-Dosgi.requiredJavaVersion=1.5
 
-Xms40m
 
-Xmx1024m
 
-XX:ThreadStackSize=4096
 
 
=Team=
 
 
Gabriel Barbier ([http://www.mia-software.com Mia-Software])
 
 
=Install=
 
 
To install this plugin, you will have to retrieve it and its dependencies from [http://wiki.eclipse.org/MoDisco/SVN MoDisco SVN].
 
All following bundles are available in folder "plugins/trunk":
 
 
* org.eclipse.gmt.modisco.usecase.modelfilter
 
* org.eclipse.gmt.modisco.kdm.uml2converter
 
* org.eclipse.gmt.modisco.j2se5
 
* org.eclipse.gmt.modisco.j2se5.discoverer
 
* org.eclipse.gmt.modisco.kdm
 
* org.eclipse.gmt.modisco.common.core
 
  
 
=User manual=
 
=User manual=
  
To illustrate ModelFilter plugin and its features, we will use a sample inspired from the [http://java.sun.com/developer/technicalArticles/J2EE/petstore/ Pet Store Application].
+
To illustrate the ModelFilter plugin and its features, we will use a sample inspired from the [http://java.sun.com/developer/technicalArticles/J2EE/petstore/ Pet Store Application].
  
 
==Get and install use case==
 
==Get and install use case==
  
The models are available from [http://wiki.eclipse.org/MoDisco/SVN MoDisco SVN (how to...)] in subdirectory "examples/trunk/org.eclipse.gmt.modisco.usecase.modelfilter.sample" or from downloadable archive. If you use a SVN client in eclipse (Subversive or Subclipse), the project will be immediately available in your Eclipse workspace.
+
The models are available from the [http://wiki.eclipse.org/MoDisco/SVN MoDisco SVN] in subdirectory "examples/trunk/org.eclipse.gmt.modisco.usecase.modelfilter.sample" or from a downloadable archive. If you use a SVN client in Eclipse (Subversive or Subclipse), the project will be immediately available in your Eclipse workspace.
 +
 
 +
Sources of the Pet Store application are  available here: http://www.oracle.com/technetwork/java/petstore1-3-1-02-139690.html
  
Sources of [http://java.sun.com/developer/technicalArticles/J2EE/petstore/ Pet Store application] are  available from [https://blueprints.dev.java.net/servlets/ProjectDocumentList?folderID=5315&expandFolder=5315&folderID=0 Sun downloads].
 
 
You may have to download several libraries to obtain an eclipse project without errors (JPA, JTA, JSF-apis and Servlets-jsp-apis).
 
You may have to download several libraries to obtain an eclipse project without errors (JPA, JTA, JSF-apis and Servlets-jsp-apis).
 
A complete bundle is also available from [http://www.mia-software.com/html/miaStudio/download/modisco/examples/javapetstore-2.0-ea5.zip Mia-Software...]
 
A complete bundle is also available from [http://www.mia-software.com/html/miaStudio/download/modisco/examples/javapetstore-2.0-ea5.zip Mia-Software...]
To view this application in your Eclipse workspace, you will have to extract content of this archive, and use the "import" wizard (import project in workspace).
+
To view this application in your Eclipse workspace, you will have to extract the content of this archive, and use the "import" wizard (import project in workspace).
  
 
==Dependencies graph==
 
==Dependencies graph==
  
To get the dependencies graph of a particular class, you have to select it in package explorer. Then in contextual menu, navigate in "Modelplex Use Cases" menu, click on "Create Dependencies model from selected java class" menu item.
+
To get the dependencies graph of a particular class, you have to right-click on the class in the '''Package Explorer''', and select '''Discovery > Actions > Display Dependencies'''
  
[[Image:MoDisco_Dependencies_ContextualMenu.jpg|center|Contextual menu entry for Modelplex use cases.]]
+
[[Image:MoDisco_PetStore_MapBean_DisplayDependencies.png|frame|center|Contextual menu entry for '''Display Dependencies''']]
  
Then, you will have a simple UML model dedicated to dependencies graph presentation.
+
Then, a graph displaying the dependencies will open:
  
[[Image:MoDisco_Dependencies_ClassDiagram_MapBeanSample_CenterView.jpg|center|Sample of target UML model with local dependencies.]]
+
[[Image:MoDisco_DependenciesOfMapBean_PrefuseGraph.png|frame|center|Dependencies graph]]
  
 
==Method calls==
 
==Method calls==
  
Nota: to represent method calls from a selected method, we have to use a modeler which is able to show dependencies between methods, these methods being in classes located in different packages. Then, following diagrams have been created with [http://www.papyrusuml.org/ Papyrus] and not with UML2 Tools.
+
Right-click on a project and select '''Discovery > Actions > Display Method Calls'''. A graph displaying all the method calls will open:
  
To get the UML model with method calls, select the java project you would like to inspect. Then in contextual menu, navigate in "Modelplex Use Cases" menu, click on "Create uml model with method calls" menu item.
+
[[Image:MoDisco_PetStore_MethodCalls_PrefuseGraph.png|frame|center|All method calls]]
  
[[Image:MoDisco_MethodCalls_ContextualMenu.jpg|center|Contextual menu entry for Modelplex use cases.]]
+
You will have a better look if we focus on a particular method. For example, the method <source lang="java">public List<SelectItem> getCategories()</source> in class MapBean located in package com.sun.javaee.blueprints.petstore.mapviewer.
  
Then, you will have a complete UML model instrumented with dependencies to represent method calls.
+
<source lang="java">
 
+
[[Image:MoDisco_MethodCalls_MapBeanSample_UmlModelView.jpg|center|Sample of target UML model with specific dependencies.]]
+
 
+
You will have a better look if we focus on a particular method. For example, the method <source lang="java">public List<SelectItem> getCategories()</source> in class MapBean located in package com.sun.javaee.blueprints.petstore.mapviewer.
+
<source lang="java">// mapAll.jsp
+
 
     public List<SelectItem> getCategories() {
 
     public List<SelectItem> getCategories() {
 
         // return categories for a JSF radio button
 
         // return categories for a JSF radio button
Line 134: Line 80:
 
     }</source>
 
     }</source>
  
[[Image:MoDisco_MethodCalls_MapBeanSample_UmlDiagramView.jpg|center|A diagram build with Papyrus to show method calls from method "getCategories".]]
+
Right-click on the method in the '''Package Explorer''', and select '''Discovery > Actions > Display Method Calls''':
  
==Real type of properties==
+
[[Image:MoDisco_DisplayMethodCalls_PetStore_MapBean_getCategories.png|frame|center|Displaying method calls from a single method]]
  
Nota: to represent real type of properties, we have to use a modeler which is able to show dependencies between an association and a class, these elements being located in different packages. Then, following diagrams have been created with [http://www.papyrusuml.org/ Papyrus] and not with UML2 Tools.
+
[[Image:MoDisco_PetStore_MapBean_MethodCalls_PrefuseGraph.png|center|A graph displaying method calls from method "getCategories"]]
 +
 
 +
==Real type of properties==
  
To get the UML model with real type of properties, select the java project you would like to inspect. Then in contextual menu, navigate in "Modelplex Use Cases" menu, click on "Create uml model with real types information on associations" menu item.
+
To get the UML model with real type of properties, right-click on the java project you would like to inspect, and select '''Discovery > Discoverers > Create UML model with real types information on associations''':
  
[[Image:MoDisco_RealType_ContextualMenu.jpg|center|Contextual menu entry for Modelplex use cases.]]
+
[[Image:MoDisco_CreateUMLModelWithRealTypesOnAssociations_menu.png|frame|center|Context menu item]]
  
Then, you will have a complete UML model instrumented with dependencies to represent method calls.
+
Then, you will have a complete UML model with the real types of Associations:
  
[[Image:MoDisco_Realtype_MapBeanSample_UmlModelView.jpg|center|Sample of target UML model with specific dependencies.]]
+
[[Image:MoDisco_PetStore_RealTypes_inModelBrowser.png|frame|center|UML model with real types of Associations]]
  
You will have a better look if we focus on a particular association. For example, the properties <source lang="java">private Collection<Item> items</source> in class Tag and <source lang="java">private Collection<Tag> tags</source> in class Item both located in package com.sun.javaee.blueprints.petstore.model.
+
You will have a better look if we focus on a particular association. For example, the properties  
 +
<source lang="java">
 +
private Collection<Item> items
 +
</source>
 +
in class Tag and  
 +
<source lang="java">
 +
private Collection<Tag> tags
 +
</source>
 +
in class Item both located in package com.sun.javaee.blueprints.petstore.model.
  
[[Image:MoDisco_RealType_BidirectionalAssociation_UmlDiagramView.jpg|center|A diagram build with Papyrus to show real types.]]
+
[[Image:MoDisco_RealType_BidirectionalAssociation_UmlDiagramView.jpg|center|A diagram built with Papyrus to show real types.]]
  
 
=Current limitations=
 
=Current limitations=
Line 156: Line 112:
 
==Dependencies graph==
 
==Dependencies graph==
  
* The dependencies gaph does not reflect some implicit dependencies, for example with embricated method calls:
+
* The dependencies gaph does not reflect some implicit dependencies, for example with nested method calls:
 
  <source lang="java">String entryPagesParam = filterConfig.getServletContext().getInitParameter("entryPages");</source>
 
  <source lang="java">String entryPagesParam = filterConfig.getServletContext().getInitParameter("entryPages");</source>
  
Line 168: Line 124:
 
* Diagrams have to be built manually with Papyrus
 
* Diagrams have to be built manually with Papyrus
 
* Initializations through parameters or local variable are not managed
 
* Initializations through parameters or local variable are not managed
* Initializations through method call are not managed
+
* Initializations through method calls are not managed
 +
 
 +
=Team=
 +
 
 +
Gabriel Barbier ([http://www.mia-software.com Mia-Software])
 +
 
 +
=Install=
 +
 
 +
You can [[MoDisco/Installation|install]] the discoverer from the MoDisco update site.
 +
 
 +
As part of the "Use cases layer" which is not embedded in MoDisco SDK, you cannot install it from eclipse or modeling update site. Please use MoDisco release update site.
  
 +
{{MoDisco}}
 
[[Category:MoDisco]]
 
[[Category:MoDisco]]

Latest revision as of 02:11, 19 August 2011

The goal of the ModelFilter plug-in is to extract specific information from java projects, and to show it as UML models.

  • First application is to initialize a graph of dependencies from one selected element, with the level of recursion provided as a parameter.
  • Second application is to show method calls as a pseudo sequence diagram using dependencies between methods, numbered from 1 to n to indicate the order.
  • Third application is to represent the real type of properties when an interface has been used in java code.

Description

To discover an application, you may use SimpleTransformationsChain to obtain a UML model which represents the whole application structure. Or you may use the ModelFilter plug-in to focus on different aspects. It could be represented by little models dedicated to one element, or a complete model but with added information. Depending on the complexity of the application and resulting UML model, you will have to select a different kind of model.

The dependencies graph is clearly well fitted to show how several little models could be useful. Representation of method calls as a pseudo sequence could be done by little models or by one complete model; it has been implemented as one model to show how different diagrams have to be used to mask complexity of model elements. And representation of real type for properties show how a complete model could be improved with a few details.

Dependencies graph

From a selected class in a java application, you choose the recursion level of the search for dependencies and you will get a UML model which represents a dependencies graph from the selected class. Structural links, like association, inheritance, etc. are of course available, but we have added UML dependencies to show local uses of a type, or method parameters. It is very useful to detect usage of qualified types or usage of a type in the same package.

Sample dependencies graph with local and method parameter dependencies.

Method calls

To represent method calls as pseudo sequence, we use UML dependencies from one method (caller) to other methods (callee). Each dependency is named with the name of the called method suffixed by a number which represents its order in the sequence of method calls.

Sample method calls graph

Real type of properties

When the type of a property is an interface, it is interesting to represent its real type as a dependency in a UML model:

Sample of target UML model with real types as dependencies.

User manual

To illustrate the ModelFilter plugin and its features, we will use a sample inspired from the Pet Store Application.

Get and install use case

The models are available from the MoDisco SVN in subdirectory "examples/trunk/org.eclipse.gmt.modisco.usecase.modelfilter.sample" or from a downloadable archive. If you use a SVN client in Eclipse (Subversive or Subclipse), the project will be immediately available in your Eclipse workspace.

Sources of the Pet Store application are available here: http://www.oracle.com/technetwork/java/petstore1-3-1-02-139690.html

You may have to download several libraries to obtain an eclipse project without errors (JPA, JTA, JSF-apis and Servlets-jsp-apis). A complete bundle is also available from Mia-Software... To view this application in your Eclipse workspace, you will have to extract the content of this archive, and use the "import" wizard (import project in workspace).

Dependencies graph

To get the dependencies graph of a particular class, you have to right-click on the class in the Package Explorer, and select Discovery > Actions > Display Dependencies

Contextual menu entry for Display Dependencies

Then, a graph displaying the dependencies will open:

Dependencies graph

Method calls

Right-click on a project and select Discovery > Actions > Display Method Calls. A graph displaying all the method calls will open:

All method calls
You will have a better look if we focus on a particular method. For example, the method
public List<SelectItem> getCategories()
in class MapBean located in package com.sun.javaee.blueprints.petstore.mapviewer.
    public List<SelectItem> getCategories() {
        // return categories for a JSF radio button
        ArrayList<SelectItem> arCats=new ArrayList<SelectItem>();
 
        // get the CatalogFacade for the app
        FacesContext context=FacesContext.getCurrentInstance();
        Map<String,Object> contextMap=context.getExternalContext().getApplicationMap();
        CatalogFacade cf=(CatalogFacade)contextMap.get("CatalogFacade");
 
        // get the categories from the database
        List<Category> catsx=cf.getCategories();
        for(Category catx : catsx) {
            // add categories to be displayed in a radio button
            arCats.add(new SelectItem(catx.getCategoryID(), catx.getName()));
        }
        return arCats;
    }

Right-click on the method in the Package Explorer, and select Discovery > Actions > Display Method Calls:

Displaying method calls from a single method
A graph displaying method calls from method "getCategories"

Real type of properties

To get the UML model with real type of properties, right-click on the java project you would like to inspect, and select Discovery > Discoverers > Create UML model with real types information on associations:

Context menu item

Then, you will have a complete UML model with the real types of Associations:

UML model with real types of Associations

You will have a better look if we focus on a particular association. For example, the properties

private Collection<Item> items

in class Tag and

private Collection<Tag> tags

in class Item both located in package com.sun.javaee.blueprints.petstore.model.

A diagram built with Papyrus to show real types.

Current limitations

Dependencies graph

  • The dependencies gaph does not reflect some implicit dependencies, for example with nested method calls:
String entryPagesParam = filterConfig.getServletContext().getInitParameter("entryPages");

Method calls

  • Diagrams have to be built manually with Papyrus
  • Method calls should be represented with a uml sequence diagram

Real type of properties

  • Diagrams have to be built manually with Papyrus
  • Initializations through parameters or local variable are not managed
  • Initializations through method calls are not managed

Team

Gabriel Barbier (Mia-Software)

Install

You can install the discoverer from the MoDisco update site.

As part of the "Use cases layer" which is not embedded in MoDisco SDK, you cannot install it from eclipse or modeling update site. Please use MoDisco release update site.


MoDisco
Components Infrastructure: KDM · SMM · GASTM · Model Browser · Discovery Manager · MoDisco Workflow · Query Manager · Facet Manager · Metrics Visualization Builder · KDM Source Extension
Technologies: Java · JEE · EjbJar · WebApp · XML
Use Cases: Simple Transformation Chain · Model Filter
Help Installation · SVN
Project API Policy · Retention Policy · Project Plan · metrics · Accessibility Guidelines · Capabilities Disablement