%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
net.sf.infrared.aspects.AbstractBaseAspect |
|
|
1 | /* |
|
2 | * Copyright 2005 Tavant Technologies and Contributors |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | * |
|
16 | * |
|
17 | * |
|
18 | * Original Author: binil.thomas (Tavant Technologies) |
|
19 | * Contributor(s): -; |
|
20 | * |
|
21 | */ |
|
22 | package net.sf.infrared.aspects; |
|
23 | ||
24 | import net.sf.infrared.agent.MonitorConfig; |
|
25 | import net.sf.infrared.agent.MonitorFacade; |
|
26 | import net.sf.infrared.agent.MonitorFactory; |
|
27 | import net.sf.infrared.agent.StatisticsCollector; |
|
28 | import net.sf.infrared.agent.util.MutableInteger; |
|
29 | import net.sf.infrared.base.model.ExecutionContext; |
|
30 | import net.sf.infrared.base.model.ExecutionTimer; |
|
31 | ||
32 | import org.codehaus.aspectwerkz.joinpoint.StaticJoinPoint; |
|
33 | ||
34 | 0 | public abstract class AbstractBaseAspect { |
35 | public Object recordExecution(ExecutionContext ctx, StaticJoinPoint sjp) throws Throwable { |
|
36 | 0 | return recordExecution(ctx, sjp, MonitorFactory.getFacade()); |
37 | } |
|
38 | ||
39 | public Object recordExecution(ExecutionContext ctx, |
|
40 | StaticJoinPoint sjp, MonitorFacade facade) throws Throwable { |
|
41 | /* |
|
42 | if (sjp == null) { |
|
43 | throw new IllegalArgumentException("Cannot proceed with a null JoinPoint"); |
|
44 | } |
|
45 | if (ctx == null) { |
|
46 | return sjp.proceed(); |
|
47 | }*/ |
|
48 | ||
49 | // @TODO iajc trips over here; find out how to enable JDK 1.4 assertions in iajc |
|
50 | // assert sjp != null: "Cannot proceed with a null JoinPoint"; |
|
51 | // assert ctx != null: "Cannot record timing for a null context"; |
|
52 | ||
53 | 0 | ExecutionTimer timer = new ExecutionTimer(ctx); |
54 | 0 | StatisticsCollector collector = facade.recordExecutionBegin(timer); |
55 | try { |
|
56 | 0 | return sjp.proceed(); |
57 | } finally { |
|
58 | 0 | facade.recordExecutionEnd(timer, collector); |
59 | } |
|
60 | } |
|
61 | ||
62 | public boolean isMonitoringEnabled(){ |
|
63 | 0 | MonitorFacade facade = MonitorFactory.getFacade(); |
64 | 0 | return isMonitoringEnabled(facade); |
65 | } |
|
66 | ||
67 | public boolean isMonitoringEnabled(MonitorFacade facade){ |
|
68 | 0 | MonitorConfig cfg = facade.getConfiguration(); |
69 | 0 | return cfg.isMonitoringEnabled(); |
70 | } |
|
71 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |