SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
Aspects Everywhere:
                                           Language Extensibility for JDT
                                             through Equinox Aspects


                                                                      Andrew Eisenberg
                                                                       AJDT Committer
                                                                       AspectJ Project




Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
AJDT is an extension of JDT

                                                                 Extension
      AJDT                                                                                                           JDT
                                                                     of

                                              AspectJ JPython
              support for




                                                                                                                     support for
                                              Groovy And other
                 Tool




                                                                                                                        Tool
                                              Scala   Java-like
                                                      language
                                              JRuby
                                                                 Extension
   AspectJ                                                                                                           Java
                                                                     of
                                                                                                                          public class Ship {
             public aspect ShipAccessor {                                                                                   // ...
               // ...                                                                                                     }
             }




                                                                                                                                                2
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
A little more about AspectJ

      • Aspects
                – like classes, but can have pointcuts and
                  advice
      • Pointcuts
                – define interesting parts of the (execution of)
                  program
      • Advice
                – define extra behavior at interesting parts of
                  the program
      • Weaving (performed by a weaver)
                – makes sure advice runs at right time

                                                                                                                     3
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Demo 1


      • AJDT 1.6.1
                – Provides AspectJ-specific editor
                – But does not fully integrate with JDT




                                                                                                                     4
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
The problem


                                                                                                                     • Aspects are
                                                                                                                       not in Open
                                                                                                                       Type dialogs




                                                                                                                                      5
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
The problem

                                                                                                                     • What I
                                                                                                                       really want
                                                                                                                       is this




                                                                                                                                     6
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
JDT is not really extensible


  • The problem runs deep
            – Need to plug into JDT's Java model, but can't
            – Need to plug into JDT's source indexing, but can't
            – Need to plug into JDT's parser, but can't




                                                                                                                     7
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
First attempt: Raise a bug!


      • Bug 36939: Improve support for Java-like
        source files
                – Many patches submitted
                – 37 votes
                – but not resolved
      • Outside the scope of JDT




                                                                                                                     8
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Second attempt: eat our own
dogfood!

      JDT Weaving Service
      • Use AspectJ
                – add hooks to JDT
                – toggles JDT or extended functionality
      • Wrapped in Eclipse extension points
                – make extensible to third parties
      • Equinox Aspects to support load time
        weaving in OSGi environment
      • AJDT 1.6.2 and later

                                                                                                                     9
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Demo 2


      • AJDT 1.6.4
                – Uses JDT Weaving service
                – More fully integrated with JDT




                                                                                                                     10
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
How does this work?

                                       Uses
       AJDT                                                                                                          JDT
                                     extension
        UI                                                                                                            UI
                                                                                                         Weaves
                                       points   JDT
                                                                                                          into
                                              Weaving
                                                                                                                     JDT
       AJDT                                    Service
                                                                                                                     Core
       Core

                                                                                                                             Other
                    Load Time                                                                                               bundles...
                     Weaving class
                             loading
             Equinox            &
             Aspects OSGi, everything
                   In                                                                                                 is a bundle
                            extension
                             support

                                                        Equinox-OSGi                                                                     11
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Equinox Aspects uses AspectJ
weaver

      • The weaver is careful which bundles to
        touch
      • Weaving happens lazily as classes are
        loaded
                – little effect on startup time
      • Once woven, weaver has no more role




                                                                                                                     12
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Example: Plug into JDT's Java
model

      • For when it's like Java, but it really isn't
      • Need to plug into JDT's Java element
        hierarchy
                – IJavaElement --- generic Java entity
                – ICompilationUnit --- A Java source file
      • Objects need to be instantiated at the
        right time




                                                                                                                     13
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Example: Plug into JDT's Java
model

      1. Define extension:
                <extension point=quot;org.eclipse.contribution.weaving.jdt.cuproviderquot;>
                             <provider class=quot;org.eclipse.ajdt.eclipsecon2009.ShipCUProviderquot;
                                                     file_extension=quot;shipquot;/>
                </extension>

      2. Define compilation unit provider:
           public class ShipCUProvider implements ICompilationUnitProvider {
                     public CompilationUnit create(PackageFragment parent, String name,
                                        WorkingCopyOwner owner) {
                          return new ShipCompilationUnit(parent, name, owner);
           }




                                                                                                                     14
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Demo 3/4


      • Simple Ship editor
                – Icons
                – Searching
                – Open type
      • Ship Editor source code
                – plugin.xml
                – Java source code




                                                                                                                     15
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
JDT Weaving Service


      • JDT functionality is exposed
                –      AspectJ advice and pointcuts
                –      exposed as extension points
                –      no need to be AspectJ aware
                –      simple and Eclipse-friendly
      • Available for download
                – with AJDT or separately
                http://download.eclipse.org/tools/ajdt/34/update
      • Useful for any Java-like language
                – Scala Eclipse plugin using this now
                                                                                                                     16
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
That's it!


      • Links
                – AJDT : http://eclipse.org/ajdt
                – Equinox Aspects :
                  http://www.eclipse.org/equinox/incubator/aspects/index.php
                – Source code and more implementation details :
                  http://contraptionsforprogramming.blogspot.com
                – AspectJ in Action by Ramnivas Laddad available at bookstore




                                                                                                                     17
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
CompilationUnitProviderAspect

 pointcut compilationUnitCreations(PackageFragment parent,
                                   String name, WorkingCopyOwner owner) :
          call(public CompilationUnit.new(PackageFragment,
                                          String, WorkingCopyOwner)) &&
          args(parent, name, owner);

 CompilationUnit around(PackageFragment parent,
                        String name, WorkingCopyOwner owner) :
             compilationUnitCreations(parent, name, owner) {

           String fileExtension = findFileExtension(name);
           ICompilationUnitProvider provider =
                        CompilationUnitProviderRegistry.getInstance()
                        .getProvider(fileExtension);
           if (provider != null)
               return provider.create(parent, name, owner);
           return proceed(parent, name, owner);
 }




                                                                                                                     18
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.

Contenu connexe

En vedette

Ciga 1
Ciga 1Ciga 1
Ciga 1
JNR
 
Initiative 2020 - Thal In Bewegung
Initiative 2020 - Thal In BewegungInitiative 2020 - Thal In Bewegung
Initiative 2020 - Thal In Bewegung
guesta3da88
 
5-Fh_Heidelberg_Organisationstheorien_Taylorismus
5-Fh_Heidelberg_Organisationstheorien_Taylorismus5-Fh_Heidelberg_Organisationstheorien_Taylorismus
5-Fh_Heidelberg_Organisationstheorien_Taylorismus
Tobias Illig
 
Tut peterschrotter bs_02_grundlagen_analog
Tut peterschrotter bs_02_grundlagen_analogTut peterschrotter bs_02_grundlagen_analog
Tut peterschrotter bs_02_grundlagen_analog
strychnine
 
Israele palestina som_
Israele palestina som_Israele palestina som_
Israele palestina som_
pppmm
 
Social Media für Einsteiger 11 Tipps
Social Media für Einsteiger 11 TippsSocial Media für Einsteiger 11 Tipps
Social Media für Einsteiger 11 Tipps
Brigitte Rossa
 

En vedette (20)

Ciga 1
Ciga 1Ciga 1
Ciga 1
 
22º dia pdf
22º dia   pdf22º dia   pdf
22º dia pdf
 
7º dia
7º dia7º dia
7º dia
 
19º dia pdf
19º dia   pdf19º dia   pdf
19º dia pdf
 
ε1 μέδουσα
ε1 μέδουσαε1 μέδουσα
ε1 μέδουσα
 
Initiative 2020 - Thal In Bewegung
Initiative 2020 - Thal In BewegungInitiative 2020 - Thal In Bewegung
Initiative 2020 - Thal In Bewegung
 
Recomendaciones para despues de una exodoncia
Recomendaciones para despues de una exodonciaRecomendaciones para despues de una exodoncia
Recomendaciones para despues de una exodoncia
 
البيان الختامي والتوصيات
البيان الختامي والتوصياتالبيان الختامي والتوصيات
البيان الختامي والتوصيات
 
5-Fh_Heidelberg_Organisationstheorien_Taylorismus
5-Fh_Heidelberg_Organisationstheorien_Taylorismus5-Fh_Heidelberg_Organisationstheorien_Taylorismus
5-Fh_Heidelberg_Organisationstheorien_Taylorismus
 
Kap1
Kap1Kap1
Kap1
 
ΣΤ2 Σύρος
ΣΤ2 ΣύροςΣΤ2 Σύρος
ΣΤ2 Σύρος
 
Tut peterschrotter bs_02_grundlagen_analog
Tut peterschrotter bs_02_grundlagen_analogTut peterschrotter bs_02_grundlagen_analog
Tut peterschrotter bs_02_grundlagen_analog
 
Conduce con cuidado
Conduce con cuidadoConduce con cuidado
Conduce con cuidado
 
Bons Conselhos
Bons ConselhosBons Conselhos
Bons Conselhos
 
Levantamento de brincadeiras publicar
Levantamento de brincadeiras publicarLevantamento de brincadeiras publicar
Levantamento de brincadeiras publicar
 
Follow-the-Sun: Um Processo para Minimizar as Dificuldades de Projetos que Ad...
Follow-the-Sun: Um Processo para Minimizar as Dificuldades de Projetos que Ad...Follow-the-Sun: Um Processo para Minimizar as Dificuldades de Projetos que Ad...
Follow-the-Sun: Um Processo para Minimizar as Dificuldades de Projetos que Ad...
 
Στ2 Ηρακλειά
Στ2 ΗρακλειάΣτ2 Ηρακλειά
Στ2 Ηρακλειά
 
Israele palestina som_
Israele palestina som_Israele palestina som_
Israele palestina som_
 
Social Media für Einsteiger 11 Tipps
Social Media für Einsteiger 11 TippsSocial Media für Einsteiger 11 Tipps
Social Media für Einsteiger 11 Tipps
 
Vocabulario
VocabularioVocabulario
Vocabulario
 

Similaire à Aspects Every Where

Practical Groovy Domain-Specific Languages - SpringOne Europe 2009
Practical Groovy Domain-Specific Languages - SpringOne Europe 2009Practical Groovy Domain-Specific Languages - SpringOne Europe 2009
Practical Groovy Domain-Specific Languages - SpringOne Europe 2009
Guillaume Laforge
 
Groovy-Eclipse at Eclipsecon2010
Groovy-Eclipse at Eclipsecon2010Groovy-Eclipse at Eclipsecon2010
Groovy-Eclipse at Eclipsecon2010
guest9ff00
 
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Guillaume Laforge
 
Groovy and Grails in Google App Engine
Groovy and Grails in Google App EngineGroovy and Grails in Google App Engine
Groovy and Grails in Google App Engine
Guillaume Laforge
 
[Challenge:Future] Chocoholic
[Challenge:Future] Chocoholic [Challenge:Future] Chocoholic
[Challenge:Future] Chocoholic
Challenge:Future
 
Javascript Framework Roundup FYB
Javascript Framework Roundup FYBJavascript Framework Roundup FYB
Javascript Framework Roundup FYB
nukeevry1
 
Eclipsecon 2010 - Scala Support in Eclipse
Eclipsecon 2010 - Scala Support in EclipseEclipsecon 2010 - Scala Support in Eclipse
Eclipsecon 2010 - Scala Support in Eclipse
Miles Sabin
 

Similaire à Aspects Every Where (16)

Practical Groovy Domain-Specific Languages - SpringOne Europe 2009
Practical Groovy Domain-Specific Languages - SpringOne Europe 2009Practical Groovy Domain-Specific Languages - SpringOne Europe 2009
Practical Groovy Domain-Specific Languages - SpringOne Europe 2009
 
Groovy-Eclipse at Eclipsecon2010
Groovy-Eclipse at Eclipsecon2010Groovy-Eclipse at Eclipsecon2010
Groovy-Eclipse at Eclipsecon2010
 
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
 
Groovy and Grails in Google App Engine
Groovy and Grails in Google App EngineGroovy and Grails in Google App Engine
Groovy and Grails in Google App Engine
 
Spring Integration and EIP Introduction
Spring Integration and EIP IntroductionSpring Integration and EIP Introduction
Spring Integration and EIP Introduction
 
BeJUG - Di With Spring
BeJUG - Di With SpringBeJUG - Di With Spring
BeJUG - Di With Spring
 
[Challenge:Future] Chocoholic
[Challenge:Future] Chocoholic [Challenge:Future] Chocoholic
[Challenge:Future] Chocoholic
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
Jcp adopt jsr
Jcp adopt jsrJcp adopt jsr
Jcp adopt jsr
 
Javascript Framework Roundup FYB
Javascript Framework Roundup FYBJavascript Framework Roundup FYB
Javascript Framework Roundup FYB
 
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?
JVM Languages Support in Eclipse - Monkey-patching the JDT for fun and profit?
 
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?
Scala Support in Eclipse - Monkey-patching the JDT for fun and profit?
 
GR8Conf 2009. The Grails Plugin System by Graeme Rocher
GR8Conf 2009. The Grails Plugin System by Graeme RocherGR8Conf 2009. The Grails Plugin System by Graeme Rocher
GR8Conf 2009. The Grails Plugin System by Graeme Rocher
 
Whats Cool in Java E 6
Whats Cool in Java E 6Whats Cool in Java E 6
Whats Cool in Java E 6
 
Server Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef ArendsenServer Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef Arendsen
 
Eclipsecon 2010 - Scala Support in Eclipse
Eclipsecon 2010 - Scala Support in EclipseEclipsecon 2010 - Scala Support in Eclipse
Eclipsecon 2010 - Scala Support in Eclipse
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Aspects Every Where

  • 1. Aspects Everywhere: Language Extensibility for JDT through Equinox Aspects Andrew Eisenberg AJDT Committer AspectJ Project Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 2. AJDT is an extension of JDT Extension AJDT JDT of AspectJ JPython support for support for Groovy And other Tool Tool Scala Java-like language JRuby Extension AspectJ Java of public class Ship { public aspect ShipAccessor { // ... // ... } } 2 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 3. A little more about AspectJ • Aspects – like classes, but can have pointcuts and advice • Pointcuts – define interesting parts of the (execution of) program • Advice – define extra behavior at interesting parts of the program • Weaving (performed by a weaver) – makes sure advice runs at right time 3 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 4. Demo 1 • AJDT 1.6.1 – Provides AspectJ-specific editor – But does not fully integrate with JDT 4 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 5. The problem • Aspects are not in Open Type dialogs 5 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 6. The problem • What I really want is this 6 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 7. JDT is not really extensible • The problem runs deep – Need to plug into JDT's Java model, but can't – Need to plug into JDT's source indexing, but can't – Need to plug into JDT's parser, but can't 7 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 8. First attempt: Raise a bug! • Bug 36939: Improve support for Java-like source files – Many patches submitted – 37 votes – but not resolved • Outside the scope of JDT 8 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 9. Second attempt: eat our own dogfood! JDT Weaving Service • Use AspectJ – add hooks to JDT – toggles JDT or extended functionality • Wrapped in Eclipse extension points – make extensible to third parties • Equinox Aspects to support load time weaving in OSGi environment • AJDT 1.6.2 and later 9 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 10. Demo 2 • AJDT 1.6.4 – Uses JDT Weaving service – More fully integrated with JDT 10 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 11. How does this work? Uses AJDT JDT extension UI UI Weaves points JDT into Weaving JDT AJDT Service Core Core Other Load Time bundles... Weaving class loading Equinox & Aspects OSGi, everything In is a bundle extension support Equinox-OSGi 11 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 12. Equinox Aspects uses AspectJ weaver • The weaver is careful which bundles to touch • Weaving happens lazily as classes are loaded – little effect on startup time • Once woven, weaver has no more role 12 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 13. Example: Plug into JDT's Java model • For when it's like Java, but it really isn't • Need to plug into JDT's Java element hierarchy – IJavaElement --- generic Java entity – ICompilationUnit --- A Java source file • Objects need to be instantiated at the right time 13 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 14. Example: Plug into JDT's Java model 1. Define extension: <extension point=quot;org.eclipse.contribution.weaving.jdt.cuproviderquot;> <provider class=quot;org.eclipse.ajdt.eclipsecon2009.ShipCUProviderquot; file_extension=quot;shipquot;/> </extension> 2. Define compilation unit provider: public class ShipCUProvider implements ICompilationUnitProvider { public CompilationUnit create(PackageFragment parent, String name, WorkingCopyOwner owner) { return new ShipCompilationUnit(parent, name, owner); } 14 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 15. Demo 3/4 • Simple Ship editor – Icons – Searching – Open type • Ship Editor source code – plugin.xml – Java source code 15 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 16. JDT Weaving Service • JDT functionality is exposed – AspectJ advice and pointcuts – exposed as extension points – no need to be AspectJ aware – simple and Eclipse-friendly • Available for download – with AJDT or separately http://download.eclipse.org/tools/ajdt/34/update • Useful for any Java-like language – Scala Eclipse plugin using this now 16 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 17. That's it! • Links – AJDT : http://eclipse.org/ajdt – Equinox Aspects : http://www.eclipse.org/equinox/incubator/aspects/index.php – Source code and more implementation details : http://contraptionsforprogramming.blogspot.com – AspectJ in Action by Ramnivas Laddad available at bookstore 17 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 18. CompilationUnitProviderAspect pointcut compilationUnitCreations(PackageFragment parent, String name, WorkingCopyOwner owner) : call(public CompilationUnit.new(PackageFragment, String, WorkingCopyOwner)) && args(parent, name, owner); CompilationUnit around(PackageFragment parent, String name, WorkingCopyOwner owner) : compilationUnitCreations(parent, name, owner) { String fileExtension = findFileExtension(name); ICompilationUnitProvider provider = CompilationUnitProviderRegistry.getInstance() .getProvider(fileExtension); if (provider != null) return provider.create(parent, name, owner); return proceed(parent, name, owner); } 18 Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.