Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DIFIoCLogAspect |
|
| 0.0;0 |
1 | 0 | /** |
2 | * - Digitalis Internal Framework v2.0 - | |
3 | * | |
4 | * (C) 2007, Digitalis Informatica. | |
5 | * | |
6 | * Distribuicao e Gestao de Informatica, Lda. | |
7 | * Estrada de Paco de Arcos num.9 - Piso -1 | |
8 | * 2780-666 Paco de Arcos | |
9 | * Telefone: (351) 21 4408990 | |
10 | * Fax: (351) 21 4408999 | |
11 | * http://www.digitalis.pt | |
12 | */ | |
13 | package pt.digitalis.dif.utils.logging; | |
14 | ||
15 | import pt.digitalis.utils.ioc.IIoCRegistry; | |
16 | ||
17 | /** | |
18 | * Contains the logging logic to be applied on the IoC container | |
19 | * | |
20 | * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a> | |
21 | * @created Oct 3, 2007 | |
22 | * | |
23 | */ | |
24 | 0 | final public aspect DIFIoCLogAspect extends DIFLogAspect { |
25 | ||
26 | /** Holds the start time for the IoC engine */ | |
27 | private long iocStart; | |
28 | ||
29 | /** Saves if the IoC has been started previously */ | |
30 | 0 | static private boolean iocStarted = false; |
31 | ||
32 | /** | |
33 | * Defines the pointcut for the registry instantiation and it's return. | |
34 | */ | |
35 | 0 | protected pointcut IoCRegistryConstructor() : call (* pt.digitalis.dif.ioc.DIFIoCRegistry.getRegistry(..)) && excludeLoggingAppliances(); |
36 | ||
37 | /** | |
38 | * Defines the pointcut for service resolution | |
39 | * | |
40 | * @param clazz | |
41 | * the class that defines the interface param obj the object instantiated | |
42 | */ | |
43 | 0 | protected pointcut IoCRegistryGetService(Class clazz) : call (* pt.digitalis.utils.ioc.IIoCRegistry+.getImplementation(Class)) && args(clazz) && excludeLoggingAppliances(); |
44 | ||
45 | /** | |
46 | * Defines the pointcut for each discovered module | |
47 | */ | |
48 | 0 | protected pointcut IoCRegistryDiscoverModules() : execution (* pt.digitalis.utils.ioc.IIoCRegistry+.discoverModules()) && excludeLoggingAppliances(); |
49 | ||
50 | /** | |
51 | * Captures the discovered config files for module discovery | |
52 | */ | |
53 | 0 | private pointcut IoCConfigFilesFound() : withincode (* pt.digitalis.utils.ioc.AbstractIoCRegistryImpl+.discoverModules()) && call (* pt.digitalis.utils.inspection.ClasspathUtils.getClasspathFileNamesWithExtension(..)) && excludeLoggingAppliances(); |
54 | ||
55 | /** | |
56 | * Logs the start of the startup process of the IoC | |
57 | */ | |
58 | before() : IoCRegistryConstructor() | |
59 | { | |
60 | 0 | if (!iocStarted) { |
61 | 0 | iocStart = System.currentTimeMillis(); |
62 | ||
63 | // Log the message | |
64 | 0 | super.getLogger().info("IoC engine: Initializing..."); |
65 | } | |
66 | 0 | } |
67 | ||
68 | /** | |
69 | * Logs the end of the startup process of the IoC | |
70 | * | |
71 | * @param registry | |
72 | * the registry instantiated | |
73 | */ | |
74 | after() returning (IIoCRegistry registry) : IoCRegistryConstructor() | |
75 | { | |
76 | 0 | if (!iocStarted) { |
77 | // Log the message | |
78 | 0 | super.getLogger().info( |
79 | 0 | "IoC engine: \"" + registry.getClass().getSimpleName() + "\" implementation started in " |
80 | 0 | + (System.currentTimeMillis() - iocStart) + "ms"); |
81 | 0 | iocStarted = true; |
82 | } | |
83 | 0 | } |
84 | ||
85 | /** | |
86 | * Logs each resolution made by the IoC | |
87 | * | |
88 | * @param clazz | |
89 | * the class that defines the service to look for | |
90 | * @param obj | |
91 | * the implementation resolved | |
92 | * | |
93 | */ | |
94 | after(Class clazz) returning (Object obj) : IoCRegistryGetService(clazz) | |
95 | { | |
96 | // Log the message | |
97 | 0 | super.getLogger().debug( |
98 | 0 | "IoC resolved: \"" + clazz.getSimpleName() + "\" -> \"" + obj.getClass().getSimpleName() + "\""); |
99 | 0 | } |
100 | } |