1 / 20

Applying aspect-oriented programming ideas in a component based context: Composition Adapters.

Applying aspect-oriented programming ideas in a component based context: Composition Adapters. Wim Vanderperren System and Software Engineering Lab (SSEL) Vrije Universiteit Brussel (VUB) Pleinlaan 2, 1050 Brussels, Belgium. 姓名:陳源順. 學號: E9406002. 指導老師:張顧耀老師. Outline.

wshawn
Download Presentation

Applying aspect-oriented programming ideas in a component based context: Composition Adapters.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Applying aspect-oriented programming ideas in a component based context: Composition Adapters. Wim Vanderperren System and Software Engineering Lab (SSEL) Vrije Universiteit Brussel (VUB) Pleinlaan 2, 1050 Brussels, Belgium 姓名:陳源順 學號:E9406002 指導老師:張顧耀老師

  2. Outline AOP (Aspect – oriented programming) Component Based Possible Approaches Example of composition adapters Conclusions

  3. Aspect – oriented programming package java.io; public class File implements java.io.Serializable { private String path; ... public boolean exists() { // JAAS security service call SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); } return exists0(); }

  4. Aspect – oriented programming public boolean canRead() { // JAAS security service call SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); } return canRead0(); } … // repeat for 16 times Crosscutting concern

  5. AOP (Aspect – oriented programming)

  6. Component based

  7. Component based

  8. Component based

  9. Aspectual component Composition adapters consist of two part Context Describes the behavior that will be adapted. Adapter Describes the adaptation itself.

  10. Aspectual component

  11. Aspectual component

  12. Example of composition adapters public aspect SensorAdapter { declare parents : (TemperatureGauge || RadiationDetector) implements StatusSensor; }

  13. Example of composition adapters public class TemperatureGauge{ public int readTemperature(){ //accesses sensor internals } }

  14. Example of composition adapters public class RadiationDetector { public double getCurrentRadiationLevel(){ //read radiation somehow } }

  15. Example of composition adapters Readout: Sensor 1 status is OK Sensor 2 status is OK Sensor 3 status is BORDERLINE Sensor 4 status is DANGER!

  16. Example of composition adapters public static void main(String[] args){ RadiationDetector radiationDetector = //find critical detector TemperatureGauge gauge = //get exhaust nozzle gauge List allSensors = new ArrayList(); allSensors.add(radiationDetector); allSensors.add(gauge); int count = 1; for (Sensor sensor : allSensors) { //How to read each type of sensor...? } }

  17. Example of composition adapters if(this.readTemperature() > 160){ return "DANGER"; } return "OK"

  18. Example of composition adapters public aspect SensorAdapter { declare parents : (TemperatureGauge || RadiationDetector) implements StatusSensor; }

  19. Example of composition adapters public String TemperatureGauge.getStatus() { if(this.readTemperature() > 160) { return "DANGER"; } return "OK"; }

  20. Conclusions Easy to understand Repetition use Maintenance Combination

More Related