concept violation in category aspectj

appears as: violation, violation, violations, violations
AspectJ in Action, Second Edition

This is an excerpt from Manning's book AspectJ in Action, Second Edition.

You also modify the Main class to add new Authenticator().authenticate() (and the associated import statements) to test a violation. When you compile the code, the output is as follows:

> ajc –source 5 ajia\messaging\MessageCommunicator.java ajia\main\Main.java
   ajia\security\SecurityAspect.aj ajia\security\*.java
...\ajia\main\Main.java:13 [warning]
   Authentication should be performed only by SecurityAspect
new Authenticator().authenticate();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        method-call(void ajia.security.Authenticator.authenticate())
        see also: ...\ajia\security\SecurityAspect.aj:15::0

As the output shows, the compiler detects and flags the violation and also points to the aspect with the corresponding declare warning statement.

Policy enforcement is a mechanism for ensuring that system components follow certain programming practices, comply with specified rules, and meet any assumptions. If there is no enforcement, errors may go undetected during development and show up only in the deployed system. How would you enforce such policies today? Perhaps you’d use a static code-analysis tool such as PMD or FindBugs that looks for specific code patterns to flag potential programming problems. These tools detect violations of commonly accepted practices. You may also be able to write simple custom policies if you learn the tool’s specific programming language. Even then, you’re limited to policies that static code analysis can detect. Specifically, you can’t enforce policies that need information available only at runtime. Although these tools are excellent additions to most development environments, they aren’t adequate for catching all scenarios.

Figure 11.1. A typical layered architecture for enterprise applications. The arrows indicate the allowed interaction. Any other interaction is in violation of the layering policy.
Listing 11.8. Class to illustrate the violation of publicly exposed fields
package ajia; public class Accessor { public void set() { Exposer exposer = new Exposer(); int exposureCount = exposer.count; exposer.count = 10; } } class Exposer { public final int CONST = 56; public int count; }