Aspect weaver

Available inAspectC++, AspectJ
TypeAspect-oriented programming

An aspect weaver is a metaprogramming utility for aspect-oriented languages designed to take instructions specified by aspects (isolated representations of significant concepts in a program) and generate the final implementation code. The weaver integrates aspects into the locations specified by the software as a pre-compilation step. By merging aspects and classes (representations of the structure of entities in the program), the weaver generates a woven class.

Aspect weavers take instructions known as advice specified through the use of pointcuts and join points, special segments of code that indicate what methods should be handled by aspect code. The implementation of the aspect then specifies whether the related code should be added before, after, or throughout the related methods. By doing this, aspect weavers improve modularity, keeping code in one place that would otherwise have been interspersed throughout various, unrelated classes.

Motivation

Many programming languages are already widely accepted and understood. However, there is no significant desire to create radically different programming languages to support the aspect-oriented programming paradigm due to business-related risks associated with adopting new technologies.[1] Use of an entirely new language relies on a business's ability to acquire new developers. Additionally, the existing code base of a business would need to be discarded. Finally, a business would need to acquire a new toolchain (suite of tools) for development, which is often expensive in both money and time.[2] Primary concerns about roadmaps for the adoption of new technologies include the need to train new developers and adapt existing processes to the new technology.[3]

To address these business concerns, an aspect weaver enables the use of widely adopted languages like Java with aspect-oriented programming through minor adaptations such as AspectJ which work with existing tools.[4] 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.[5] The AspectC++ programming language extends C++ through the use of an aspect weaver, offering the additional efficiency over AspectJ that is needed for embedded systems while still retaining the benefits of aspect-oriented programming.[6]

Implementation

Aspect weavers operate by taking instructions specified by aspects, known as advice, and automatically distributing it throughout the various classes in the program. The result of the weaving process is a set of classes with the same names as the original classes but with additional code automatically injected into the classes' functions. The advice specifies the exact location and functionality of the injected code.[7]

Through this weaving process, aspect weavers allow for code which otherwise would have been duplicated across classes. By eliminating this duplication, aspect weavers promote modularity of cross-cutting concerns.[8] Aspects define the implementation code which otherwise would have been duplicated and then use pointcuts and join points to define the advice. During weaving, the aspect weaver uses the pointcuts and join points, known as a pointcut designator, to identify the positions in candidate classes at which the implementation should be injected.[9] The implementation is then injected into the classes at the points identified, thus permitting the code to be executed at the appropriate times without relying on manual duplication by the programmer.[10]

aspect Logger {
    pointcut method() : execution(* *(..));
    before() : method() {
        System.out.println("Entering " + 
            thisJoinPoint.getSignature().toString());
    }
    after() : method() { 
        System.out.println("Leaving " + 
            thisJoinPoint.getSignature().toString());
    }
}
public class Foo {
    public void bar() {
        System.out.println("Executing Foo.bar()");
    }
    public void baz() {
        System.out.println("Executing Foo.baz()");
    }
}
A sample aspect and class defined in the AspectJ programming language
public class Foo {
    public void bar() {
        System.out.println("Entering Foo.bar()");
        System.out.println("Executing Foo.bar()");
        System.out.println("Leaving Foo.bar()");
    }
    public void baz() {
        System.out.println("Entering Foo.baz()");
        System.out.println("Executing Foo.baz()");
        System.out.println("Leaving Foo.baz()");
    }
}
The woven class that results from executing an aspect weaver on the above sample

Weaving in AspectJ

In the programming language AspectJ, pointcuts, join points, and the modularized code are defined in an aspect block similar to that of Java classes. Classes are defined using Java syntax. The weaving process consists of executing the aspect advice to produce only a set of generated classes that have the aspect implementation code woven into it.[11]

The example at right shows a potential implementation of an aspect which logs the entry and exit of all methods. Without an aspect weaver, this feature would require duplication of code in the class for every method. Instead, the entry and exit code is defined solely within the aspect.[12]

