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 Seasar.Framework.Exceptions;
|
21
|
|
using Seasar.Framework.Util;
|
22
|
|
using Seasar.Framework.Xml;
|
23
|
|
|
24
|
|
namespace Seasar.Framework.Container.Factory
|
25
|
|
{
|
26
|
|
|
27
|
|
|
28
|
|
|
29
|
|
public static class SingletonS2ContainerFactory
|
30
|
|
{
|
31
|
|
private static string configPath_ = "app.dicon";
|
32
|
|
private static IS2Container container_;
|
33
|
|
|
34
|
1
|
static SingletonS2ContainerFactory()
|
35
|
|
{
|
36
|
1
|
S2Section config = S2SectionHandler.GetS2Section();
|
37
|
1
|
if (config != null)
|
38
|
|
{
|
39
|
1
|
string configPath = config.ConfigPath;
|
40
|
1
|
if (!StringUtil.IsEmpty(configPath)) configPath_ = configPath;
|
41
|
|
}
|
42
|
|
}
|
43
|
|
|
44
|
|
public static string ConfigPath
|
45
|
|
{
|
46
|
2
|
set { configPath_ = value; }
|
47
|
3
|
get { return configPath_; }
|
48
|
|
}
|
49
|
|
|
50
|
44
|
public static void Init()
|
51
|
|
{
|
52
|
44
|
container_ = S2ContainerFactory.Create(configPath_);
|
53
|
44
|
container_.Init();
|
54
|
|
}
|
55
|
|
|
56
|
44
|
public static void Destroy()
|
57
|
|
{
|
58
|
44
|
if (container_ != null)
|
59
|
|
{
|
60
|
44
|
container_.Destroy();
|
61
|
44
|
container_ = null;
|
62
|
|
}
|
63
|
|
}
|
64
|
|
|
65
|
|
public static IS2Container Container
|
66
|
|
{
|
67
|
42
|
get
|
68
|
|
{
|
69
|
42
|
if(container_ == null)
|
70
|
0
|
throw new EmptyRuntimeException("S2Container");
|
71
|
42
|
return container_;
|
72
|
|
}
|
73
|
0
|
set
|
74
|
|
{
|
75
|
|
container_ = value;
|
76
|
|
}
|
77
|
|
}
|
78
|
|
|
79
|
0
|
public static bool HasContainer
|
80
|
|
{
|
81
|
|
get { return container_ != null; }
|
82
|
|
}
|
83
|
|
|
84
|
|
}
|
85
|
|
}
|
86
|
|
|