Podrška #20324
ZatvorenAOP programming: aspectj , modular, ddd programming, java annotations, java generics
Dodano od Ernad Husremović prije oko 15 godina. Izmjenjeno prije više od 14 godina.
0%
Povezani tiketi 1 (0 otvoreno — 1 zatvoren)
Izmjenjeno od Ernad Husremović prije oko 15 godina
Izmjenjeno od Ernad Husremović prije oko 15 godina
Izmjenjeno od Ernad Husremović prije oko 15 godina
Izmjenjeno od Ernad Husremović prije oko 15 godina
advice (additional behavior)
join points (points in a program)
Izmjenjeno od Ernad Husremović prije oko 15 godina
- Naslov promijenjeno iz aspectj u aspectj , modular, ddd programming
Izmjenjeno od Ernad Husremović prije oko 15 godina
Instead of developing an entirely new language, the aspect weaver interprets the extensions defined by AspectJ and builds "woven" Java code which can then be used by any existing Java compiler. This ensures that any existing object oriented code will still be valid aspect-oriented code and that development will feel like a natural extension of the object-oriented language.
Izmjenjeno od Ernad Husremović prije oko 15 godina
AspectC++ is an aspect-oriented extension of C and C++ languages. It is based on source-to-source translation, translating AspectC++ source code to C++. It is available under the GNU GPL, though some extensions specific to Microsoft Windows are only available through pure-systems GmbH.
Izmjenjeno od Ernad Husremović prije oko 15 godina
Aspect weavers operate by taking instructions specified by aspects, known as advice, and distributing it throughout the various classes in the program automatically.
The result of the weaving process is a set of classes with the same names as the original classes but with additional code injected into the classes' functions automatically.
Izmjenjeno od Ernad Husremović prije oko 15 godina
http://blog.objectmentor.com/articles/2008/09/27/traits-vs-aspects-in-scala
Scala traits provide a mixin composition mechanism that has been missing in Java. Roughly speaking, you can think of traits as analogous to Java interfaces, but with implementations.
Aspects, e.g., those written in AspectJ, are another mechanism for mixin composition in Java.
Izmjenjeno od Ernad Husremović prije oko 15 godina
http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations.html#annotations-inJava5
retention - zadržavanje
Izmjenjeno od Ernad Husremović prije oko 15 godina
- Naslov promijenjeno iz aspectj , modular, ddd programming u aspectj , modular, ddd programming, java annotations
Annotations can have one of three retention policies:
Source-file retention¶
Annotations with source-file retention are read by the compiler during the compilation process, but are not rendered in the generated .class files.
Class-file retention¶
This is the default retention policy. Annotations with class-file retention are read by the compiler and also retained in the generated .class files.
Runtime retention¶
Annotations with runtime retention are read by the compiler, retained in the generated .class files, and also made available at runtime.
Local variable annotations are not retained in class files (or at runtime) regardless of the retention policy set on the annotation type. See JLS 9.6.1.2.
Izmjenjeno od Ernad Husremović prije oko 15 godina
- Naslov promijenjeno iz aspectj , modular, ddd programming, java annotations u aspectj , modular, ddd programming, java annotations, java generics
Izmjenjeno od Ernad Husremović prije oko 15 godina
A generic type is declared with one or more type parameters following the type name. By convention formal type parameters are named using a single letter, though this is not required. A simple generic list type (that can contain elements of any type E) could be declared:
interface List<E> { Iterator<E> iterator(); void add(E anItem); E remove(E anItem); }
Izmjenjeno od Ernad Husremović prije oko 15 godina
generics nije isto što i templating !
It is important to understand that unlike template mechanisms there will only be one type, and one class file, corresponding to the List interface, regardless of how many different instantiations of the List interface a program has (each potentially providing a different value for the type parameter E). A consequence of this is that you cannot refer to the type parameters of a type declaration in a static method or initializer, or in the declaration or initializer of a static variable.
Izmjenjeno od Ernad Husremović prije oko 15 godina
You declare a variable (or a method/constructor argument) of a parameterized type by specifying a concrete type specfication for each type parameter in the generic type. The following example declares a list of strings and a list of numbers:
List<String> strings; List<Number> numbers;
It is also possible to declare a variable of a generic type without specifying any values for the type parameters (a raw type). For example, List strings. In this case, unchecked warnings may be issued by the compiler when the referenced object is passed as a parameter to a method expecting a parameterized type such as a List<String>. New code written in the Java 5 language would not be expected to use raw types.
Parameterized types are instantiated by specifying type parameter values in the constructor call expression as in the following examples:
List<String> strings = new MyListImpl<String>(); List<Number> numbers = new MyListImpl<Number>();
...
Generics in Java are implemented using a technique called erasure. All type parameter information is erased from the run-time type system. Asking an object of a parameterized type for its class will return the class object for the raw type (eg. List for an object declared to be of type List<String>. A consequence of this is that you cannot at runtime ask if an object is an instanceof a parameterized type.
Izmjenjeno od Ernad Husremović prije oko 15 godina
java covariance, varargs, enumerated types¶
http://www.eclipse.org/aspectj/doc/released/adk15notebook/covariance.html#covariance-inJava5
http://www.eclipse.org/aspectj/doc/released/adk15notebook/varargs.html#varargs-inJava5
http://www.eclipse.org/aspectj/doc/released/adk15notebook/enumeratedtypes.html#enums-in-java5
Izmjenjeno od Ernad Husremović prije oko 15 godina
The advice's pointcut publishes the values for the advice's arguments. The three primitive pointcuts this, target and args are used to publish these values.
pointcut setXY(FigureElement fe, int x, int y): call(void FigureElement.setXY(int, int)) && target(fe) && args(x, y); after(FigureElement fe, int x, int y) returning: setXY(fe, x, y) { System.out.println(fe + " moved to (" + x + ", " + y + ")."); }
Izmjenjeno od Ernad Husremović prije oko 15 godina
h2, Inter-type declarations
.. in AspectJ are declarations that cut across classes and their hierarchies. They may declare members that cut across multiple classes, or change the inheritance relationship between classes. Unlike advice, which operates primarily dynamically, introduction operates statically, at compile-time.
Consider the problem of expressing a capability shared by some existing classes that are already part of a class hierarchy, i.e. they already extend a class. In Java, one creates an interface that captures this new capability, and then adds to each affected class a method that implements this interface.
AspectJ can express the concern in one place, by using inter-type declarations. The aspect declares the methods and fields that are necessary to implement the new capability, and associates the methods and fields to the *existing classes.
Suppose we want to have Screen objects observe changes to Point objects, where Point is an existing class.
We can implement this by writing an aspect declaring that the class Point Point has an instance field, observers, that keeps track of the Screen objects that are observing Points.
aspect PointObserving { private Vector Point.observers = new Vector(); ... }
The observers field is private, so only PointObserving can see it. So observers are added or removed with the static methods addObserver and removeObserver on the aspect.
aspect PointObserving { private Vector Point.observers = new Vector(); public static void addObserver(Point p, Screen s) { p.observers.add(s); } public static void removeObserver(Point p, Screen s) { p.observers.remove(s); } ... }
Along with this, we can define a pointcut changes that defines what we want to observe, and the after advice defines what we want to do when we observe a change.
aspect PointObserving { private Vector Point.observers = new Vector(); public static void addObserver(Point p, Screen s) { p.observers.add(s); } public static void removeObserver(Point p, Screen s) { p.observers.remove(s); } pointcut changes(Point p): target(p) && call(void Point.set*(int)); after(Point p): changes(p) { Iterator iter = p.observers.iterator(); while ( iter.hasNext() ) { updateObserver(p, (Screen)iter.next()); } } static void updateObserver(Point p, Screen s) { s.display(p); } }
Note that neither Screen's nor Point's code has to be modified, and that all the changes needed to support this new capability are local to this aspect.
Izmjenjeno od Ernad Husremović prije oko 15 godina
ovo ovo je detaljna analiza šta predstavlja jedan aspekt:
http://www.eclipse.org/aspectj/doc/released/progguide/language-anatomy.html
Izmjenjeno od Ernad Husremović prije oko 15 godina
- Naslov promijenjeno iz aspectj , modular, ddd programming, java annotations, java generics u AOP programming: aspectj , modular, ddd programming, java annotations, java generics
Izmjenjeno od Ernad Husremović prije više od 14 godina
- Status promijenjeno iz Dodijeljeno u Zatvoreno