The aspect weaver analyzes the advice specified by the pointcut in the aspect and uses that advice to distribute the implementation code into the defined class. The code differs slightly in each method due to slight variances in requirements for the method (as the method identifier has changed). The aspect weaver determines the appropriate code to generate in each situation as defined by the implementation advice and then injects it into methods matching the specified pointcut.[13]

Weaving to bytecode

Instead of generating a set of woven source code, some AspectJ weavers instead weave the aspects and classes together directly into bytecode, acting both as the aspect weaver and compiler.[14][15] It is expected that the performance of aspect weavers which also perform the compilation process will require more computation time due to the weaving process involved. However, the bytecode weaving process produces more efficient runtime code than would usually be achieved through compiled woven source.

Run-time weaving

Developments in AspectJ have revealed the potential to incorporate just-in-time compilation into the execution of aspect-oriented code to address performance demands.[16] At run-time, an aspect weaver could translate aspects in a more efficient manner than traditional, static weaving approaches. Using AspectJ on a Java Virtual Machine, dynamic weaving of aspects at run-time has been shown to improve code performance by 26%.[17] While some implementations of just-in-time virtual machines implement this capability through a new virtual machine, some implementations can be designed to use features that already exist in current virtual machines.[18][19] The requirement of a new virtual machine is contrary to one of the original design goals of AspectJ.[5]

To accomplish just-in-time weaving, a change to the virtual machine that executes the compiled bytecode is needed. A proposed solution for AspectJ uses a layered approach which builds upon the existing Java Virtual Machine to add support for join point management and callbacks to a Dynamic Aspect-Oriented Programming Engine.[19] An alternative implementation uses a weaving engine that uses breakpoints to halt execution at the pointcut, select an appropriate method, embed it into the application, and continue.[20] The use of breakpoints in this manner has been shown to reduce performance due to a very large number of context switches.[17]

Performance

Aspect weavers' performance, as well as the performance of the code that they produce, has been a subject of analysis. It is preferable that the improvement in modularity supplied by aspect weaving does not impact run-time performance. Aspect weavers are able to perform aspect-specific optimizations.[21] While traditional optimizations such as the elimination of unused special variables from aspect code can be done at compile-time, some optimizations can only be performed by the aspect weaver. For example, AspectJ contains two similar but distinct keywords, thisJoinPoint, which contains information about this particular instance of woven code, and thisJoinPointStaticPart, which contains information common to all instances of code relevant to that set of advice. The optimization of replacing thisJoinPoint with the more efficient and static keyword thisJoinPointStaticPart can only be done by the aspect weaver. By performing this replacement, the woven program avoids the creation of a join point object on every execution.[14] Studies have shown that the unnecessary creation of join point objects in AspectJ can lead to a performance overhead of 5% at run-time, while performance degradation is only approximately 1% when this object is not created.[22]

Compile-time performance is generally worse in aspect weavers than their traditional compiler counterparts due to the additional work needed for locating methods which match the specified pointcuts. One study showed that the AspectJ compiler ajc is about 34% slower than the Sun Microsystems Java 1.3 compiler and about 62% slower than the Java 1.4 compiler.[23]

See also

References

  1. ^ Kiczales (October 2001), p.2
  2. ^ Kiczales (October 2001), p.7
  3. ^ Colyer (2003), p.6
  4. ^ Kiczales (October 2001), p.5
  5. ^ a b Kiczales (June 2001), p.3
  6. ^ Spinczyk (2002), p.1
  7. ^ Wand (2004), p.1
  8. ^ Wand (2004), p.7
  9. ^ Viega (November 2000), p.2
  10. ^ Spinczyk (October 2007), p.21
  11. ^ Wang (July 2007), p.4
  12. ^ Avgustinov (2007), p.2
  13. ^ Hilsdale (2004), pp.5–6
  14. ^ a b Hilsdale (2004), p.2
  15. ^ McEachen (2005), p.1
  16. ^ Popovici (2003), p.1
  17. ^ a b Sato (September 2003), p.17
  18. ^ Sato (September 2003), p.2
  19. ^ a b Papovici (2003), p.3
  20. ^ Sato (September 2003), p.11
  21. ^ Gal (2001), p.3
  22. ^ Colyer (2003), p.2
  23. ^ Hilsdale (2004), p.7

