Creating a New JAsCo Aspect

JAsCo aspect beans are used to describe crosscutting concern. For more information about the concepts and syntax of JAsCo aspect beans, we refer to the JAsCo language reference. The JAsCo aspect wizard helps a user to implement JAsCo aspect beans, as it can generate the body of an aspect bean automatically.

Create a new package called aspects. Add a new aspect LoggingAspect by going to FileNewJAsCo Aspect.

Specify LoggingHook as initial hook and specify that a before behavior method should be generated automatically. Click the finish button. The aspect code body is generated automatically and an editor for the aspect is opened.

Adapt the text in the opened editor so that it reflects the code specified below and save it.

package aspects;

class LoggingAspect {
	
	hook LoggingHook {
		
		LoggingHook(method(..args)) {
			execute(method);
		}
		
		before() {
			System.out.println("Method executed");
		}
	}
}

Your Eclipse environment should now look like the one in the following image. Note that the editor automatically colors the JAsCo aspect keywords. If an aspect is compiled, but the aspect contains errors, these are automatically shown in the tasks view.