/usr/share/doc/aspectj-doc/progguide/idioms.html is in aspectj-doc 1.8.9-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 4. Idioms</title><link rel="stylesheet" type="text/css" href="aspectj-docs.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="index.html" title="The AspectJTM Programming Guide"><link rel="up" href="index.html" title="The AspectJTM Programming Guide"><link rel="prev" href="examples-reusable.html" title="Reusable Aspects"><link rel="next" href="pitfalls.html" title="Chapter 5. Pitfalls"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. Idioms</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="examples-reusable.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="pitfalls.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="idioms"></a>Chapter 4. Idioms</h1></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="sect1"><a href="idioms.html#idioms-intro">Introduction</a></span></dt></dl></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="idioms-intro"></a>Introduction</h2></div></div></div><p>
This chapter consists of very short snippets of AspectJ code,
typically pointcuts, that are particularly evocative or useful.
This section is a work in progress.
</p><p>
Here's an example of how to enfore a rule that code in the
java.sql package can only be used from one particular package in
your system. This doesn't require any access to code in the
java.sql package.
</p><pre class="programlisting">
/* Any call to methods or constructors in java.sql */
pointcut restrictedCall():
call(* java.sql.*.*(..)) || call(java.sql.*.new(..));
/* Any code in my system not in the sqlAccess package */
pointcut illegalSource():
within(com.foo..*) && !within(com.foo.sqlAccess.*);
declare error: restrictedCall() && illegalSource():
"java.sql package can only be accessed from com.foo.sqlAccess";
</pre><p>Any call to an instance of a subtype of AbstractFacade whose class is
not exactly equal to AbstractFacade:</p><pre class="programlisting">
pointcut nonAbstract(AbstractFacade af):
call(* *(..))
&& target(af)
&& !if(af.getClass() == AbstractFacade.class);
</pre><p> If AbstractFacade is an abstract class or an interface, then every
instance must be of a subtype and you can replace this with: </p><pre class="programlisting">
pointcut nonAbstract(AbstractFacade af):
call(* *(..))
&& target(af);
</pre><p> Any call to a method which is defined by a subtype of
AbstractFacade, but which isn't defined by the type AbstractFacade itself:
</p><pre class="programlisting">
pointcut callToUndefinedMethod():
call(* AbstractFacade+.*(..))
&& !call(* AbstractFacade.*(..));
</pre><p> The execution of a method that is defined in the source code for a
type that is a subtype of AbstractFacade but not in AbstractFacade itself:
</p><pre class="programlisting">
pointcut executionOfUndefinedMethod():
execution(* *(..))
&& within(AbstractFacade+)
&& !within(AbstractFacade)
</pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="examples-reusable.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="pitfalls.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Reusable Aspects </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 5. Pitfalls</td></tr></table></div></body></html>
|