CrossArtefact Information Retrieval - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

CrossArtefact Information Retrieval

Description:

motivation why do we need cross-artefact analysis. the tool s architecture. the database ... a Cross-Artefact Query. declare function EJBsWithCMT() as element ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 35
Provided by: stInforma
Category:

less

Transcript and Presenter's Notes

Title: CrossArtefact Information Retrieval


1
Cross-Artefact Information Retrieval
  • Michael Eichberg
  • Klaus Ostermann
  • Mira Mezini
  • Thorsten Schäfer

2
outline
  • motivation why do we need cross-artefact
    analysis
  • the tools architecture
  • the database
  • how to retrieve information introduction to
    XQuery
  • integration in Eclipse
  • Examplesdetecting bad smells / violations of
    best practices / errors

3
a Projects Artefacts are diverse
.properties
XML
Java
4
and the stored information is related
5
Are these two types related?
public interface Test extends EJBObject
String getText()
?
public class TestBean implements SessionBean
public String getText()
6
Are these two types related?
Yes!
public interface Test extends EJBObject
String getText()
?
public class TestBean implements SessionBean
public String getText()
Deployment Descriptor
ltenterprise-beansgt ltsessiongt ltejb-namegtHel
loWorldTestBeanlt/ejb-namegt lthomegtde.tud.xirc.pla
yground.TestHomelt/homegt ltremotegtde.tud.xirc.play
ground.Testlt/remotegt ltejb-classgtde.tud.xirc.play
ground.TestBeanlt/ejb-classgt ltsession-typegtStatel
esslt/session-typegt lttransaction-typegtContainerlt/
transaction-typegt lt/sessiongt lt/enterprise-beansgt
7
What is the transaction attribute?
ltenterprise-beansgt ltsessiongt ltejb-namegtHelloWor
ldTestBeanlt/ejb-namegt lthomegtde.tud.xirc.playgrou
nd.TestHomelt/homegt ltremotegtde.tud.xirc.playgroun
d.Testlt/remotegt ltejb-classgtde.tud.xirc.playgroun
d.TestBeanlt/ejb-classgt ltsession-typegtStatelesslt/
session-typegt lttransaction-typegtContainerlt/trans
action-typegt lt/sessiongt lt/enterprise-beansgt ltcont
ainer-transactiongt ltmethodgt ltejb-namegtHelloWorl
dTestBeanlt/ejb-namegt ltmethod-namegtgetTextlt/metho
d-namegt lt/methodgt lttrans-attributegtRequiredlt/tra
ns-attributegt lt/container-transactiongt
Java Code
public interface Test extends EJBObject
String getText() throws RemoteException Str
ing getValue() throws RemoteException String
getValue(int i) throws RemoteException String
getNoValue() throws RemoteException
Deployment Descriptor
8
What is the transaction attribute?
ltenterprise-beansgt ltsessiongt ltejb-namegtHelloWor
ldTestBeanlt/ejb-namegt lthomegtde.tud.xirc.playgrou
nd.TestHomelt/homegt ltremotegtde.tud.xirc.playgroun
d.Testlt/remotegt ltejb-classgtde.tud.xirc.playgroun
d.TestBeanlt/ejb-classgt ltsession-typegtStatelesslt/
session-typegt lttransaction-typegtContainerlt/trans
action-typegt lt/sessiongt lt/enterprise-beansgt ltcont
ainer-transactiongt ltmethodgt ltejb-namegtHelloWorl
dTestBeanlt/ejb-namegt ltmethod-namegtgetTextlt/metho
d-namegt lt/methodgt lttrans-attributegtRequiredlt/tra
ns-attributegt lt/container-transactiongt
ltenterprise-beansgt ltsessiongt ltejb-namegtHelloWor
ldTestBeanlt/ejb-namegt lthomegtde.tud.xirc.playgrou
nd.TestHomelt/homegt ltremotegtde.tud.xirc.playgroun
d.Testlt/remotegt ltejb-classgtde.tud.xirc.playgroun
d.TestBeanlt/ejb-classgt ltsession-typegtStatelesslt/
session-typegt lttransaction-typegtContainerlt/trans
action-typegt lt/sessiongt lt/enterprise-beansgt ltcont
ainer-transactiongt ltmethodgt ltejb-namegtHelloWorl
dTestBeanlt/ejb-namegt ltmethod-namegtgetTextlt/metho
d-namegt lt/methodgt lttrans-attributegtRequiredlt/tra
ns-attributegt lt/container-transactiongt
searching the deployment descriptor in the local
FS
Java Code
public interface Test extends EJBObject
String getText() throws RemoteException Str
ing getValue() throws RemoteException String
getValue(int i) throws RemoteException String
getNoValue() throws RemoteException
Deployment Descriptor
9
the Architecture of XIRC
Project Sources
.java .class
Query
.jar
XIRC XML-Database
.properties
.xml
10
the XML-Database (excerpt)
  • ltdball xmlnsdb"http//.../XMLDB(5/20/04)"gt
  • ltdbdocument type"source" documentID"file/D/.
    ../HelloWorld/bin/test/Test.class"
    tag"de.tud.xirc.processor.input.ClassFileInputPro
    cessor"gt
  • ltclass xmlns"http//.../BAT2-Java1.5(12/7/04)"
    name"test.Test" visibility"public" gt
  • ltinheritsgt ltclass name"java.lang.Object" /gt
    lt/inheritsgt
  • ltmethod name"ltinitgt" visibility"public" ...gt
  • ltsignaturegt ltreturns type"void" /gt lt/signaturegt
  • ltcodegt
  • ltload index"0" lineNumber"15" /gt
  • ltinvoke declaringClassName"java.lang.Object m
    ethodName"ltinitgt" specialMethod"true" ...gt
  • ltsignaturegt ltreturns type"void" /gt
    lt/signaturegt
  • lt/invokegt
  • ltreturn lineNumber"15" /gt
  • lt/codegt
  • lt/methodgt
  • lt/classgt
  • lt/dbdocumentgt
  • lt/dballgt

