sialcasa / mvvmFX

an Application Framework for implementing the MVVM Pattern with JavaFX
Apache License 2.0
489 stars 105 forks source link

Document AspectJ configuration for architecture checks #436

Open manuel-mauky opened 8 years ago

manuel-mauky commented 8 years ago

@gbalderas is a student at Saxonia Systems AG and he has worked on configuration for checking violations of the MVVM pattern with AspectJ.

There are 2 tasks to be done for a first proof of concept for this:

gbalderas commented 8 years ago

I'm currently working on this. The branch can be found here: https://github.com/gbalderas/mvvmFX/tree/436_AspectJ/mvvmfx-aspectj

Currently the Model layer is attached to any package and its subpackages of name model on it, like: com.example.model or com.another.example.project.model.also.in.model

The package com.example.mymodel will not work as the model layer.

I'm now working on a way to make it possible that the user can give their own model package names before compiling the project.

gbalderas commented 7 years ago

As it is now I have created a maven-plugin where the user can define their model packages. The plugin then generates the aspects and drops them to a folder inside the project.

I will be pushing my changes soon and also create some documentation for setting this plugin up as well as how to use the generated aspects for maven projects and multi-module projects.

manuel-mauky commented 7 years ago

Is AspectJ compiling the source code or the byte code? If there is another compiler that generates things based on the source code (for example Lombok) then we would have a problem when AspectJ operates on source code too. It wouldn't see the generated code of the other compiler. It would only work if AspectJ operates on bytecode. @gbalderas can you say more about this topic?

gbalderas commented 7 years ago

As far as I know, the AspectJ compiler takes a java class and produces bytecode. It can also take valid java bytecode and produce new bytecode with the weaved advices. So if the Sourcecode or Bytecode is valid it should also be valid for the AspectJ compiler.

Looking into this post we can configure the AspectJ compiler to recompile the bytecode. https://palesz.wordpress.com/2011/12/03/howto-maven-lombok-and-aspectj-together/