1
|
|
using System;
|
2
|
|
using System.Collections;
|
3
|
|
using Seasar.Framework.Container;
|
4
|
|
using Seasar.Framework.Aop.Proxy;
|
5
|
|
|
6
|
|
namespace Seasar.Framework.Aop.Impl
|
7
|
|
{
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
public class DynamicAopProxyAspectWeaver : AbstractAspectWeaver
|
12
|
|
{
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
|
18
|
0
|
public override void WeaveAspect(ref object target, Seasar.Framework.Container.IComponentDef componentDef)
|
19
|
|
{
|
20
|
|
if (componentDef.AspectDefSize == 0) return;
|
21
|
|
Hashtable parameters = new Hashtable();
|
22
|
|
parameters[ContainerConstants.COMPONENT_DEF_NAME] = componentDef;
|
23
|
|
|
24
|
|
Type[] interfaces = componentDef.ComponentType.GetInterfaces();
|
25
|
|
|
26
|
|
if (!componentDef.ComponentType.IsInterface)
|
27
|
|
{
|
28
|
|
DynamicAopProxy aopProxy = new DynamicAopProxy(componentDef.ComponentType,
|
29
|
|
GetAspects(componentDef), parameters, target);
|
30
|
|
target = aopProxy.Create();
|
31
|
|
}
|
32
|
|
else
|
33
|
|
{
|
34
|
|
this.AddProxy(ref target, componentDef, componentDef.ComponentType, parameters);
|
35
|
|
}
|
36
|
|
|
37
|
|
foreach (Type interfaceType in interfaces)
|
38
|
|
{
|
39
|
|
this.AddProxy(ref target, componentDef, interfaceType, parameters);
|
40
|
|
}
|
41
|
|
}
|
42
|
|
|
43
|
|
|
44
|
|
|
45
|
|
|
46
|
|
|
47
|
|
|
48
|
|
|
49
|
0
|
protected void AddProxy(ref object target, IComponentDef componentDef, Type type, Hashtable parameters)
|
50
|
|
{
|
51
|
|
DynamicAopProxy aopProxy = new DynamicAopProxy(type,
|
52
|
|
GetAspects(componentDef), parameters, target);
|
53
|
|
componentDef.AddProxy(type, aopProxy.Create());
|
54
|
|
}
|
55
|
|
}
|
56
|
|
}
|
57
|
|
|