Presentation is loading. Please wait.

Presentation is loading. Please wait.

Implementing Distribution and Persistence Aspects with AspectJ WAS CLASS.

Similar presentations


Presentation on theme: "Implementing Distribution and Persistence Aspects with AspectJ WAS CLASS."— Presentation transcript:

1 Implementing Distribution and Persistence Aspects with AspectJ WAS CLASS

2 Purpose of the paper l show that AspectJ is useful for implementing several distribution and persistence concerns solution is superior to a Java-only version l provide guidelines for using AspectJ specific for these concerns l suggest some extensions to AspectJ to make it easier to use

3 The Health Watcher System

4 l modularity and extensibility required using a layered architecture using design patterns (for example Facade) l goal: separation of concerns persistance / distribution / business and presentation untangle the code not completely achievable in a pure java version l use AspectJ to achieve separation of concerns

5 separation of concerns l benefits well structured code more transparent easier to maintain possibly less code to write...

6 The Health Watcher System

7 Distribution Concerns l pure java implementation uses Java RMI code is spread throughout server and client classes l goal remove all RMI-specific code from the system code l example server sided facade-class implementing remote interface

8 Example: Distribution concerns l removing RMI code use aspect to make facade implement Remote Interface use aspects to make parameter and return types serializable declare parents: HWFacade implements IHWFacade l problems AspectJ does not allow to add throws()-clauses (here for Java RemoteExceptions) tedious to write pointcut for all parameter and return types of the Remote Interface methods (for serializability)

9 Example: Distribution concerns l results separation of concerns succeeded some inconvenient solutions because of limitations in AsptecJ general pattern for restructuring systems

10 Distribution concerns

11 Persistence concerns l pure java implementation persistence code mostly concentrated in data collection and persistence mechanism classes but also spread throughout server classes l goal remove all persistence-specific code from the system code l example transaction control

12 Example: Transaction Control abstract aspect AbstractTransactionControl { abstract pointcut transactionalMethods(); abstract IPersistenceMechanism getPm(); before(): transactionalMethods() { getPm().beginTransaction } after() returning: transactionalMethods() { getPm().commitTransaction(); } after() throwing: transactionalMethods() { getPm().rollbackTransaction(); }

13 Example: Transaction Control l implement a concrete aspect l defining an interface for transactional methods to avoid listing them in the pointcut

14 Example: Transaction Control l results dependencies between System code and aspect code exist removal of explicit calls of transactional methods removal of error handling for transaction failures less code than in the pure java version inadequate for systems with lots of hand-optimized transaction methods

15 Persistence concerns

16 Summary l AspectJ is useful for separating concerns success in complete separation of concerns l some drawbacks possible side effects of pointcuts aspects may be system specific careful design still necessary

17 Summary l AspectJ is not used to provide full transparency application programmers should be aware of aspects aspect programmers should be aware of the application code more powerful tools needed to provide different views on the dependencies

18 Summary l possibility of an Aspect Framework building on abstract aspects deriving guidelines for restructuring and implementing applications using AspectJ probably automatation of refactoring pure Java systems

19 Questions


Download ppt "Implementing Distribution and Persistence Aspects with AspectJ WAS CLASS."

Similar presentations


Ads by Google