11
a View of the Database in Eclipse
12
using XQuery for Information Retrieval
  • functional query language especially well suited
    for XML Datasources
  • integrates well with other XML technologies(e.g.
    Namespaces)
  • still under development (but already widely
    adopted)

13
XQuery Path Expressions
ltdballgt ltdbdocumentgt ltclass name"test.Test"
visibility"public" gt ltinheritsgt ltclass
name"java.lang.Object"/gt lt/inheritsgt lt/classgt lt/
dbdocumentgt ltdbdocumentgt ltclass
name"test.SubTest" visibility"public"
gt ltinheritsgt ltclass nametest.Test"/gt
lt/inheritsgt lt/classgt lt/dbdocumentgt lt/dballgt
/
14
XQuery Path Expressions
ltdballgt ltdbdocumentgt ltclass name"test.Test"
visibility"public" gt ltinheritsgt ltclass
name"java.lang.Object"/gt lt/inheritsgt lt/classgt lt/
dbdocumentgt ltdbdocumentgt ltclass
name"test.SubTest" visibility"public"
gt ltinheritsgt ltclass nametest.Test"/gt
lt/inheritsgt lt/classgt lt/dbdocumentgt lt/dballgt
/ dball
15
XQuery Path Expressions
ltdballgt ltdbdocumentgt ltclass name"test.Test"
visibility"public" gt ltinheritsgt ltclass
name"java.lang.Object"/gt lt/inheritsgt lt/classgt lt/
dbdocumentgt ltdbdocumentgt ltclass
name"test.SubTest" visibility"public"
gt ltinheritsgt ltclass nametest.Test"/gt
lt/inheritsgt lt/classgt lt/dbdocumentgt lt/dballgt
/ dball/ dbdocument/
16
XQuery Path Expressions
ltdballgt ltdbdocumentgt ltclass name"test.Test"
visibility"public" gt ltinheritsgt ltclass
name"java.lang.Object"/gt lt/inheritsgt lt/classgt lt/
dbdocumentgt ltdbdocumentgt ltclass
name"test.SubTest" visibility"public"
gt ltinheritsgt ltclass nametest.Test"/gt
lt/inheritsgt lt/classgt lt/dbdocumentgt lt/dballgt
/ dball/ dbdocument/ class
17
XQuery Path Expressions
ltdballgt ltdbdocumentgt ltclass name"test.Test"
visibility"public" gt ltinheritsgt ltclass
name"java.lang.Object"/gt lt/inheritsgt lt/classgt lt/
dbdocumentgt ltdbdocumentgt ltclass
name"test.SubTest" visibility"public"
gt ltinheritsgt ltclass nametest.Test"/gt
lt/inheritsgt lt/classgt lt/dbdocumentgt lt/dballgt
/ dball/ dbdocument/ class _at_name
test.SubTest
18
XQuery Function Variable Definitions
ltdballgt ltdbdocumentgt ltclass name"test.Test"
visibility"public" gt ltinheritsgt ltclass
name"java.lang.Object"/gt lt/inheritsgt lt/classgt lt/
dbdocumentgt ltdbdocumentgt ltclass
name"test.SubTest" visibility"public"
gt ltinheritsgt ltclass nametest.Test"/gt
lt/inheritsgt lt/classgt lt/dbdocumentgt lt/dballgt
supertypes( / dball/dbdocument/ class_at_name
test.SubTest )
declare function supertypes(classes as
element()) as element() let supertypes
xircall/(classinterface) _at_nameclasse
s/inherits/(classinterface)/_at_name return
if (empty(supertypes)) then
classes else classes union
supertypes(supertypes)
19
XQuery Set Operations
select all classes that do not define the
toString method
let all xircproject-sources/class_at_abstract
"false" return all except
all/method _at_name"toString" and
empty(./signature/parameter) ( and
./signature/returns/_at_type "java.lang.String"
) /..
20
Bad Smells
21
a Cross-Artefact Query
detect all methods with bean managed transactions
(BMT) for which container managed transactions
are specified (CMT)
  • declare function EJBsWithCMT() as element()
  • let ejbname /ejb-jar/enterprise-beans
  • /(session message-driven)/transaction-type
  • ./text() "Container"/../ejb-class/text()
  • return /class_at_name ejbname
  • declare function methodsWithBMT() as element()
  • //invoke_at_declaringClassName
    "javax.transaction.UserTransaction"/
  • ancestormethod
  • methodsWithBMT() intersect EJBsWithCMT()//method

