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 AopProxyAspectWeaver : AbstractAspectWeaver
|
12
|
|
{
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
|
18
|
34
|
public override void WeaveAspect(ref object target, Seasar.Framework.Container.IComponentDef componentDef)
|
19
|
|
{
|
20
|
0
|
if (componentDef.AspectDefSize == 0) return;
|
21
|
34
|
Hashtable parameters = new Hashtable();
|
22
|
34
|
parameters[ContainerConstants.COMPONENT_DEF_NAME] = componentDef;
|
23
|
|
|
24
|
34
|
Type[] interfaces = componentDef.ComponentType.GetInterfaces();
|
25
|
34
|
if (componentDef.ComponentType.IsMarshalByRef)
|
26
|
|
{
|
27
|
10
|
AopProxy aopProxy = new AopProxy(componentDef.ComponentType,
|
28
|
|
GetAspects(componentDef), parameters, target);
|
29
|
10
|
componentDef.AddProxy(componentDef.ComponentType, aopProxy.Create());
|
30
|
|
}
|
31
|
24
|
else if (componentDef.ComponentType.IsInterface)
|
32
|
|
{
|
33
|
4
|
AopProxy aopProxy = new AopProxy(componentDef.ComponentType,
|
34
|
|
GetAspects(componentDef), parameters, target);
|
35
|
4
|
target = aopProxy.Create();
|
36
|
|
}
|
37
|
34
|
foreach (Type interfaceType in interfaces)
|
38
|
|
{
|
39
|
29
|
AopProxy aopProxy = new AopProxy(interfaceType,
|
40
|
|
GetAspects(componentDef), parameters, target);
|
41
|
29
|
componentDef.AddProxy(interfaceType, aopProxy.Create());
|
42
|
|
}
|
43
|
|
}
|
44
|
|
}
|
45
|
|
}
|
46
|
|
|