Top Banner
Aspect Weaving for OSGi Martin Lippert (akquinet it-agile GmbH) H ik S b (Wil Wil kG bH) Heiko Seeberger (Weigle Wilczek GmbH) © 2008 by Martin Lippert, Heiko Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license | November 7th, 2008
23

Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Jun 30, 2015

Download

Technology

Heiko Seeberger
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Aspect Weaving for OSGi

Martin Lippert (akquinet it-agile GmbH)H ik S b (W i l Wil k G bH)Heiko Seeberger (Weigle Wilczek GmbH)

© 2008 by Martin Lippert, Heiko Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license | November 7th, 2008

Page 2: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Aspect-oriented programming

• Modularity improved a lot by OO concepts• Modularity improved a lot by OO concepts• AOP adds modularization for crosscutting concerns• Meanwhile AOP is an established conceptMeanwhile AOP is an established concept

Established languages and frameworks availableUsed in production

ClassA ClassB ClassC AspectX

ConcernXConcernXConcernX

ConcernXConcernX

ConcernX

ConcernX

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 3: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

AspectJ = AOP for Java

• AspectJ is a powerful language extension for Java• AspectJ is a powerful language extension for JavaHosted as an Eclipse projectStill very active (latest release 1.6.1 in July 2008)

• AJDT:Great tooling for the Eclipse IDE (3.3, 3.4)Comes close to the JDT feelingComes close to the JDT feeling

• Spring-IDE:Integrates AJDT with Spring-AOPAJDT feeling for Spring apps

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 4: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

The Standard Use Case

ClassA ClassB ClassC AspectXClassA ClassB ClassC AspectX

ConcernXConcernXConcernX

ConcernXConcernX

ConcernX

ConcernX

Project Sources

Java Virtual Machine

Single Application Classpath

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 5: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Library Aspects

ClassA ClassB ClassC AspectXClassA ClassB ClassC AspectX

ConcernXConcernXConcernX

ConcernXConcernX

ConcernX

ConcernX

JARProject Sources

Java Virtual Machine

Single Application Classpath

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 6: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Aspects for Existing Code

ClassA ClassB ClassC AspectXClassA ClassB ClassC AspectX

ConcernXConcernXConcernX

ConcernXConcernX

ConcernX

ConcernX

Project SourcesJARs

Java Virtual Machine

Single Application Classpath

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 7: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Java + OSGi

• OSGi:• OSGi:“A dynamic module system for Java”

• Modularity• Dynamic• Service-Oriented

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 8: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

What does it mean for us?

• We would like to modularize• We would like to modularize… classes and interfaces into bundles… and aspects into bundles

• The obvious next step:modularize cross cutting concerns into bundlesmodularize cross-cutting concerns into bundles

• Takes modularity to the next level

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 9: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Intra-Bundle Aspects

ClassA ClassB ClassC AspectXClassA ClassB ClassC AspectX

ConcernXConcernXConcernX

Bundle A Bundle B

Java Virtual Machine

Bundle-Classpath Bundle-Classpath

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 10: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Co-Op Bundle Aspects

ClassA ClassB ClassC AspectXClassA ClassB ClassC AspectX

ConcernXConcernXConcernX

ConcernXConcernX

ConcernX

ConcernX

Bundle A Bundle B Bundle C

Java Virtual Machine

Bundle-Classpath Bundle-Classpath Bundle-Classpath

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 11: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Abstract Aspect Bundles

ClassA ClassB Ab t tC tClassA ClassB AbstractAspect

ConcernXConcernX

ConcernXConcernX

ConcernX

ConcreteAspect

ConcernX

Bundle A Bundle B

Java Virtual Machine

Bundle-Classpath Bundle-Classpath

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 12: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Dynamics for Aspect Bundles

• OSGi allows dynamic bundle• OSGi allows dynamic bundle… installs… uninstalls… updates

• Same should be possible for aspect bundles• Same should be possible for aspect bundles… dynamic installs, uninstalls and updates of aspect bundles… dynamic installs, uninstalls and updates of bundles that are ff t d b taffected by aspects

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 13: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

How could all this possibly work?

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 14: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Equinox Aspects

• Equinox Incubator Project• Equinox Incubator Projecthttp://www.eclipse.org/equinox/incubator/aspects

• Enables AspectJ/AOP for OSGiSupports all presented use-casesReady to useReady-to-use

• SettingWorks with Eclipse 3.4 (and 3.3 deprecated)Works with AJDT 1.5.2, 1.5.3, 1.6.0, 1.6.1, 1.6.2

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 15: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

What can I do?

• Put aspects into standard OSGi bundles• Put aspects into standard OSGi bundlesJust like Java classes

• Define what and where to weaveaop.xml and manifest headers

• Go!

• Feels like a natural combination of AOP and OSGi• Feels like a natural combination of AOP and OSGi…

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 16: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Load-Time Weaving for OSGi

• Let the OSGi runtime take care of weaving the aspects• Let the OSGi runtime take care of weaving the aspects(and not the compiler)Leads to load-time weaving within OSGi

• This means:No recompilation of existing bundles necessaryNo recompilation of existing bundles necessarySupports “aop.xml” load-time weaving config of AspectJ

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 17: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Live Demo

• Monitoring Eclipse bundles• Monitoring Eclipse bundles…

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 18: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Caching

• Wasn’t that a fast startup?• Wasn t that a fast startup?

• The reason: caching for woven classesThe reason: caching for woven classesLoad-time weaving happens only onceSecond time startup is same as without aspectsA il bl f t d d JRE d IBM J9 h d lAvailable for standard JREs and IBM J9 shared classesSupports configuration switching

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 19: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Dynamics

• Dynamics for aspect bundles• Dynamics for aspect bundlesMeans re- or un-weaving existing bundles

• How is it realized?Silent update of bundles to be woven againBundles must behave nicely within dynamic situationsBundles must behave nicely within dynamic situations

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 20: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Live Demo

• Installing• Installing,updating,

uninstallingaspects at runtime…

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 21: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

APIs and Implementation

• org eclipse equinox weaving hook• org.eclipse.equinox.weaving.hookHooks into the runtimeProvides API for injecting weaving and caching implementations

• org.eclipse.equinox.weaving.aspectjImplements aspect weaving using AspectJImplements aspect weaving using AspectJ

• org.eclipse.equinox.weaving.cachingImplements caching for standard VMs

• org.eclipse.equinox.weaving.caching.j9Implements caching for IBM J9 VMs (shared classes feature)

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 22: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Conclusions

• Equinox Aspects brings full AOP to OSGi• Equinox Aspects brings full AOP to OSGiLoad-time weaving integrated into OSGiCombines OSGi and AOP modularity features

• Can be used for production systems today

• Give it a tryhttp://www.eclipse.org/equinox/incubator/aspects

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license

Page 23: Eclipse Summit Europe 08 - Aspect Weaving for OSGi

Thank you for your attention!

Q&AQ&A

Heiko Seeberger: [email protected] Lippert lippert@acm orgMartin Lippert: [email protected]

Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license