Bibliography

Further reading

Read other articles:

Djamel Mesbah Mesbah (kanan) berlatih bersama Milan tahun 2012.Informasi pribadiNama lengkap Djamel Eddine Mesbah[1]Tanggal lahir 9 Oktober 1984 (umur 39)Tempat lahir Zighoud Youcef, AljazairTinggi 1,80 m (5 ft 11 in)[2]Posisi bermain BekInformasi klubKlub saat ini SampdoriaNomor 3Karier junior1995–2001 US Annecy-le-Vieux2001–2003 ServetteKarier senior*Tahun Tim Tampil (Gol)2003–2004 Servette 11 (3)2004–2006 Basel 11 (1)2006 → Lorient (pinjaman) ...

 

RewriteGenre Drama Fantasi Roman PembuatViu OriginalSkenario Lele Laila Devina Sofiyanti Cerita Susanti Dewi Anji SutradaraFajar NugrosPemeran Maxime Bouttier Audi Marissa Marcell Darwin Sonya Pandarmawan Dewi Rezer Dewi Irawan Hesti Purwadinata Verdi Solaiman Penggubah lagu temaKikan NamaraLagu pembukaKatakanLagu penutupKatakanNegara asal IndonesiaBahasa asliBahasa IndonesiaJmlh. musim1Jmlh. episode13ProduksiProduser eksekutifSahana KamathProduserSusanti DewiLokasi produksi Indone...

 

Kapasitas jalan adalah arus maksimumKapasitas jalan atau daya tampung jalan adalah kemampuan ruas jalan untuk menampung arus atau volume lalu lintas yang ideal dalam satuan waktu tertentu, dinyatakan dalam jumlah kendaraan yang melewati potongan jalan tertentu dalam satu jam (kend/jam), atau dengan mempertimbangan berbagai jenis kendaraan yang melalui suatu jalan digunakan satuan mobil penumpang sebagai satuan kendaraan dalam perhitungan kapasitas maka kapasitas menggunakan satuan satuan mobi...

Gerakan kemerdekaan Taiwan Hanzi tradisional: 臺灣獨立運動 atau 台灣獨立運動 Hanzi sederhana: 台湾独立运动 Alih aksara Mandarin - Hanyu Pinyin: Táiwān dúlì yùndòng - Tongyong Pinyin: Táiwan dúlì yùndòng - Wade-Giles: T'ai²-wan¹ tu²-li⁴ yün⁴-tung⁴ - Gwoyeu Romatzyh: Tair'uan durlih yunndonq - Bopomofo: ㄊㄞˊ ㄨㄢ ㄉㄨˊ ㄌㄧˋ ㄩㄣˋ ㄉㄨㄥˋ Kejia (Hakka) - Romanisasi: Thòi-vân thu̍k-li̍p yun-thung Min Nan - Romanisasi POJ: Tâi-oân t...

 

American academic, homeopathic physician, and politician Royal Copeland redirects here. For another person, see Royal Copeland (Canadian football). Senator Copeland redirects here. For other uses, see Senator Copeland (disambiguation). Royal S. CopelandCopeland in 1923United States Senatorfrom New YorkIn officeMarch 4, 1923 – June 17, 1938Preceded byWilliam M. CalderSucceeded byJames M. MeadMayor of Ann Arbor, MichiganIn office1901–1903Preceded byGottlob LuickSucceeded byArthur B...

 

Suburb of Bunbury, Western Australia East BunburyBunbury, Western AustraliaTranswa Australind train at Bunbury Passenger TerminalEast BunburyCoordinates33°20′29″S 115°39′39″E / 33.3414°S 115.6608°E / -33.3414; 115.6608Population4,019 (SAL 2021)[1]Established1840sPostcode(s)6230Area3.5 km2 (1.4 sq mi)Location4 km (2 mi) from BunburyLGA(s)City of BunburyState electorate(s)BunburyFederal division(s)Forrest Suburbs around E...

