1 | 0 | |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
package pt.digitalis.dif.utils.logging; |
7 | |
|
8 | |
import org.aspectj.lang.Signature; |
9 | |
|
10 | |
import pt.digitalis.dif.controller.AbstractDIFDispatcher; |
11 | |
import pt.digitalis.dif.controller.objects.DIFContext; |
12 | |
import pt.digitalis.dif.controller.objects.DIFRequest; |
13 | |
import pt.digitalis.dif.controller.objects.DIFResponse; |
14 | |
import pt.digitalis.log.LogLevel; |
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | 0 | privileged public aspect DIFCoreDebugAspect extends DIFLogAspect { |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
private pointcut dispatcherMethodsWithReturn() : execution(* pt.digitalis.dif.controller.AbstractDIFDispatcher+.validate(..)) || |
32 | |
execution(* pt.digitalis.dif.controller.AbstractDIFDispatcher+.authenticate(..)) || |
33 | 0 | execution(* pt.digitalis.dif.controller.AbstractDIFDispatcher+.authorize(..)); |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | private pointcut contextCreation(DIFRequest difRequest) : execution (* pt.digitalis.dif.controller.AbstractDIFDispatcher+.createContext(..)) && args (difRequest); |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | 0 | private pointcut stageExecution(AbstractDIFDispatcher dispatcher) : execution (* pt.digitalis.dif.controller.AbstractDIFDispatcher+.execute(..)) && this(dispatcher); |
51 | |
|
52 | |
|
53 | 0 | private pointcut difResponseCreation() : call (* pt.digitalis.dif.controller.AbstractDIFDispatcher+.createResponse(..)); |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | 0 | private pointcut serve(Object request, Object response, Object restAction) : execution (* pt.digitalis.dif.controller.AbstractChAL+.serve(..)) && args (request, response, restAction); |
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
after() returning(Object returnValue): dispatcherMethodsWithReturn() |
76 | |
{ |
77 | 0 | super.getLogger().increaseIndentation(); |
78 | |
|
79 | 0 | if (super.getLogger().isDebugEnabled()) |
80 | |
{ |
81 | 0 | Signature signature = thisJoinPointStaticPart.getSignature(); |
82 | 0 | super.getLogger().log( |
83 | 0 | LogLevel.DEBUG, |
84 | 0 | super.getLogger().getIndentationString() + "Method " + signature.getDeclaringType().getName() + "." |
85 | 0 | + signature.getName()); |
86 | |
} |
87 | |
|
88 | 0 | super.getLogger().decreaseIndentation(); |
89 | 0 | } |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
after(DIFRequest difRequest) returning (DIFContext context) : contextCreation(difRequest) |
100 | |
{ |
101 | 0 | super.getLogger().increaseIndentation(); |
102 | |
|
103 | 0 | if (super.getLogger().isDebugEnabled()) |
104 | |
{ |
105 | |
|
106 | 0 | Signature signature = thisJoinPointStaticPart.getSignature(); |
107 | |
|
108 | |
|
109 | 0 | super.getLogger().log( |
110 | 0 | LogLevel.DEBUG, |
111 | 0 | super.getLogger().getIndentationString() + "\n------------------------" + difRequest.toString() |
112 | 0 | + "\nat: " + signature.getDeclaringType().getName() + "." + signature.getName() |
113 | 0 | + "\n------------------------"); |
114 | |
|
115 | 0 | super.getLogger().log( |
116 | 0 | LogLevel.DEBUG, |
117 | 0 | super.getLogger().getIndentationString() + "\n------------------------" + context.toString() |
118 | 0 | + "\nat: " + signature.getDeclaringType().getName() + "." + signature.getName() |
119 | 0 | + "\n------------------------"); |
120 | |
} |
121 | |
|
122 | 0 | super.getLogger().decreaseIndentation(); |
123 | 0 | } |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
before(AbstractDIFDispatcher dispatcher) : stageExecution(dispatcher) |
133 | |
{ |
134 | 0 | super.getLogger().increaseIndentation(); |
135 | |
|
136 | 0 | if (super.getLogger().isDebugEnabled()) |
137 | |
{ |
138 | |
|
139 | 0 | Signature signature = thisJoinPointStaticPart.getSignature(); |
140 | |
|
141 | 0 | super.getLogger().log( |
142 | 0 | LogLevel.DEBUG, |
143 | 0 | super.getLogger().getIndentationString() + "\n------------------------" |
144 | 0 | + dispatcher.difContext.toString() + "\nbefore entering: " |
145 | 0 | + signature.getDeclaringType().getName() + "." + signature.getName() |
146 | 0 | + "\n------------------------"); |
147 | |
} |
148 | 0 | } |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
after(AbstractDIFDispatcher dispatcher) : stageExecution(dispatcher) |
158 | |
{ |
159 | 0 | if (super.getLogger().isDebugEnabled()) |
160 | |
{ |
161 | |
|
162 | 0 | Signature signature = thisJoinPointStaticPart.getSignature(); |
163 | |
|
164 | 0 | super.getLogger().log( |
165 | 0 | LogLevel.DEBUG, |
166 | 0 | super.getLogger().getIndentationString() + "\n------------------------" |
167 | 0 | + dispatcher.difContext.toString() + "\nafter exiting: " |
168 | 0 | + signature.getDeclaringType().getName() + "." + signature.getName() |
169 | 0 | + "\n------------------------"); |
170 | |
} |
171 | |
|
172 | 0 | super.getLogger().decreaseIndentation(); |
173 | 0 | } |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
after() returning (DIFResponse response) : difResponseCreation() |
180 | |
{ |
181 | 0 | super.getLogger().increaseIndentation(); |
182 | |
|
183 | 0 | if (super.getLogger().isDebugEnabled()) |
184 | |
{ |
185 | 0 | Signature signature = thisJoinPointStaticPart.getSignature(); |
186 | |
|
187 | 0 | super.getLogger().log( |
188 | 0 | LogLevel.DEBUG, |
189 | 0 | super.getLogger().getIndentationString() + "\n------------------------" + response.toString() |
190 | 0 | + "\nat: " + signature.getDeclaringType().getName() + "." + signature.getName() |
191 | 0 | + "\n------------------------"); |
192 | |
} |
193 | |
|
194 | 0 | super.getLogger().decreaseIndentation(); |
195 | 0 | } |
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
before(Object request, Object response, Object restAction) : serve(request, response, restAction) |
208 | |
{ |
209 | 0 | super.getLogger().increaseIndentation(); |
210 | |
|
211 | 0 | if (super.getLogger().isDebugEnabled()) |
212 | |
{ |
213 | 0 | Signature signature = thisJoinPointStaticPart.getSignature(); |
214 | 0 | super.getLogger().log( |
215 | 0 | LogLevel.DEBUG, |
216 | 0 | super.getLogger().getIndentationString() + "\n------------------------\n" + request.toString() |
217 | 0 | + "\nat: " + signature.getDeclaringType().getName() + "." + signature.getName() |
218 | 0 | + "\n------------------------"); |
219 | |
} |
220 | 0 | } |
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
after(Object request, Object response, Object restAction) : serve(request, response, restAction) |
233 | |
{ |
234 | 0 | if (super.getLogger().isDebugEnabled()) |
235 | |
{ |
236 | 0 | Signature signature = thisJoinPointStaticPart.getSignature(); |
237 | |
|
238 | |
|
239 | 0 | super.getLogger().log( |
240 | 0 | LogLevel.DEBUG, |
241 | 0 | super.getLogger().getIndentationString() + "\n------------------------\n" + request.toString() |
242 | 0 | + "\nat: " + signature.getDeclaringType().getName() + "." + signature.getName() |
243 | 0 | + "\n------------------------"); |
244 | |
|
245 | 0 | super.getLogger().log( |
246 | 0 | LogLevel.DEBUG, |
247 | 0 | super.getLogger().getIndentationString() + "\n------------------------\n" + response.toString() |
248 | 0 | + "\nat: " + signature.getDeclaringType().getName() + "." + signature.getName() |
249 | 0 | + "\n------------------------"); |
250 | |
} |
251 | |
|
252 | 0 | super.getLogger().decreaseIndentation(); |
253 | 0 | } |
254 | |
|
255 | |
} |