Web Cache Prefetching as an Aspect: Towards a Dynamic-Weaving Based Solution
W-JAX 08 - Aspect Weaving for OSGii
-
Upload
heiko-seeberger -
Category
Technology
-
view
969 -
download
0
description
Transcript of W-JAX 08 - Aspect Weaving for OSGii
![Page 1: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/1.jpg)
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: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/2.jpg)
Aspect-oriented programming
• Modularity improved a lot by OO concepts• Modularity improved a lot by OO conceptsClasses, interfacesInformation hiding, polymorphism, inheritance
• AOP adds additional conceptsTo modularize so called “cross-cutting concerns”
ClassA ClassB ClassC AspectX
ConcernXConcernXConcernXConcernX
ConcernX
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: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/3.jpg)
AOP today
• Meanwhile AOP is an established concept• Meanwhile AOP is an established conceptUseful for many situationsMostly technology-centric usage scenarios
• Established languages and frameworks availableAspectJ: powerful language extension to JavaSpring AOP: simple to use AOP for enterprise appsSpring-AOP: simple to use AOP for enterprise apps
• Used in production:Spring itself makes heavy use of AOP conceptsApp-servers are using AOP insideDirect AOP selectively used in enterprise apps
Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license
![Page 4: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/4.jpg)
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 5: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/5.jpg)
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 6: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/6.jpg)
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 7: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/7.jpg)
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 8: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/8.jpg)
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 9: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/9.jpg)
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 10: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/10.jpg)
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 11: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/11.jpg)
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 12: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/12.jpg)
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 13: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/13.jpg)
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 14: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/14.jpg)
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 15: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/15.jpg)
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
Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license
![Page 16: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/16.jpg)
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 17: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/17.jpg)
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 18: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/18.jpg)
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 19: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/19.jpg)
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 20: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/20.jpg)
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 21: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/21.jpg)
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 22: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/22.jpg)
AOP in Spring
• Spring uses AOP a lot for all kinds of purposes• Spring uses AOP a lot for all kinds of purposes• @Configurable is one example
• Realized by Spring via load-time aspect weaving
Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license
![Page 23: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/23.jpg)
Spring & Equinox Aspects
• Equinox Aspects can do load time aspect weaving for• Equinox Aspects can do load-time aspect weaving for Spring-powered bundles…
• Live Demo@Configurable for Extensions (Views in Eclipse RCP apps)
Aspect Weaving for OSGi | © 2008 by M. Lippert, H. Seeberger; made available under Creative Commons Att. Nc Nd 2.5 license
![Page 24: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/24.jpg)
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 25: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/25.jpg)
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 26: W-JAX 08 - Aspect Weaving for OSGii](https://reader034.fdocuments.in/reader034/viewer/2022051411/547d4bedb4795984508b4881/html5/thumbnails/26.jpg)
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