1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.Web.SessionState;
|
21
|
|
using Seasar.Framework.Container.Util;
|
22
|
|
using Seasar.Framework.Exceptions;
|
23
|
|
|
24
|
|
namespace Seasar.Framework.Container.Deployer
|
25
|
|
{
|
26
|
|
|
27
|
|
|
28
|
|
|
29
|
|
public class SessionComponentDeployer : AbstractComponentDeployer
|
30
|
|
{
|
31
|
0
|
public SessionComponentDeployer(IComponentDef componentDef)
|
32
|
|
: base(componentDef)
|
33
|
|
{
|
34
|
|
}
|
35
|
|
|
36
|
0
|
public override object Deploy(Type receiveType)
|
37
|
|
{
|
38
|
|
IComponentDef cd = this.ComponentDef;
|
39
|
|
HttpSessionState session = cd.Container.Root.Session;
|
40
|
|
if(session == null)
|
41
|
|
{
|
42
|
|
throw new EmptyRuntimeException("session");
|
43
|
|
}
|
44
|
|
string componentName = cd.ComponentName;
|
45
|
|
if(componentName == null)
|
46
|
|
{
|
47
|
|
throw new EmptyRuntimeException("componentName");
|
48
|
|
}
|
49
|
|
object component = session[componentName];
|
50
|
|
if(component != null) return component;
|
51
|
|
|
52
|
|
component = this.ConstructorAssembler.Assemble();
|
53
|
|
session[componentName] = component;
|
54
|
|
this.PropertyAssembler.Assemble(component);
|
55
|
|
this.InitMethodAssembler.Assemble(component);
|
56
|
|
|
57
|
|
object proxy = GetProxy(receiveType);
|
58
|
|
return proxy == null ? component : proxy;
|
59
|
|
}
|
60
|
|
|
61
|
0
|
public override void InjectDependency(object outerComponent)
|
62
|
|
{
|
63
|
|
throw new NotSupportedException("InjectDependency");
|
64
|
|
}
|
65
|
|
|
66
|
0
|
public override void Init()
|
67
|
|
{
|
68
|
|
}
|
69
|
|
|
70
|
0
|
public override void Destroy()
|
71
|
|
{
|
72
|
|
}
|
73
|
|
|
74
|
|
|
75
|
|
|
76
|
|
|
77
|
|
}
|
78
|
|
}
|
79
|
|
|