City in Mendoza, ArgentinaMalargüeCityPlaza San MartinMalargüeLocation of Malargüe in ArgentinaCoordinates: 35°28.5′S 69°35′W / 35.4750°S 69.583°W / -35.4750; -69.583CountryArgentinaProvinceMendozaDepartmentMalargüeElevation1,402 m (4,600 ft)Population (2010 census) • Total27,660Time zoneUTC-3 (ART)CPA baseM5613Dialing code+54 2627ClimateBSk Malargüe (Spanish pronunciation: [maˈlaɾɣwe]) is a city in the southwest part ...

 

René Plaissetty René Plaissetty en 1919. Données clés Naissance 7 mars 1889Chicago, Illinois Nationalité Américaine Décès 4 janvier 1955 (à 65 ans)Los Angeles, Californie Profession RéalisateurScénaristeProducteur modifier René Alexis Plaissetty est un cinéaste et producteur de cinéma franco-américain, né le 7 mars 1889 à Chicago et mort le 4 janvier 1955 à Los Angeles. Biographie Fils d'Achille Plaissetty[Note 1], chimiste et homme d'affaires et de Corinne Bonnecaze, ...

 

Berikut merupakan daftar 226 komune di département Pyrénées-Orientales, di Prancis. Sebagian besar teritori (kecuali distrik Fenolheda) membentuk bagian dari Kepangeranan Catalunya hingga 1659, dan bahasa Katalan masih dituturkan (selain bahasa Prancis) oleh minoritas populasi. Nama komune dalam Katalan diambil dari Enciclopèdia catalana dan ditujukan sebagai perbandingan dengan nama Prancis resmi: tidak menandakan status linguistik komune saat ini atau sebelumnya. (CATM) Commune forming...

土库曼斯坦总统土库曼斯坦国徽土库曼斯坦总统旗現任谢尔达尔·别尔德穆哈梅多夫自2022年3月19日官邸阿什哈巴德总统府(Oguzkhan Presidential Palace)機關所在地阿什哈巴德任命者直接选举任期7年,可连选连任首任萨帕尔穆拉特·尼亚佐夫设立1991年10月27日 土库曼斯坦土库曼斯坦政府与政治 国家政府 土库曼斯坦宪法 国旗 国徽 国歌 立法機關(英语:National Council of Turkmenistan) ...

 

Charles Gordon-Lennox, VIII duca di RichmondCharles Gordon-Lennox, VIII duca di Richmond, in una fotografia d'epocaDuca di RichmondStemma In carica1928 –1935 PredecessoreCharles Gordon-Lennox, VII duca di Richmond SuccessoreFrederick Gordon-Lennox, IX duca di Richmond TrattamentoSua Grazia Altri titoliDuca di LennoxDuca di GordonDuca d'AubignyConte di MarchConte di DarnleyConte di KinraraBarone SettringtonLord Torbolton NascitaLondra, 30 dicembre 1870 MorteChichester, 7 maggio 19...

 

豪栄道 豪太郎 場所入りする豪栄道基礎情報四股名 澤井 豪太郎→豪栄道 豪太郎本名 澤井 豪太郎愛称 ゴウタロウ、豪ちゃん、GAD[1][2]生年月日 (1986-04-06) 1986年4月6日(38歳)出身 大阪府寝屋川市身長 183cm体重 160kgBMI 47.26所属部屋 境川部屋得意技 右四つ・出し投げ・切り返し・外掛け・首投げ・右下手投げ成績現在の番付 引退最高位 東大関生涯戦歴 696勝493敗...

Polish Humanitarian ActionLogo of the Polish Humanitarian ActionFormation26 December 1992HeadquartersWarsawLocationPolandPresidentJanina OchojskaWebsitepah.org.pl The Polish Humanitarian Action (PAH, pl. Polska Akcja Humanitarna) is a Polish non-governmental organisation which operates in Poland and other countries. Its mission is to make the world a better place through alleviation of human suffering and promotion of humanitarian values. Polish Humanitarian Action (PAH) helps people in crisi...

 