22
a Cross-Artefact Query
detect all methods with bean managed transactions
(BMT) for which container managed transactions
are specified (CMT)
  • declare function EJBsWithCMT() as element()
  • let ejbname //ejb-jar/enterprise-beans
  • /(session message-driven)/transaction-type
  • ./text() "Container"/../ejb-class/text()
  • return //class_at_name ejbname
  • declare function methodsWithBMT() as element()
  • //invoke_at_declaringClassName
    "javax.transaction.UserTransaction"/
  • ancestormethod
  • methodsWithBMT() intersect EJBsWithCMT()//method

ltenterprise-beansgt ltsessiongt ltejb-namegtHelloWor
ldTestBeanlt/ejb-namegt lthomegtde.tud.xirc.playgrou
nd.TestHomelt/homegt ltremotegtde.tud.xirc.playgroun
d.Testlt/remotegt ltejb-classgtde.tud.xirc.playgroun
d.TestBeanlt/ejb-classgt ltsession-typegtStatelesslt/
session-typegt lttransaction-typegtContainerlt/trans
action-typegt lt/sessiongt lt/enterprise-beansgt
23
a Cross-Artefact Query
detect all methods with bean managed transactions
(BMT) for which container managed transactions
are specified (CMT)
  • declare function EJBsWithCMT() as element()
  • let ejbname //ejb-jar/enterprise-beans
  • /(session message-driven)/transaction-type
  • ./text() "Container"/../ejb-class/text()
  • return //class_at_name ejbname
  • declare function methodsWithBMT() as element()
  • //invoke_at_declaringClassName
    "javax.transaction.UserTransaction"/
  • ancestormethod
  • methodsWithBMT() intersect EJBsWithCMT()//method

24
a Cross-Artefact Query
detect all methods with bean managed transactions
(BMT) for which container managed transactions
are specified (CMT)
  • declare function EJBsWithCMT() as element()
  • let ejbname //ejb-jar/enterprise-beans
  • /(session message-driven)/transaction-type
  • ./text() "Container"/../ejb-class/text()
  • return //class_at_name ejbname
  • declare function methodsWithBMT() as element()
  • //invoke_at_declaringClassName
    "javax.transaction.UserTransaction"/
  • ancestormethod
  • methodsWithBMT() intersect EJBsWithCMT()//method

25
Bad Smells
26
performance?
  • good but could be improved
  • XML database with 2833 class entries(all public
    classes and interfaces of all Java5 APIs, except
    for classes in the javax.swing. and java.awt.
    packages) The evaluation of 48 queries against
    the project code generated 51 warnings and 2
    errors and was executed in 3.56 seconds.
  • To keep the XIRC database for this project in
    memory approximately 40 MB are required.

27
a Query Container
  • defines one to multiple related queries
  • can define a context defining query(makes sense
    only for query containers defining multiple
    related queries)
  • Defines the scope for the evaluation
  • DB scoped queries
  • easier to develop
  • slower for incremental builds
  • Document scoped
  • very fast with incremental builds
  • query is not allowed to take other non-library
    documents into account

28
a Query Container - Example
  • ltimplementation_restriction_containergt
  • ltscopegtdocumentlt/scopegt
  • ltbase-urigtHERElt/base-urigt
  • ltcontext_definition_typegtquerylt/context_definition
    _typegt
  • ltcontext_definitiongt
  • declare namespace bat "http//.../BAT2-Java1.5
    (12/7/04)"
  • ._at_type"source"/batclass/batmethod/batcode
  • lt/context_definitiongt
  • ltimplementation_restriction id"UsageOfSystemErrOr
    SystemOut"gt
  • lttitlegtuse of System.err or System.outlt/titlegt
  • ltdescriptiongtuse a logging api lt/descriptiongt
  • ltseveritygtinfolt/severitygt
  • ltquerygt
  • declare default element namespace
    "http//.../BAT2-Java1.5(12/7/04)"
  • .//get_at_declaringClassName"java.lang.System"
  • and (_at_fieldName"out" or _at_fieldName"err")

29
a Query Container - Example
  • ltimplementation_restriction_containergt
  • ltscopegtdocumentlt/scopegt
  • ltbase-urigtHERElt/base-urigt
  • ltcontext_definition_typegtquerylt/context_definition
    _typegt
  • ltcontext_definitiongt
  • declare namespace bat "http//.../BAT2-Java1.5
    (12/7/04)"
  • ._at_type"source"/batclass/batmethod/batcode
  • lt/context_definitiongt
  • ltimplementation_restriction id"UsageOfSystemErrOr
    SystemOut"gt
  • lttitlegtuse of System.err or System.outlt/titlegt
  • ltdescriptiongtuse a logging api lt/descriptiongt
  • ltseveritygtinfolt/severitygt
  • ltquerygt
  • declare default element namespace
    "http//.../BAT2-Java1.5(12/7/04)"
  • .//get_at_declaringClassName"java.lang.System"
  • and (_at_fieldName"out" or _at_fieldName"err")

