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.Collections;
|
21
|
|
using Seasar.Framework.Container.Util;
|
22
|
|
using Seasar.Framework.Container.Deployer;
|
23
|
|
using Seasar.Framework.Beans;
|
24
|
|
|
25
|
|
namespace Seasar.Framework.Container.Impl
|
26
|
|
{
|
27
|
|
|
28
|
|
|
29
|
|
|
30
|
|
public class ComponentDefImpl : IComponentDef
|
31
|
|
{
|
32
|
|
private Type componentType_;
|
33
|
|
private string componentName_;
|
34
|
|
private IS2Container container_;
|
35
|
|
private string expression_;
|
36
|
|
private ArgDefSupport argDefSupport_ = new ArgDefSupport();
|
37
|
|
private PropertyDefSupport propertyDefSupport_ = new PropertyDefSupport();
|
38
|
|
private InitMethodDefSupport initMethodDefSupport_ = new InitMethodDefSupport();
|
39
|
|
private DestroyMethodDefSupport destroyMethodDefSupport_ = new DestroyMethodDefSupport();
|
40
|
|
private AspectDefSupport aspectDefSupport_ = new AspectDefSupport();
|
41
|
|
private MetaDefSupport metaDefSupport_ = new MetaDefSupport();
|
42
|
|
private string instanceMode_ = ContainerConstants.INSTANCE_SINGLETON;
|
43
|
|
private string autoBindingMode_ = ContainerConstants.AUTO_BINDING_AUTO;
|
44
|
|
private IComponentDeployer componentDeployer_;
|
45
|
|
private IDictionary proxies_ = new Hashtable();
|
46
|
|
|
47
|
|
|
48
|
|
|
49
|
|
|
50
|
2
|
public ComponentDefImpl()
|
51
|
|
{
|
52
|
|
}
|
53
|
|
|
54
|
|
|
55
|
|
|
56
|
|
|
57
|
|
|
58
|
105
|
public ComponentDefImpl(Type componentType)
|
59
|
|
: this(componentType,null)
|
60
|
|
{
|
61
|
|
}
|
62
|
|
|
63
|
|
|
64
|
|
|
65
|
|
|
66
|
|
|
67
|
|
|
68
|
789
|
public ComponentDefImpl(Type componentType,string componentName)
|
69
|
|
{
|
70
|
789
|
componentType_ = componentType;
|
71
|
789
|
componentName_ = componentName;
|
72
|
|
}
|
73
|
|
|
74
|
|
#region ComponentDef メンバ
|
75
|
|
|
76
|
151
|
public object GetComponent()
|
77
|
|
{
|
78
|
151
|
return this.ComponentDeployer.Deploy(ComponentType);
|
79
|
|
}
|
80
|
|
|
81
|
485
|
public object GetComponent(Type receiveType)
|
82
|
|
{
|
83
|
485
|
return this.ComponentDeployer.Deploy(receiveType);
|
84
|
|
}
|
85
|
|
|
86
|
4
|
public void InjectDependency(Object outerComponent)
|
87
|
|
{
|
88
|
|
|
89
|
4
|
this.ComponentDeployer.InjectDependency(outerComponent);
|
90
|
|
}
|
91
|
|
|
92
|
|
public IS2Container Container
|
93
|
|
{
|
94
|
1552
|
get
|
95
|
|
{
|
96
|
|
|
97
|
1552
|
return container_;
|
98
|
|
}
|
99
|
788
|
set
|
100
|
|
{
|
101
|
|
|
102
|
788
|
container_ = value;
|
103
|
788
|
argDefSupport_.Container = value;
|
104
|
788
|
metaDefSupport_.Container = value;
|
105
|
788
|
metaDefSupport_.Container = value;
|
106
|
788
|
propertyDefSupport_.Container = value;
|
107
|
788
|
initMethodDefSupport_.Container = value;
|
108
|
788
|
destroyMethodDefSupport_.Container = value;
|
109
|
788
|
aspectDefSupport_.Container = value;
|
110
|
|
}
|
111
|
|
}
|
112
|
|
|
113
|
|
public Type ComponentType
|
114
|
|
{
|
115
|
3662
|
get
|
116
|
|
{
|
117
|
|
|
118
|
3662
|
return componentType_;
|
119
|
|
}
|
120
|
|
}
|
121
|
|
|
122
|
|
public string ComponentName
|
123
|
|
{
|
124
|
590
|
get
|
125
|
|
{
|
126
|
|
|
127
|
590
|
return componentName_;
|
128
|
|
}
|
129
|
|
}
|
130
|
|
|
131
|
|
public string AutoBindingMode
|
132
|
|
{
|
133
|
468
|
get
|
134
|
|
{
|
135
|
|
|
136
|
468
|
return autoBindingMode_;
|
137
|
|
}
|
138
|
660
|
set
|
139
|
|
{
|
140
|
|
|
141
|
660
|
if(AutoBindingUtil.IsAuto(value)
|
142
|
|
|| AutoBindingUtil.IsConstructor(value)
|
143
|
|
|| AutoBindingUtil.IsProperty(value)
|
144
|
|
|| AutoBindingUtil.IsNone(value))
|
145
|
|
{
|
146
|
660
|
autoBindingMode_ = value;
|
147
|
|
}
|
148
|
|
else
|
149
|
|
{
|
150
|
0
|
throw new ArgumentException(value);
|
151
|
|
}
|
152
|
|
}
|
153
|
|
}
|
154
|
|
|
155
|
|
public string InstanceMode
|
156
|
|
{
|
157
|
501
|
get
|
158
|
|
{
|
159
|
|
|
160
|
501
|
return instanceMode_;
|
161
|
|
}
|
162
|
658
|
set
|
163
|
|
{
|
164
|
|
|
165
|
658
|
if(InstanceModeUtil.IsSingleton(value)
|
166
|
|
|| InstanceModeUtil.IsPrototype(value)
|
167
|
|
|| InstanceModeUtil.IsRequest(value)
|
168
|
|
|| InstanceModeUtil.IsSession(value)
|
169
|
|
|| InstanceModeUtil.IsOuter(value))
|
170
|
|
{
|
171
|
658
|
instanceMode_ = value;
|
172
|
|
}
|
173
|
|
else
|
174
|
|
{
|
175
|
0
|
throw new ArgumentException(value);
|
176
|
|
}
|
177
|
|
}
|
178
|
|
}
|
179
|
|
|
180
|
|
public string Expression
|
181
|
|
{
|
182
|
438
|
get
|
183
|
|
{
|
184
|
|
|
185
|
438
|
return expression_;
|
186
|
|
}
|
187
|
55
|
set
|
188
|
|
{
|
189
|
|
|
190
|
55
|
expression_ = value;
|
191
|
|
}
|
192
|
|
}
|
193
|
|
|
194
|
184
|
public void Init()
|
195
|
|
{
|
196
|
|
|
197
|
184
|
this.ComponentDeployer.Init();
|
198
|
|
}
|
199
|
|
|
200
|
726
|
public object GetProxy(Type proxyType)
|
201
|
|
{
|
202
|
0
|
if(proxyType == null) return null;
|
203
|
726
|
return proxies_[proxyType];
|
204
|
|
}
|
205
|
|
|
206
|
39
|
public void AddProxy(Type proxyType, object proxy)
|
207
|
|
{
|
208
|
39
|
proxies_[proxyType] = proxy;
|
209
|
|
}
|
210
|
|
|
211
|
138
|
public void Destroy()
|
212
|
|
{
|
213
|
138
|
this.ComponentDeployer.Destroy();
|
214
|
|
}
|
215
|
|
|
216
|
|
#endregion
|
217
|
|
|
218
|
|
#region IArgDefAware メンバ
|
219
|
|
|
220
|
245
|
public void AddArgDef(IArgDef argDef)
|
221
|
|
{
|
222
|
|
|
223
|
245
|
argDefSupport_.AddArgDef(argDef);
|
224
|
|
}
|
225
|
|
|
226
|
|
public int ArgDefSize
|
227
|
|
{
|
228
|
555
|
get
|
229
|
|
{
|
230
|
|
|
231
|
555
|
return argDefSupport_.ArgDefSize;
|
232
|
|
}
|
233
|
|
}
|
234
|
|
|
235
|
195
|
public IArgDef GetArgDef(int index)
|
236
|
|
{
|
237
|
|
|
238
|
195
|
return argDefSupport_.GetArgDef(index);
|
239
|
|
}
|
240
|
|
|
241
|
|
#endregion
|
242
|
|
|
243
|
|
#region PropertyDefAware メンバ
|
244
|
|
|
245
|
333
|
public void AddPropertyDef(IPropertyDef propertyDef)
|
246
|
|
{
|
247
|
|
|
248
|
333
|
propertyDefSupport_.AddPropertyDef(propertyDef);
|
249
|
|
}
|
250
|
|
|
251
|
|
public int PropertyDefSize
|
252
|
|
{
|
253
|
12
|
get
|
254
|
|
{
|
255
|
|
|
256
|
12
|
return propertyDefSupport_.PropertyDefSize;
|
257
|
|
}
|
258
|
|
}
|
259
|
|
|
260
|
6
|
public IPropertyDef GetPropertyDef(int index)
|
261
|
|
{
|
262
|
|
|
263
|
6
|
return propertyDefSupport_.GetPropertyDef(index);
|
264
|
|
}
|
265
|
|
|
266
|
281
|
public IPropertyDef GetPropertyDef(string propertyName)
|
267
|
|
{
|
268
|
|
|
269
|
281
|
if(this.HasPropertyDef(propertyName))
|
270
|
|
{
|
271
|
281
|
return propertyDefSupport_.GetPropertyDef(propertyName);
|
272
|
|
}
|
273
|
|
else
|
274
|
|
{
|
275
|
0
|
throw new PropertyNotFoundRuntimeException(componentType_,propertyName);
|
276
|
|
}
|
277
|
|
}
|
278
|
|
|
279
|
1460
|
public bool HasPropertyDef(string propertyName)
|
280
|
|
{
|
281
|
|
|
282
|
1460
|
return propertyDefSupport_.HasPropertyDef(propertyName);
|
283
|
|
}
|
284
|
|
|
285
|
|
#endregion
|
286
|
|
|
287
|
|
#region InitMethodDefAware メンバ
|
288
|
|
|
289
|
21
|
public void AddInitMethodDef(IInitMethodDef methodDef)
|
290
|
|
{
|
291
|
|
|
292
|
21
|
initMethodDefSupport_.AddInitMethodDef(methodDef);
|
293
|
|
}
|
294
|
|
|
295
|
|
public int InitMethodDefSize
|
296
|
|
{
|
297
|
475
|
get
|
298
|
|
{
|
299
|
|
|
300
|
475
|
return initMethodDefSupport_.InitMethodDefSize;
|
301
|
|
}
|
302
|
|
}
|
303
|
|
|
304
|
22
|
public IInitMethodDef GetInitMethodDef(int index)
|
305
|
|
{
|
306
|
|
|
307
|
22
|
return initMethodDefSupport_.GetInitMethodDef(index);
|
308
|
|
}
|
309
|
|
|
310
|
|
#endregion
|
311
|
|
|
312
|
|
#region DestroyMethodDefAware メンバ
|
313
|
|
|
314
|
10
|
public void AddDestroyMethodDef(IDestroyMethodDef methodDef)
|
315
|
|
{
|
316
|
|
|
317
|
10
|
destroyMethodDefSupport_.AddDestroyMethodDef(methodDef);
|
318
|
|
}
|
319
|
|
|
320
|
|
public int DestroyMethodDefSize
|
321
|
|
{
|
322
|
142
|
get
|
323
|
|
{
|
324
|
|
|
325
|
142
|
return destroyMethodDefSupport_.DestroyMethodDefSize;
|
326
|
|
}
|
327
|
|
}
|
328
|
|
|
329
|
10
|
public IDestroyMethodDef GetDestroyMethodDef(int index)
|
330
|
|
{
|
331
|
|
|
332
|
10
|
return destroyMethodDefSupport_.GetDestroyMethodDef(index);
|
333
|
|
}
|
334
|
|
|
335
|
|
#endregion
|
336
|
|
|
337
|
|
#region AspectDefAware メンバ
|
338
|
|
|
339
|
42
|
public void AddAspeceDef(IAspectDef aspectDef)
|
340
|
|
{
|
341
|
|
|
342
|
42
|
aspectDefSupport_.AddAspectDef(aspectDef);
|
343
|
|
}
|
344
|
|
|
345
|
|
public int AspectDefSize
|
346
|
|
{
|
347
|
399
|
get
|
348
|
|
{
|
349
|
|
|
350
|
399
|
return aspectDefSupport_.AspectDefSize;
|
351
|
|
}
|
352
|
|
}
|
353
|
|
|
354
|
49
|
public IAspectDef GetAspectDef(int index)
|
355
|
|
{
|
356
|
|
|
357
|
49
|
return aspectDefSupport_.GetAspectDef(index);
|
358
|
|
}
|
359
|
|
|
360
|
|
#endregion
|
361
|
|
|
362
|
|
#region MetaDefAware メンバ
|
363
|
|
|
364
|
0
|
public void AddMetaDef(IMetaDef metaDef)
|
365
|
|
{
|
366
|
|
|
367
|
|
metaDefSupport_.AddMetaDef(metaDef);
|
368
|
|
}
|
369
|
|
|
370
|
0
|
public int MetaDefSize
|
371
|
|
{
|
372
|
|
get
|
373
|
|
{
|
374
|
|
|
375
|
|
return metaDefSupport_.MetaDefSize;
|
376
|
|
}
|
377
|
|
}
|
378
|
|
|
379
|
0
|
public IMetaDef GetMetaDef(int index)
|
380
|
|
{
|
381
|
|
|
382
|
|
return metaDefSupport_.GetMetaDef(index);
|
383
|
|
}
|
384
|
|
|
385
|
0
|
public IMetaDef GetMetaDef(string name)
|
386
|
|
{
|
387
|
|
|
388
|
|
return metaDefSupport_.GetMetaDef(name);
|
389
|
|
}
|
390
|
|
|
391
|
0
|
public IMetaDef[] GetMetaDefs(string name)
|
392
|
|
{
|
393
|
|
|
394
|
|
return metaDefSupport_.GetMetaDefs(name);
|
395
|
|
}
|
396
|
|
|
397
|
|
#endregion
|
398
|
|
|
399
|
|
|
400
|
|
|
401
|
|
|
402
|
|
private IComponentDeployer ComponentDeployer
|
403
|
|
{
|
404
|
962
|
get
|
405
|
|
{
|
406
|
962
|
lock(this)
|
407
|
|
{
|
408
|
962
|
if(componentDeployer_ == null)
|
409
|
|
{
|
410
|
434
|
componentDeployer_ = ComponentDeployerFactory.Create(this);
|
411
|
|
}
|
412
|
962
|
return componentDeployer_;
|
413
|
|
}
|
414
|
|
}
|
415
|
|
}
|
416
|
|
}
|
417
|
|
}
|
418
|
|
|