|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // Bug # 28702
-
- import java.util.Stack;
-
-
-
- interface Connection {
-
- Connection open();
-
- void close();
-
- }
-
-
-
- aspect CloseConnectionsCflow percflow(layerEntryMethods()) {
-
- Stack openConnections;
-
- pointcut layerMethods() :
-
- execution(public * com.example.businessFacade.*.*(..));
-
- pointcut layerEntryMethods() :
-
- layerMethods() && !cflowbelow(layerMethods());
-
- pointcut openedConnection() :
-
- call(* Connection.open(..));
-
- pointcut layerBoundary() : cflow(layerEntryMethods());
-
-
-
- after() returning (Connection conn) :
-
- openedConnection() && layerBoundary() {
-
- openConnections.push(conn);
-
- }
-
- after() : layerBoundary() {
-
- while (!openConnections.empty()) {
-
- Connection conn = (Connection)openConnections.pop();
-
- conn.close();
-
- }
-
- }
-
- }
|