30
a Query Container - Example
  • ltimplementation_restriction_containergt
  • ltscopegtdocumentlt/scopegt
  • ltbase-urigtHERElt/base-urigt
  • ltcontext_definition_typegtquerylt/context_definition
    _typegt
  • ltcontext_definitiongt
  • declare namespace bat "http//.../BAT2-Java1.5
    (12/7/04)"
  • ._at_type"source"/batclass/batmethod/batcode
  • lt/context_definitiongt
  • ltimplementation_restriction id"UsageOfSystemErrOr
    SystemOut"gt
  • lttitlegtuse of System.err or System.outlt/titlegt
  • ltdescriptiongtuse a logging api lt/descriptiongt
  • ltseveritygtinfolt/severitygt
  • ltquerygt
  • declare default element namespace
    "http//.../BAT2-Java1.5(12/7/04)"
  • .//get_at_declaringClassName"java.lang.System"
  • and (_at_fieldName"out" or _at_fieldName"err")

31
a Query Container - Example
  • ltimplementation_restriction_containergt
  • ltscopegtdocumentlt/scopegt
  • ltbase-urigtHERElt/base-urigt
  • ltcontext_definition_typegtquerylt/context_definition
    _typegt
  • ltcontext_definitiongt
  • declare namespace bat "http//.../BAT2-Java1.5
    (12/7/04)"
  • ._at_type"source"/batclass/batmethod/batcode
  • lt/context_definitiongt
  • ltimplementation_restriction id"UsageOfSystemErrOr
    SystemOut"gt
  • lttitlegtuse of System.err or System.outlt/titlegt
  • ltdescriptiongtuse a logging api lt/descriptiongt
  • ltseveritygtinfolt/severitygt
  • ltquerygt
  • declare default element namespace
    "http//.../BAT2-Java1.5(12/7/04)"
  • .//get_at_declaringClassName"java.lang.System"
  • and (_at_fieldName"out" or _at_fieldName"err")

32
a Query Container - Example
  • ltimplementation_restriction_containergt
  • ltscopegtdocumentlt/scopegt
  • ltbase-urigtHERElt/base-urigt
  • ltcontext_definition_typegtquerylt/context_definition
    _typegt
  • ltcontext_definitiongt
  • declare namespace bat "http//.../BAT2-Java1.5
    (12/7/04)"
  • ._at_type"source"/batclass/batmethod/batcode
  • lt/context_definitiongt
  • ltimplementation_restriction id"UsageOfSystemErrOr
    SystemOut"gt
  • lttitlegtuse of System.err or System.outlt/titlegt
  • ltdescriptiongtuse a logging api lt/descriptiongt
  • ltseveritygtinfolt/severitygt
  • ltquerygt
  • declare default element namespace
    "http//.../BAT2-Java1.5(12/7/04)"
  • .//get_at_declaringClassName"java.lang.System"
  • and (_at_fieldName"out" or _at_fieldName"err")

33
a Query Container - Example
  • ltimplementation_restriction_containergt
  • ltscopegtdocumentlt/scopegt
  • ltbase-urigtHERElt/base-urigt
  • ltcontext_definition_typegtquerylt/context_definition
    _typegt
  • ltcontext_definitiongt
  • declare namespace bat "http//.../BAT2-Java1.5
    (12/7/04)"
  • ._at_type"source"/batclass/batmethod/batcode
  • lt/context_definitiongt
  • ltimplementation_restriction id"UsageOfSystemErrOr
    SystemOut"gt
  • lttitlegtuse of System.err or System.outlt/titlegt
  • ltdescriptiongtuse a logging api lt/descriptiongt
  • ltseveritygtinfolt/severitygt
  • ltquerygt
  • declare default element namespace
    "http//.../BAT2-Java1.5(12/7/04)"
  • .//get_at_declaringClassName"java.lang.System"
  • and (_at_fieldName"out" or _at_fieldName"err")

34
Q A
Q A
Write a Comment
User Comments (0)
About PowerShow.com