Indian Diamond InstituteMotto in EnglishPassionTechnologyInnovationTypeRegistered SocietyEstablished1978LocationSurat, Gujarat, India21°11′N 72°50′E / 21.18°N 72.83°E / 21.18; 72.83NicknameIDIWebsitediamondinstitute.netSurat Cityscape The Indian Diamond Institute (IDI) is a Government of India sponsored[1] autonomous higher school of learning in the fields of diamonds, gems and jewellery in India.[2] The Institute is located in Surat, Guja...

 

Angkatan Darat Amerika SerikatUnited States ArmyLambang Angkatan Darat Amerika SerikatAktif14 Juni 1775 – saat iniNegara Amerika SerikatTipe unitAngkatan daratJumlah personel485.000 tentara reguler (2021)[1]1.258.472 tentara totalBagian dariAngkatan Bersenjata Amerika Serikat Departemen Angkatan DaratMarkasGedung PentagonArlington County, Virginia, Amerika SerikatJulukanUS ArmyMotoThis We'll DefendIni akan kami pertahankanHimneThe Army Goes Rolling AlongPertempuran Daftar perte...

Untuk yang lain, lihat Oberon (disambiguasi). Pertengkaran Oberon dan Titania. Karya Sir Joseph Paton, 1846 Oberon atau Auberon adalah raja peri, suami dari Titania. Namanya berasal dari abad ke-13 dalam sebuah lagu tradisional Prancis berjudul Les Prouesses et faitz du noble Huon de Bordeaux. Ketika Huon, anak Seguin, berjalan lewat hutan, ia dibantu oleh Oberon untuk membunuh Charlot, anak kaisar. Dalam A Midsummer Night's Dream karya William Shakespeare, ia bertengkar dengan Titania ...

 

Dalam nama Korean ini, nama keluarganya adalah Kim. Kim Byung-chulKim pada bulan Mei 2019Lahir05 Juli 1974 (umur 50)Andong, Provinsi Gyeongsang Utara, Korea SelatanKebangsaanKorea SelatanAlmamaterUniversitas Chung-AngPekerjaanPemeranTahun aktif2003-sekarangAgenAlien Company[1]Anak1Nama KoreaHangul김병철 Alih AksaraGim ByeongcheolMcCune–ReischauerKim Pyŏngchŏl Situs webSitus web resmi Kim Byung-chul (lahir 5 Juli 1974) adalah pemeran Korea Selatan. Ia paling dikenal ka...

 

Blutritt in Weingarten, um 1865 Passionsprozession in Stuttgart-Bad Cannstatt Eine Prozession (von lateinisch procedere „vorrücken, voranschreiten“; in der Bedeutung „Bittprozession“ auch lateinisch Rogatio, von rogare „beten, bitten“) ist ein religiöses Ritual, bei dem eine Menschengruppe einen nach bestimmten Regeln geordneten feierlichen Umzug oder Umgang, meist zu Fuß, vollzieht. Im säkularen Bereich entsprechen ihr Festzug, Parade, Trauerzug, Demonstration. Inhaltsverzeic...

Pour les articles homonymes, voir L'Exorciste et Exorciste (homonymie). Cet article concerne le film. Pour le roman, voir L'Exorciste (roman). Pour la série télévisée, voir L'Exorciste (série télévisée). L'Exorciste Titre original du film Données clés Titre original The Exorcist Réalisation William Friedkin Scénario William Peter Blatty Acteurs principaux Ellen BurstynLinda BlairJason MillerMax von SydowKitty Winn Sociétés de production Warner Bros.Hoya Productions Pays de ...

 

إمبراطورية بارثية إمبراطورية بارثية إمبراطورية ‏ 247 ق.م – ‏ 224 ب.م   الإمبراطورية الفرثيةعلم الإمبراطورية البارثية (المنطقة المظللة) في أقصى امتداد سميت باسم فرثية  عاصمة قطسيفون،[1] إكباتان، قومس، شوشان، نسا، آرشاك، الري نظام الحكم إقطاعية ملكية[2] ...