Tuesday, September 14, 2010

Aspect-oriented (AOP) and object-oriented (OOP) [3]



Exception Handling

Exception handling example I will not go into here, but this section of the code has been discussed by the above potential problems. When you call EmployeeRepository createEmployee object method, you may get a RepositoryException exception. The traditional solution is, in this class treatment. Another way is when the exception is thrown when RepositoryException createEmployee method returns null, catch block outside the class of other logic can deal with this error.

Error handling in different situations will be different. However, by AOP can be distinguished from each case.


Figure 3


Figure 3 describes the design of the AOP approach and a more abstract level, the interaction between classes. You can by comparing Figure 1 and Figure 3 to better understand the AOP.

Program aims to read the CSV file by BusinessUnit object record and fill in the class BusinessUnitService the map. Use AOP to fill this map is somewhat similar to the back door (backdoor) method - control is delegated to BusinessUnit to read the storage medium record.

AOP is to define some starting point (pointcut) and treatment (advice). An "entry point" is the source code in an execution point. Preceding example defines an "entry point" - class BusinessUnitService in findBusinessUnits method. a "treatment" by definition is when the Executive to a "starting point" when a piece of code. Class BusinessUnitPersistentAspect including advice method findAllBusinessUnits, the method of loading data from storage media, and then use the factory class to create BusinessUnit object. then the object is added map, map reference to the object obtained by BusinessUnitService object. "entry point" and "treatment" component of the so-called "aspect (Aspect)"

To read the data storage medium, OOP way through a DAO class to do. And AOP, you just define a "starting point" and corresponding "solutions" to read the data. AOP framework will the form of advice into the code, either in the implementation phase can also compile.

In short, when the class BusinessUnitService the findAllBusinessUnits method is called, AOP framework will be in the "entry point" into the treatment office, by BusinessUnit object map in advance to read data to populate the object. In this way, persistence layer's code can be moved to business outside of the code.

New methods in the "section"

This section discusses how to use AOP for the application of each "section" Modeling

Operational resources

Class BusinessUnitPersistenceAspect lasting method uses a buffered reader. You can even define "section" and "aspect", but for simplicity, here only concerned with the class to find methods.
@ Aspect ("perJVM")
public class BufferedFileReaderAspect (

@ Expression ("execution (* org.javatechnocrats.aop.withaop.aspects.Busi
\







Recommended links:



Quicktime mkv



Ps3 h264



Xvid To Divx Converter



mxf Converter



No comments:

Post a Comment