s2container 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Apache_Software_License_2.0.txt +202 -0
- data/ChangeLog +1 -0
- data/ChangeLog.ja +64 -0
- data/README +9 -0
- data/Rakefile +51 -0
- data/example/example01/example.rb +13 -0
- data/example/example01/run.rb +20 -0
- data/example/example02/example.rb +30 -0
- data/example/example02/run.rb +8 -0
- data/example/example03/example.rb +8 -0
- data/example/example03/run.rb +12 -0
- data/example/example04/example.rb +9 -0
- data/example/example04/run.rb +15 -0
- data/example/example05/example.rb +9 -0
- data/example/example05/run.rb +21 -0
- data/example/example06/example.rb +9 -0
- data/example/example06/run.rb +8 -0
- data/example/example07/example.rb +8 -0
- data/example/example07/run.rb +15 -0
- data/example/example08/example.rb +9 -0
- data/example/example08/run.rb +19 -0
- data/example/example09/example.rb +7 -0
- data/example/example09/run.rb +11 -0
- data/example/example10/example.rb +9 -0
- data/example/example10/run.rb +10 -0
- data/example/example11/example.rb +18 -0
- data/example/example11/run.rb +10 -0
- data/example/example12/example.rb +9 -0
- data/example/example12/run.rb +8 -0
- data/example/example13/example.rb +18 -0
- data/example/example13/example.sql +4 -0
- data/example/example13/run.rb +22 -0
- data/example/example13/sample.db +0 -0
- data/example/example14/example.db +0 -0
- data/example/example14/example.rb +57 -0
- data/example/example14/example.sql +50 -0
- data/example/example14/run1.rb +23 -0
- data/example/example14/run2.rb +28 -0
- data/example/example14/run3.rb +25 -0
- data/example/example14/run4.rb +23 -0
- data/example/example14/run5.rb +35 -0
- data/example/example15/example.rb +20 -0
- data/example/example15/run.rb +28 -0
- data/example/example16/example.rb +15 -0
- data/example/example16/run.rb +24 -0
- data/example/quickstart/quickstart1/quickstart.rb +10 -0
- data/example/quickstart/quickstart2/quickstart.rb +9 -0
- data/example/quickstart/quickstart3/quickstart.rb +9 -0
- data/example/quickstart/quickstart4/quickstart.rb +14 -0
- data/example/quickstart/quickstart5/quickstart.rb +21 -0
- data/example/quickstart/quickstart6/quickstart.rb +28 -0
- data/example/quickstart/quickstart7/quickstart.rb +18 -0
- data/lib/s2container.rb +25 -0
- data/lib/seasar/aop/aspect.rb +30 -0
- data/lib/seasar/aop/interceptor/trace-interceptor.rb +48 -0
- data/lib/seasar/aop/method-invocation.rb +57 -0
- data/lib/seasar/aop/pointcut.rb +53 -0
- data/lib/seasar/aop/s2aop-factory.rb +125 -0
- data/lib/seasar/aop.rb +29 -0
- data/lib/seasar/beans/abstract-property-desc.rb +59 -0
- data/lib/seasar/beans/attribute-accessor-desc.rb +60 -0
- data/lib/seasar/beans/bean-desc-factory.rb +68 -0
- data/lib/seasar/beans/bean-desc.rb +232 -0
- data/lib/seasar/beans/instance-variable-desc.rb +58 -0
- data/lib/seasar/beans.rb +29 -0
- data/lib/seasar/container/arg-def.rb +51 -0
- data/lib/seasar/container/aspect-def.rb +60 -0
- data/lib/seasar/container/aspect-info-def.rb +94 -0
- data/lib/seasar/container/assembler/abstract-assembler.rb +68 -0
- data/lib/seasar/container/assembler/auto-property-assembler.rb +57 -0
- data/lib/seasar/container/assembler/autobinding-auto-def.rb +55 -0
- data/lib/seasar/container/assembler/autobinding-def-factory.rb +57 -0
- data/lib/seasar/container/assembler/autobinding-none-def.rb +53 -0
- data/lib/seasar/container/assembler/manual-constructor-assembler.rb +67 -0
- data/lib/seasar/container/assembler/manual-property-assembler.rb +68 -0
- data/lib/seasar/container/autobinding-def.rb +36 -0
- data/lib/seasar/container/component-def.rb +229 -0
- data/lib/seasar/container/component-info-def.rb +117 -0
- data/lib/seasar/container/deployer/abstract-component-deployer.rb +47 -0
- data/lib/seasar/container/deployer/instance-def-factory.rb +56 -0
- data/lib/seasar/container/deployer/instance-outer-def.rb +44 -0
- data/lib/seasar/container/deployer/instance-prototype-def.rb +44 -0
- data/lib/seasar/container/deployer/instance-singleton-def.rb +42 -0
- data/lib/seasar/container/deployer/outer-component-deployer.rb +47 -0
- data/lib/seasar/container/deployer/prototype-component-deployer.rb +51 -0
- data/lib/seasar/container/deployer/singleton-component-deployer.rb +54 -0
- data/lib/seasar/container/exception/component-notfound-runtime-exception.rb +44 -0
- data/lib/seasar/container/exception/cyclic-reference-runtime-exception.rb +43 -0
- data/lib/seasar/container/exception/illegal-autobinding-def-runtime-exception.rb +43 -0
- data/lib/seasar/container/exception/illegal-instance-def-runtime-exception.rb +44 -0
- data/lib/seasar/container/exception/toomany-registration-runtime-exception.rb +46 -0
- data/lib/seasar/container/instance-def.rb +37 -0
- data/lib/seasar/container/outer-component-def.rb +34 -0
- data/lib/seasar/container/property-def.rb +43 -0
- data/lib/seasar/container/s2application-context.rb +447 -0
- data/lib/seasar/container/s2container-component-def.rb +41 -0
- data/lib/seasar/container/s2container.rb +308 -0
- data/lib/seasar/container/simple-component-def.rb +45 -0
- data/lib/seasar/container/toomany-registration-component-def.rb +69 -0
- data/lib/seasar/container.rb +143 -0
- data/lib/seasar/dbi/dbi-interceptor.rb +97 -0
- data/lib/seasar/dbi/paginate.rb +215 -0
- data/lib/seasar/dbi.rb +26 -0
- data/lib/seasar/exception/notyet-implemented-exception.rb +25 -0
- data/lib/seasar/exception/property-notfound-runtime-exception.rb +48 -0
- data/lib/seasar/exception/s2runtime-exception.rb +35 -0
- data/lib/seasar/exception/unsupported-operation-exception.rb +25 -0
- data/lib/seasar/exception.rb +27 -0
- data/lib/seasar/log/s2logger.rb +75 -0
- data/lib/seasar/log.rb +38 -0
- data/lib/seasar/util/class-util.rb +116 -0
- data/lib/seasar/util.rb +24 -0
- data/setup.rb +1585 -0
- data/test/seasar/aop/test_pointcut.rb +25 -0
- data/test/seasar/aop/test_s2aop_factory.rb +90 -0
- data/test/seasar/beans/test_bean-desc.rb +179 -0
- data/test/seasar/container/assembler/test_auto_property_assembler.rb +87 -0
- data/test/seasar/container/assembler/test_autobinding_def_factory.rb +22 -0
- data/test/seasar/container/assembler/test_manual_property_assembler.rb +59 -0
- data/test/seasar/container/assembler/test_manula_constructor_assembler.rb +59 -0
- data/test/seasar/container/assembler/test_proc_constructor_assembler.rb +61 -0
- data/test/seasar/container/deployer/test_instance_def_factory.rb +24 -0
- data/test/seasar/container/deployer/test_prototype-deployer.rb +25 -0
- data/test/seasar/container/deployer/test_singleton-component-deployer.rb +24 -0
- data/test/seasar/container/s2app_load_sample.rb +6 -0
- data/test/seasar/container/test_arg-def.rb +34 -0
- data/test/seasar/container/test_aspect-info-def.rb +85 -0
- data/test/seasar/container/test_component-def.rb +91 -0
- data/test/seasar/container/test_component-info-def.rb +88 -0
- data/test/seasar/container/test_s2application-context.rb +290 -0
- data/test/seasar/container/test_s2container.rb +268 -0
- data/test/seasar/dbi/test_paginate.rb +265 -0
- data/test/seasar/test_log.rb +20 -0
- data/test/seasar/test_util.rb +46 -0
- data/test/test-suite.rb +7 -0
- metadata +211 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
module Assembler
|
22
|
+
# マニュアルインジェクションでプロパティを設定するアセンブラです。
|
23
|
+
class ManualPropertyAssembler < AbstractAssembler
|
24
|
+
|
25
|
+
# ManualPropertyAssemblerを構築します。
|
26
|
+
# - args
|
27
|
+
# 1. Seasar::Container::ComponentDef <em>component_def</em>
|
28
|
+
def initialize(component_def)
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
# マニュアルプロパティインジェクションを実施します。
|
33
|
+
# - args
|
34
|
+
# 1. Object <em>component</em>
|
35
|
+
# - return
|
36
|
+
# - none
|
37
|
+
#
|
38
|
+
def assemble(component)
|
39
|
+
bean_desc = Seasar::Beans::BeanDescFactory.get_bean_desc(component)
|
40
|
+
prop_descs = bean_desc.typehint_property_descs
|
41
|
+
property_defs = @component_def.get_property_defs
|
42
|
+
@component_def.get_property_defs.each {|property_name, property_def|
|
43
|
+
value = nil
|
44
|
+
if bean_desc.property_descs.key?(property_name)
|
45
|
+
prop_desc = bean_desc.property_descs[property_name]
|
46
|
+
begin
|
47
|
+
value = property_def.value
|
48
|
+
rescue Seasar::Container::Exception::TooManyRegistrationRuntimeException => e
|
49
|
+
if prop_desc.array_acceptable
|
50
|
+
child_component_defs = property_def.container.get_component_def(property_def.value).component_defs
|
51
|
+
value = []
|
52
|
+
for child_component_def in child_component_defs
|
53
|
+
value << child_component_def.component
|
54
|
+
end
|
55
|
+
else
|
56
|
+
raise e
|
57
|
+
end
|
58
|
+
end
|
59
|
+
prop_desc.set_value(component, value)
|
60
|
+
else
|
61
|
+
raise Seasar::Exception::PropertyNotFoundRuntimeException.new(@component_def.component_class, property_name)
|
62
|
+
end
|
63
|
+
}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
class AutoBindingDef
|
22
|
+
AUTO_NAME = :auto
|
23
|
+
NONE_NAME = :none
|
24
|
+
|
25
|
+
#
|
26
|
+
# - args
|
27
|
+
# 1. Seasar::Container::ComponentDef <em>component_def</em>
|
28
|
+
# - return
|
29
|
+
# - Seasar::Container::Assembler::AbstractAssembler
|
30
|
+
#
|
31
|
+
def create_property_assembler(component_def)
|
32
|
+
end
|
33
|
+
attr_accessor :name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
class ComponentDef
|
22
|
+
|
23
|
+
# - args
|
24
|
+
# 1. Class <em>component_class</em>
|
25
|
+
# 2. String|Symbol <em>component_name</em>
|
26
|
+
# 3. Proc <em>procedure</em>
|
27
|
+
def initialize(component_class, component_name = nil, &procedure)
|
28
|
+
@procedure = procedure
|
29
|
+
@onetime_proc = nil
|
30
|
+
@container = nil
|
31
|
+
@component_class = component_class
|
32
|
+
@concreate_class = nil
|
33
|
+
@component_name = component_name.nil? ? Seasar::Util::ClassUtil.ub_name(component_class) : component_name
|
34
|
+
@component_deployer = nil
|
35
|
+
@arg_defs = []
|
36
|
+
@property_defs = {}
|
37
|
+
@aspect_defs = []
|
38
|
+
@instance_def = Seasar::Container::Deployer::InstanceDefFactory.get_instance_def(InstanceDef::SINGLETON_NAME)
|
39
|
+
@autobinding_def = Seasar::Container::Assembler::AutoBindingDefFactory.get_autobinding_def(AutoBindingDef::AUTO_NAME)
|
40
|
+
end
|
41
|
+
attr_accessor :container, :component_class, :component_name, :instance_def, :autobinding_def
|
42
|
+
attr_accessor :procedure, :onetime_proc
|
43
|
+
|
44
|
+
#
|
45
|
+
# - args
|
46
|
+
# - none
|
47
|
+
# - return
|
48
|
+
# - Object
|
49
|
+
#
|
50
|
+
def get_component
|
51
|
+
return self.get_component_deployer.deploy
|
52
|
+
end
|
53
|
+
alias component get_component
|
54
|
+
|
55
|
+
#
|
56
|
+
# - args
|
57
|
+
# 1. Seasar::Container::S2Container <em>container</em>
|
58
|
+
# - return
|
59
|
+
# - none
|
60
|
+
#
|
61
|
+
def container=(container)
|
62
|
+
@container = container
|
63
|
+
@arg_defs.each {|i| i.container = container}
|
64
|
+
@property_defs.each {|i, v| v.container = container}
|
65
|
+
@aspect_defs.each {|i| i.container = container}
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# - args
|
70
|
+
# 1. Integer <em>index</em>
|
71
|
+
# - return
|
72
|
+
# - Seasar::Container::ArgDef
|
73
|
+
#
|
74
|
+
def get_arg_def(index)
|
75
|
+
return @arg_defs[index]
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# - args
|
80
|
+
# - none
|
81
|
+
# - return
|
82
|
+
# - Integer
|
83
|
+
#
|
84
|
+
def get_arg_def_size
|
85
|
+
return @arg_defs.length
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# - args
|
90
|
+
# 1. Seasar::Container::ArgDef <em>arg_def</em>
|
91
|
+
# - return
|
92
|
+
# - none
|
93
|
+
#
|
94
|
+
def add_arg_def(arg_def)
|
95
|
+
if arg_def.container.nil?
|
96
|
+
arg_def.container = @container
|
97
|
+
end
|
98
|
+
@arg_defs << arg_def
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# - args
|
103
|
+
# - none
|
104
|
+
# - return
|
105
|
+
# - Array
|
106
|
+
#
|
107
|
+
def get_arg_defs
|
108
|
+
return @arg_defs
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# - args
|
113
|
+
# 1. Symbol <em>property_name</em>
|
114
|
+
# - return
|
115
|
+
# - Boolean
|
116
|
+
#
|
117
|
+
def has_property_def(property_name)
|
118
|
+
return @property_defs.key?(property_name)
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# - args
|
123
|
+
# 1. String <em>property_name</em>
|
124
|
+
# - return
|
125
|
+
# - Seasar::Container::PropertyDef
|
126
|
+
#
|
127
|
+
def get_property_def(property_name)
|
128
|
+
return @property_defs[property_name]
|
129
|
+
end
|
130
|
+
|
131
|
+
#
|
132
|
+
# - args
|
133
|
+
# - none
|
134
|
+
# - return
|
135
|
+
# - Array
|
136
|
+
#
|
137
|
+
def get_property_defs
|
138
|
+
return @property_defs
|
139
|
+
end
|
140
|
+
|
141
|
+
#
|
142
|
+
# - args
|
143
|
+
# - none
|
144
|
+
# - return
|
145
|
+
# - Integer
|
146
|
+
#
|
147
|
+
def get_property_def_size
|
148
|
+
return @property_defs.length
|
149
|
+
end
|
150
|
+
|
151
|
+
#
|
152
|
+
# - args
|
153
|
+
# 1. Seasar::Container::PropertyDef <em>property_def</em>
|
154
|
+
# - return
|
155
|
+
# - none
|
156
|
+
#
|
157
|
+
def add_property_def(property_def)
|
158
|
+
if property_def.container.nil?
|
159
|
+
property_def.container = @container
|
160
|
+
end
|
161
|
+
@property_defs[property_def.property_name] = property_def
|
162
|
+
end
|
163
|
+
|
164
|
+
#
|
165
|
+
# - args
|
166
|
+
# 1. Integer <em>index</em>
|
167
|
+
# - return
|
168
|
+
# - Seasar::Container::AspectDef
|
169
|
+
#
|
170
|
+
def get_aspect_def(index)
|
171
|
+
return @aspect_defs[index]
|
172
|
+
end
|
173
|
+
|
174
|
+
#
|
175
|
+
# - args
|
176
|
+
# - none
|
177
|
+
# - return
|
178
|
+
# - Integer
|
179
|
+
#
|
180
|
+
def get_aspect_def_size()
|
181
|
+
return @aspect_defs.length
|
182
|
+
end
|
183
|
+
|
184
|
+
#
|
185
|
+
# - args
|
186
|
+
# 1. Seasar::Container::AspectDef <em>aspect_def</em>
|
187
|
+
# - return
|
188
|
+
# - none
|
189
|
+
#
|
190
|
+
def add_aspect_def(aspect_def)
|
191
|
+
@concreate_class = nil
|
192
|
+
if aspect_def.container.nil?
|
193
|
+
aspect_def.container = @container
|
194
|
+
end
|
195
|
+
@aspect_defs << aspect_def
|
196
|
+
end
|
197
|
+
|
198
|
+
#
|
199
|
+
# - args
|
200
|
+
# - none
|
201
|
+
# - return
|
202
|
+
# - Seasar::Container::Deployer::AbstractComponentDeployer
|
203
|
+
#
|
204
|
+
def get_component_deployer
|
205
|
+
if @component_deployer.nil?
|
206
|
+
@component_deployer = @instance_def.create_component_deployer(self)
|
207
|
+
end
|
208
|
+
return @component_deployer
|
209
|
+
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# - args
|
213
|
+
# - none
|
214
|
+
# - return
|
215
|
+
# - Class
|
216
|
+
#
|
217
|
+
def get_concreate_class
|
218
|
+
if @aspect_defs.length == 0
|
219
|
+
return @component_class
|
220
|
+
end
|
221
|
+
if not @concreate_class.nil?
|
222
|
+
return @concreate_class
|
223
|
+
end
|
224
|
+
@concreate_class = Seasar::Aop::S2AopFactory.create(@component_class, @aspect_defs.map {|aspect_def| aspect_def.aspect})
|
225
|
+
return @concreate_class
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
class ComponentInfoDef
|
22
|
+
@@auto_namespace = false
|
23
|
+
|
24
|
+
class << self
|
25
|
+
#
|
26
|
+
# - args
|
27
|
+
# 1. Boolean <em>val</em>
|
28
|
+
# - return
|
29
|
+
# - none
|
30
|
+
#
|
31
|
+
def auto_namespace=(val); @@auto_namespace = val; end
|
32
|
+
|
33
|
+
#
|
34
|
+
# - args
|
35
|
+
# - none
|
36
|
+
# - return
|
37
|
+
# - Boolean
|
38
|
+
#
|
39
|
+
def auto_namespace; return @@auto_namespace; end
|
40
|
+
end
|
41
|
+
|
42
|
+
# - args
|
43
|
+
# 1. Hash <em>options</em>
|
44
|
+
# 1. Proc <em>procedure</em>
|
45
|
+
def initialize(options, &procedure)
|
46
|
+
@component_class = options[:class]
|
47
|
+
@component_name = options[:name]
|
48
|
+
@instance = options[:instance]
|
49
|
+
@autobinding = options[:autobinding]
|
50
|
+
@namespace = options[:namespace]
|
51
|
+
@procedure = procedure
|
52
|
+
end
|
53
|
+
attr_accessor :component_class, :component_name, :instance, :autobinding, :namespace, :procedure
|
54
|
+
|
55
|
+
#
|
56
|
+
# - args
|
57
|
+
# - none
|
58
|
+
# - return
|
59
|
+
# - String
|
60
|
+
#
|
61
|
+
def namespace
|
62
|
+
return @namespace unless @namespace.nil?
|
63
|
+
if @@auto_namespace
|
64
|
+
@namespace = Seasar::Util::ClassUtil.module_name(@component_class).gsub(/::/, '.')
|
65
|
+
end
|
66
|
+
return @namespace
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# - args
|
71
|
+
# 1. Symbol <em>key</em>
|
72
|
+
# - return
|
73
|
+
# - Object
|
74
|
+
#
|
75
|
+
def [](key)
|
76
|
+
return self.instance_variable_get(key)
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# - args
|
81
|
+
# 1. Objectn <em>matcher</em>
|
82
|
+
# - return
|
83
|
+
# - Boolean
|
84
|
+
#
|
85
|
+
def match(matcher)
|
86
|
+
case
|
87
|
+
when matcher.is_a?(Regexp)
|
88
|
+
if @component_name.is_a?(String)
|
89
|
+
if matcher.match(@component_name)
|
90
|
+
return true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
return matcher.match(@component_class.name)
|
94
|
+
when matcher.is_a?(Class)
|
95
|
+
return @component_class == matcher
|
96
|
+
when matcher.is_a?(Module)
|
97
|
+
return @component_class.name.match(/^#{matcher.name}::/)
|
98
|
+
when matcher.is_a?(String)
|
99
|
+
return (matcher == @component_name or matcher == @component_class.name)
|
100
|
+
when matcher.is_a?(Symbol)
|
101
|
+
return (matcher == @component_name or matcher == @component_class.name.to_sym)
|
102
|
+
else
|
103
|
+
raise ArgumentError.new("unsupported argument #{matcher}")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def ==(other)
|
108
|
+
@component_class == other.component_class &&
|
109
|
+
@component_name == other.component_name &&
|
110
|
+
@instance == other.instance &&
|
111
|
+
@autobinding == other.autobinding &&
|
112
|
+
self.namespace() == other.namespace() &&
|
113
|
+
@procedure == other.procedure
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
module Deployer
|
22
|
+
# コンポーネントを組み立てる抽象クラスです。
|
23
|
+
class AbstractComponentDeployer
|
24
|
+
|
25
|
+
# AbstractComponentDeployerを構築します。
|
26
|
+
# - args
|
27
|
+
# 1. Seasar::Container::ComponentDef <em>component_def</em>
|
28
|
+
def initialize(component_def)
|
29
|
+
@component_def = component_def
|
30
|
+
@constructor_assembler = nil
|
31
|
+
@property_assembler = nil
|
32
|
+
self.setup_assembler
|
33
|
+
end
|
34
|
+
|
35
|
+
# デフォルトのアセンブラインスタンスを作成します。
|
36
|
+
# - args
|
37
|
+
# - none
|
38
|
+
# - return
|
39
|
+
# - none
|
40
|
+
def setup_assembler
|
41
|
+
@constructor_assembler = @component_def.autobinding_def.create_constructor_assembler(@component_def)
|
42
|
+
@property_assembler = @component_def.autobinding_def.create_property_assembler(@component_def)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
module Deployer
|
22
|
+
|
23
|
+
# インスタンスの管理方法を表すクラスを生成・管理するファクトリクラスです。
|
24
|
+
class InstanceDefFactory
|
25
|
+
|
26
|
+
@@instance_defs = {}
|
27
|
+
|
28
|
+
#InstanceDefを追加します。
|
29
|
+
# - args
|
30
|
+
# 1. Seasar::Container::InstanceDef <em>instance_def</em>
|
31
|
+
# - return
|
32
|
+
# - none
|
33
|
+
def InstanceDefFactory.add_instance_def(instance_def)
|
34
|
+
@@instance_defs[instance_def.name] = instance_def
|
35
|
+
end
|
36
|
+
|
37
|
+
# 指定された名前のInstanceDefを返します。
|
38
|
+
# - args
|
39
|
+
# 1. Symbol <em>name</em>
|
40
|
+
# - return
|
41
|
+
# - Seasar::Container::InstanceDef
|
42
|
+
def InstanceDefFactory.get_instance_def(name)
|
43
|
+
if not @@instance_defs.key?(name)
|
44
|
+
raise Seasar::Container::Exception::IllegalInstanceDefRuntimeException.new(name)
|
45
|
+
end
|
46
|
+
return @@instance_defs[name]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# InstanceDefFactoryに初期値としてInstanceDefを登録します。
|
51
|
+
InstanceDefFactory.add_instance_def(InstanceSingletonDef.new(Seasar::Container::InstanceDef::SINGLETON_NAME))
|
52
|
+
InstanceDefFactory.add_instance_def(InstancePrototypeDef.new(Seasar::Container::InstanceDef::PROTOTYPE_NAME))
|
53
|
+
InstanceDefFactory.add_instance_def(InstanceOuterDef.new(Seasar::Container::InstanceDef::OUTER_NAME))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
module Deployer
|
22
|
+
|
23
|
+
# インスタンスの管理をOuter Componentと定義するクラスです。
|
24
|
+
class InstanceOuterDef < Seasar::Container::InstanceDef
|
25
|
+
|
26
|
+
# InstanceOuterDefを構築します。
|
27
|
+
# - args
|
28
|
+
# 1. Symbol <em>name</em>
|
29
|
+
def initialize(name)
|
30
|
+
@name = name
|
31
|
+
end
|
32
|
+
|
33
|
+
# OuterComponentDeployerを生成します。
|
34
|
+
# - args
|
35
|
+
# 1. Seasar::Container::ComponentDef <em>component_def</em>
|
36
|
+
# - return
|
37
|
+
# - Seasar::Container::Deployer::OuterComponentDeployer
|
38
|
+
def create_component_deployer(component_def)
|
39
|
+
return OuterComponentDeployer.new(component_def)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
module Deployer
|
22
|
+
|
23
|
+
# インスタンスの管理をPrototypeと定義するクラスです。
|
24
|
+
class InstancePrototypeDef < Seasar::Container::InstanceDef
|
25
|
+
|
26
|
+
# InstancePrototypeDefを構築します。
|
27
|
+
# - args
|
28
|
+
# 1. Symbol <em>name</em>
|
29
|
+
def initialize(name)
|
30
|
+
@name = name
|
31
|
+
end
|
32
|
+
|
33
|
+
# PrototypeComponentDeployerを生成します。
|
34
|
+
# - args
|
35
|
+
# 1. Seasar::Container::ComponentDef <em>component_def</em>
|
36
|
+
# - return
|
37
|
+
# - Seasar::Container::Deployer::PrototypeComponentDeployer
|
38
|
+
def create_component_deployer(component_def)
|
39
|
+
return PrototypeComponentDeployer.new(component_def)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#--
|
3
|
+
# +----------------------------------------------------------------------+
|
4
|
+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
|
5
|
+
# +----------------------------------------------------------------------+
|
6
|
+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
+
# | you may not use this file except in compliance with the License. |
|
8
|
+
# | You may obtain a copy of the License at |
|
9
|
+
# | |
|
10
|
+
# | http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
+
# | |
|
12
|
+
# | Unless required by applicable law or agreed to in writing, software |
|
13
|
+
# | distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
+
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|
15
|
+
# | either express or implied. See the License for the specific language |
|
16
|
+
# | governing permissions and limitations under the License. |
|
17
|
+
# +----------------------------------------------------------------------+
|
18
|
+
#++
|
19
|
+
module Seasar
|
20
|
+
module Container
|
21
|
+
module Deployer
|
22
|
+
#インスタンスの管理をSingletonと定義するクラスです。
|
23
|
+
class InstanceSingletonDef < Seasar::Container::InstanceDef
|
24
|
+
# InstanceSingletonDefを構築します。
|
25
|
+
# - args
|
26
|
+
# 1. Symbol <em>name</em>
|
27
|
+
def initialize(name)
|
28
|
+
@name = name
|
29
|
+
end
|
30
|
+
|
31
|
+
# SingletonComponentDeployerを生成します。
|
32
|
+
# - args
|
33
|
+
# 1. Seasar::Container::ComponentDef <em>component_def</em>
|
34
|
+
# - return
|
35
|
+
# - Seasar::Container::Deployer::SingletonComponentDeployer
|
36
|
+
def create_component_deployer(component_def)
|
37
|
+
return SingletonComponentDeployer.new(component_def)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|