s2container 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/Apache_Software_License_2.0.txt +202 -0
  2. data/ChangeLog +1 -0
  3. data/ChangeLog.ja +64 -0
  4. data/README +9 -0
  5. data/Rakefile +51 -0
  6. data/example/example01/example.rb +13 -0
  7. data/example/example01/run.rb +20 -0
  8. data/example/example02/example.rb +30 -0
  9. data/example/example02/run.rb +8 -0
  10. data/example/example03/example.rb +8 -0
  11. data/example/example03/run.rb +12 -0
  12. data/example/example04/example.rb +9 -0
  13. data/example/example04/run.rb +15 -0
  14. data/example/example05/example.rb +9 -0
  15. data/example/example05/run.rb +21 -0
  16. data/example/example06/example.rb +9 -0
  17. data/example/example06/run.rb +8 -0
  18. data/example/example07/example.rb +8 -0
  19. data/example/example07/run.rb +15 -0
  20. data/example/example08/example.rb +9 -0
  21. data/example/example08/run.rb +19 -0
  22. data/example/example09/example.rb +7 -0
  23. data/example/example09/run.rb +11 -0
  24. data/example/example10/example.rb +9 -0
  25. data/example/example10/run.rb +10 -0
  26. data/example/example11/example.rb +18 -0
  27. data/example/example11/run.rb +10 -0
  28. data/example/example12/example.rb +9 -0
  29. data/example/example12/run.rb +8 -0
  30. data/example/example13/example.rb +18 -0
  31. data/example/example13/example.sql +4 -0
  32. data/example/example13/run.rb +22 -0
  33. data/example/example13/sample.db +0 -0
  34. data/example/example14/example.db +0 -0
  35. data/example/example14/example.rb +57 -0
  36. data/example/example14/example.sql +50 -0
  37. data/example/example14/run1.rb +23 -0
  38. data/example/example14/run2.rb +28 -0
  39. data/example/example14/run3.rb +25 -0
  40. data/example/example14/run4.rb +23 -0
  41. data/example/example14/run5.rb +35 -0
  42. data/example/example15/example.rb +20 -0
  43. data/example/example15/run.rb +28 -0
  44. data/example/example16/example.rb +15 -0
  45. data/example/example16/run.rb +24 -0
  46. data/example/quickstart/quickstart1/quickstart.rb +10 -0
  47. data/example/quickstart/quickstart2/quickstart.rb +9 -0
  48. data/example/quickstart/quickstart3/quickstart.rb +9 -0
  49. data/example/quickstart/quickstart4/quickstart.rb +14 -0
  50. data/example/quickstart/quickstart5/quickstart.rb +21 -0
  51. data/example/quickstart/quickstart6/quickstart.rb +28 -0
  52. data/example/quickstart/quickstart7/quickstart.rb +18 -0
  53. data/lib/s2container.rb +25 -0
  54. data/lib/seasar/aop/aspect.rb +30 -0
  55. data/lib/seasar/aop/interceptor/trace-interceptor.rb +48 -0
  56. data/lib/seasar/aop/method-invocation.rb +57 -0
  57. data/lib/seasar/aop/pointcut.rb +53 -0
  58. data/lib/seasar/aop/s2aop-factory.rb +125 -0
  59. data/lib/seasar/aop.rb +29 -0
  60. data/lib/seasar/beans/abstract-property-desc.rb +59 -0
  61. data/lib/seasar/beans/attribute-accessor-desc.rb +60 -0
  62. data/lib/seasar/beans/bean-desc-factory.rb +68 -0
  63. data/lib/seasar/beans/bean-desc.rb +232 -0
  64. data/lib/seasar/beans/instance-variable-desc.rb +58 -0
  65. data/lib/seasar/beans.rb +29 -0
  66. data/lib/seasar/container/arg-def.rb +51 -0
  67. data/lib/seasar/container/aspect-def.rb +60 -0
  68. data/lib/seasar/container/aspect-info-def.rb +94 -0
  69. data/lib/seasar/container/assembler/abstract-assembler.rb +68 -0
  70. data/lib/seasar/container/assembler/auto-property-assembler.rb +57 -0
  71. data/lib/seasar/container/assembler/autobinding-auto-def.rb +55 -0
  72. data/lib/seasar/container/assembler/autobinding-def-factory.rb +57 -0
  73. data/lib/seasar/container/assembler/autobinding-none-def.rb +53 -0
  74. data/lib/seasar/container/assembler/manual-constructor-assembler.rb +67 -0
  75. data/lib/seasar/container/assembler/manual-property-assembler.rb +68 -0
  76. data/lib/seasar/container/autobinding-def.rb +36 -0
  77. data/lib/seasar/container/component-def.rb +229 -0
  78. data/lib/seasar/container/component-info-def.rb +117 -0
  79. data/lib/seasar/container/deployer/abstract-component-deployer.rb +47 -0
  80. data/lib/seasar/container/deployer/instance-def-factory.rb +56 -0
  81. data/lib/seasar/container/deployer/instance-outer-def.rb +44 -0
  82. data/lib/seasar/container/deployer/instance-prototype-def.rb +44 -0
  83. data/lib/seasar/container/deployer/instance-singleton-def.rb +42 -0
  84. data/lib/seasar/container/deployer/outer-component-deployer.rb +47 -0
  85. data/lib/seasar/container/deployer/prototype-component-deployer.rb +51 -0
  86. data/lib/seasar/container/deployer/singleton-component-deployer.rb +54 -0
  87. data/lib/seasar/container/exception/component-notfound-runtime-exception.rb +44 -0
  88. data/lib/seasar/container/exception/cyclic-reference-runtime-exception.rb +43 -0
  89. data/lib/seasar/container/exception/illegal-autobinding-def-runtime-exception.rb +43 -0
  90. data/lib/seasar/container/exception/illegal-instance-def-runtime-exception.rb +44 -0
  91. data/lib/seasar/container/exception/toomany-registration-runtime-exception.rb +46 -0
  92. data/lib/seasar/container/instance-def.rb +37 -0
  93. data/lib/seasar/container/outer-component-def.rb +34 -0
  94. data/lib/seasar/container/property-def.rb +43 -0
  95. data/lib/seasar/container/s2application-context.rb +447 -0
  96. data/lib/seasar/container/s2container-component-def.rb +41 -0
  97. data/lib/seasar/container/s2container.rb +308 -0
  98. data/lib/seasar/container/simple-component-def.rb +45 -0
  99. data/lib/seasar/container/toomany-registration-component-def.rb +69 -0
  100. data/lib/seasar/container.rb +143 -0
  101. data/lib/seasar/dbi/dbi-interceptor.rb +97 -0
  102. data/lib/seasar/dbi/paginate.rb +215 -0
  103. data/lib/seasar/dbi.rb +26 -0
  104. data/lib/seasar/exception/notyet-implemented-exception.rb +25 -0
  105. data/lib/seasar/exception/property-notfound-runtime-exception.rb +48 -0
  106. data/lib/seasar/exception/s2runtime-exception.rb +35 -0
  107. data/lib/seasar/exception/unsupported-operation-exception.rb +25 -0
  108. data/lib/seasar/exception.rb +27 -0
  109. data/lib/seasar/log/s2logger.rb +75 -0
  110. data/lib/seasar/log.rb +38 -0
  111. data/lib/seasar/util/class-util.rb +116 -0
  112. data/lib/seasar/util.rb +24 -0
  113. data/setup.rb +1585 -0
  114. data/test/seasar/aop/test_pointcut.rb +25 -0
  115. data/test/seasar/aop/test_s2aop_factory.rb +90 -0
  116. data/test/seasar/beans/test_bean-desc.rb +179 -0
  117. data/test/seasar/container/assembler/test_auto_property_assembler.rb +87 -0
  118. data/test/seasar/container/assembler/test_autobinding_def_factory.rb +22 -0
  119. data/test/seasar/container/assembler/test_manual_property_assembler.rb +59 -0
  120. data/test/seasar/container/assembler/test_manula_constructor_assembler.rb +59 -0
  121. data/test/seasar/container/assembler/test_proc_constructor_assembler.rb +61 -0
  122. data/test/seasar/container/deployer/test_instance_def_factory.rb +24 -0
  123. data/test/seasar/container/deployer/test_prototype-deployer.rb +25 -0
  124. data/test/seasar/container/deployer/test_singleton-component-deployer.rb +24 -0
  125. data/test/seasar/container/s2app_load_sample.rb +6 -0
  126. data/test/seasar/container/test_arg-def.rb +34 -0
  127. data/test/seasar/container/test_aspect-info-def.rb +85 -0
  128. data/test/seasar/container/test_component-def.rb +91 -0
  129. data/test/seasar/container/test_component-info-def.rb +88 -0
  130. data/test/seasar/container/test_s2application-context.rb +290 -0
  131. data/test/seasar/container/test_s2container.rb +268 -0
  132. data/test/seasar/dbi/test_paginate.rb +265 -0
  133. data/test/seasar/test_log.rb +20 -0
  134. data/test/seasar/test_util.rb +46 -0
  135. data/test/test-suite.rb +7 -0
  136. metadata +211 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/ChangeLog ADDED
@@ -0,0 +1 @@
1
+ under construction
data/ChangeLog.ja ADDED
@@ -0,0 +1,64 @@
1
+
2
+ 2009-04-11 s2container-0.8.0
3
+ * modify: Seasar::Util::ClassUtilで、attribute accessor methodの取得時に親クラスのメソッドは探索しないようにしました。
4
+ * modify: Seasar::Container::S2ApplicationContextをinstance化するように変更しました。
5
+ * add: Seasar::Container::S2ApplicationContextにsnapshotメソッドを追加しました。
6
+
7
+ 2009-02-01 s2container-0.8.0
8
+
9
+ * add: Seasar::Contanier::ComponentInfoDefに、@@auto_namespaceを追加し、@namespaceがnilの場合にmodule名をnamespaceに自動設定できるようにしました。
10
+ * modify: Seasar::Contanier::S2ApplicationContext#get_component_def, has_component_def, createメソッドの引数を、第1引数がコンポーネント名、第2引数がnamespace配列に変更しました。
11
+
12
+ 2009-02-01 s2ruby-0.7.0
13
+
14
+ * info: ruby-1.9.1-p0で動作確認しました。
15
+ * info: s2ruby-0.7.0 release.
16
+
17
+ 2009-01-28 s2ruby-0.7.0
18
+
19
+ * modify: Seasar::Conatiner::ComponentDef#initializeで、コンポーネント名のデフォルト値に、小文字でunder bar区切りとしたコンポーネントクラス名を設定するようにしました。
20
+ * modify: Seasar::Aop::S2AopFactoryで、EnhancedClassに名前を付けるようにしました。
21
+
22
+ 2009-01-18 s2ruby-0.6.0
23
+
24
+ * add: Seasar::Beans::AttributeAccessorDescを追加しました。
25
+ * modify: パッケージのディレクトリ構成を修正しました。
26
+ * info: s2ruby-0.6.0 release.
27
+
28
+ 2009-01-04 s2ruby-0.5.0
29
+
30
+ * info: s2ruby-0.5.0 release.
31
+ * info: ruby-1.9.0-p5で動作確認。Module#public_instance_methodsがSymbolでメソッド名を返すようになったので対応しました。
32
+
33
+ 2009-01-03 s2ruby-0.5.0
34
+
35
+ * modify: ComponentInfoDef、AspectInfoDefでpatternにモジュールが指定された場合は、そのモジュール配下にあるクラスが対象となるようにしました。
36
+
37
+ 2009-01-01 s2ruby-0.5.0
38
+
39
+ * modify: Constructor Blockを持つコンポーネントのクラスがProcの場合は、Constructor Blockを返すようにしました。
40
+ * add: S2ApplicationContextにselectメソッドを追加しました。また、createメソッドにもselector blockを渡せるようにしました。
41
+
42
+ 2008-12-25 s2ruby-0.4.0
43
+
44
+ * info: s2ruby-0.4.0 release.
45
+ * modify: 内部のプロパティ名でSymbolを使用するように修正しました。
46
+ * info: ドキュメント作成
47
+
48
+ 2008-12-10 s2ruby-0.3.0
49
+
50
+ * info: s2ruby-0.3.0 release.
51
+ * info: Exception関連のリファクタリング
52
+ * info: S2ApplicationContext, S2Container, ComponentDefのget, get_component, componentのalias設定
53
+ * info: 文字列定数をSymbolに変更
54
+
55
+ 2008-12-03 s2ruby-0.2.0
56
+
57
+ * info: s2ruby-0.2.0 release.
58
+ * info: ComponentDefのinitializeメソッドでブロック引数に対応しました。
59
+ * info: S2ApplicationContextのリファクタリングとしてComponentInfoDef、AspectInfoDefを追加しました。
60
+ * info: Pointcutクラスを追加しました。
61
+
62
+ 2008-11-20 s2ruby-0.1.0
63
+
64
+ * info: s2ruby-0.1.0 first release.
data/README ADDED
@@ -0,0 +1,9 @@
1
+ == Welcome to S2Container
2
+ S2Container is a Dependency Injection(DI) and Aspect Oriented Programming(AOP) implementation, written in Ruby.
3
+
4
+ == Documents
5
+ Please refer to next URL:
6
+ http://s2container.ruby.sandbox.seasar.org/en/docbook/
7
+
8
+
9
+
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ RUBY_S2CONTAINER_VERSION = '0.8.0'
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+ require 'rake/rdoctask'
7
+ require 'rake/packagetask'
8
+ require 'rake/gempackagetask'
9
+
10
+ task :default => [:test]
11
+
12
+ Rake::TestTask.new('test') do |t|
13
+ t.libs << 'lib'
14
+ t.pattern = 'test/**/test_*.rb'
15
+ t.verbose = true
16
+ t.ruby_opts = ['-r test/unit']
17
+ end
18
+
19
+ spec = Gem::Specification.new do |s|
20
+ s.name = 's2container'
21
+ s.date = '2009-04-01'
22
+ s.version = RUBY_S2CONTAINER_VERSION
23
+ s.authors = ['klove']
24
+ s.email = 'klovelion@gmail.com'
25
+ s.homepage = 'http://s2container.ruby.sandbox.seasar.org/'
26
+ s.platform = Gem::Platform::RUBY
27
+ s.summary = 's2container on ruby'
28
+ s.description = 'S2Container is a Dependency Injection(DI) and Aspect Oriented Programming(AOP) implementation, written in Ruby'
29
+ s.files = [ "README", "ChangeLog.ja", "ChangeLog", "Apache_Software_License_2.0.txt", "setup.rb", "Rakefile"]
30
+ s.files += Dir['lib/**/*.rb']
31
+ s.files += Dir['test/**/*.rb']
32
+ s.files += Dir['example/**/*']
33
+ s.require_path = 'lib'
34
+ s.has_rdoc = false
35
+ s.required_ruby_version = '>= 1.8.7'
36
+ s.test_file = 'test/test-suite.rb'
37
+ s.bindir = 'bin'
38
+ end
39
+
40
+ Rake::GemPackageTask.new(spec) do |pkg|
41
+ pkg.need_zip = true
42
+ pkg.need_tar = true
43
+ end
44
+
45
+ Rake::RDocTask.new('doc') do |rd|
46
+ rd.rdoc_files.include("lib/**/*.rb")
47
+ rd.main = 'Seasar::Container'
48
+ rd.rdoc_dir = 'doc'
49
+ rd.title = "S2Container.Ruby"
50
+ rd.options << '--line-numbers' << '--inline-source' << '-c UTF-8'
51
+ end
@@ -0,0 +1,13 @@
1
+ module Example
2
+ class IndexAction
3
+ s2component :name => "index"
4
+ end
5
+
6
+ class TopAction
7
+ s2component :name => :top
8
+ end
9
+
10
+ class ResultAction
11
+ s2component
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ container = s2app.create
7
+ component = container.get_component('index')
8
+ p component
9
+
10
+ container = s2app.create
11
+ component = container.component(Example::IndexAction)
12
+ p component
13
+
14
+ container = s2app.create
15
+ component = container.get(:top)
16
+ p component
17
+
18
+ container = s2app.create
19
+ component = container[Example::ResultAction]
20
+ p component
@@ -0,0 +1,30 @@
1
+ module Example
2
+ class Action
3
+ s2comp
4
+ def initialize
5
+ @a = nil
6
+ @b = :di, "x.y.z.service_b"
7
+ @c = :di, ServiceC
8
+ @x_ = nil
9
+ @_x = nil
10
+ end
11
+ attr_reader :a, :b, :c
12
+ attr_accessor :d
13
+ end
14
+
15
+ class ServiceA
16
+ s2comp :name => :a
17
+ end
18
+
19
+ class ServiceB
20
+ s2comp :name => "service_b", :namespace => "x.y.z"
21
+ end
22
+
23
+ class ServiceC
24
+ s2comp
25
+ end
26
+
27
+ class ServiceD
28
+ s2comp :name => :d
29
+ end
30
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ container = s2app.create
7
+ component = container[Example::Action]
8
+ p component
@@ -0,0 +1,8 @@
1
+ module Example
2
+ class Action
3
+ def initialize(val)
4
+ @val = val
5
+ end
6
+ attr_reader :val
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ s2component(:class => Example::Action) {
7
+ Example::Action.new("abc")
8
+ }
9
+
10
+ container = s2app.create
11
+ component = container[Example::Action]
12
+ p component.val
@@ -0,0 +1,9 @@
1
+ module Example
2
+ class Action
3
+ s2comp :instance => :prototype
4
+ def initialize(val)
5
+ @val = val
6
+ end
7
+ attr_reader :val
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ container = s2app.create
7
+ component = container.get_component(Example::Action) {
8
+ Example::Action.new("abc")
9
+ }
10
+ p component.val # -> "abc"
11
+
12
+ component = container.get_component(Example::Action) {
13
+ Example::Action.new("xyz")
14
+ }
15
+ p component.val # -> "xyz"
@@ -0,0 +1,9 @@
1
+ module Example
2
+ class Action
3
+ s2comp
4
+ end
5
+
6
+ class Service
7
+ s2comp :namespace => "services"
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ container = s2app.create
7
+ component = container.get_component(Example::Action)
8
+ p component
9
+ component = container.get_component(Example::Service)
10
+ p component
11
+
12
+
13
+ container = s2app.create("services")
14
+ begin
15
+ component = container.get_component(Example::Action)
16
+ rescue => err
17
+ puts err.message
18
+ end
19
+ component = container.get_component(Example::Service)
20
+ p component
21
+
@@ -0,0 +1,9 @@
1
+ module Example
2
+ class Action
3
+ s2comp
4
+ s2aspect :interceptor => "interceptor.trace", :pointcut => :index
5
+ def index
6
+ s2logger.debug(self.class.superclass) {"index action called."}
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ container = s2app.create
7
+ component = container.get(Example::Action)
8
+ component.index
@@ -0,0 +1,8 @@
1
+ module Example
2
+ class Action
3
+ s2comp :name => :action
4
+ def index
5
+ s2logger.debug(self.class.superclass) {"index action called."}
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ s2aspect(:pattern => :action, :pointcut => :index) {|invocation|
7
+ s2logger.debug(invocation.component_class) {"before"}
8
+ result = invocation.proceed
9
+ s2logger.debug(invocation.component_class) {"after "}
10
+ next result
11
+ }
12
+
13
+ container = s2app.create
14
+ component = container.get(:action)
15
+ component.index
@@ -0,0 +1,9 @@
1
+ module Example
2
+ class Action
3
+ s2comp
4
+ end
5
+
6
+ class Service
7
+ s2comp :namespace => "services"
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ global_action = s2app.get(Example::Action)
7
+ p global_action
8
+ global_service = s2app.get(Example::Service)
9
+ p global_service
10
+
11
+ begin
12
+ services_action = s2app.get(Example::Action, "services")
13
+ rescue => err
14
+ puts err.message
15
+ end
16
+ services_service = s2app.get(Example::Service, "services")
17
+ p services_service
18
+ p global_service != services_service
19
+
@@ -0,0 +1,7 @@
1
+ module Example
2
+ class Service
3
+ def add(a, b)
4
+ return a + b
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ interceptor = Seasar::Aop::Interceptor::TraceInterceptor.new
7
+ pointcut = Seasar::Aop::Pointcut.new(/^add$/)
8
+ aspect = Seasar::Aop::Aspect.new(interceptor, pointcut)
9
+ service = Seasar::Aop::S2AopFactory::create(Example::Service, [aspect]).new
10
+
11
+ p service.add(2, 3)
@@ -0,0 +1,9 @@
1
+ module Example
2
+ class Service
3
+ s2comp
4
+ def add(a, b)
5
+ puts "#{self.class.superclass.name}.add called."
6
+ return a + b
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ s2app.aspect(:pattern => Example::Service, :interceptor => Seasar::Aop::Interceptor::TraceInterceptor.new)
7
+ container = s2app.create
8
+ service = container.get(Example::Service)
9
+
10
+ p service.add(2, 3)
@@ -0,0 +1,18 @@
1
+ module Example
2
+ class Service
3
+ s2comp
4
+ def add(a, b)
5
+ puts "#{self.class.superclass.name}.add called."
6
+ return a + b
7
+ end
8
+ end
9
+
10
+ class SampleInterceptor
11
+ def call(invocation)
12
+ puts 'Before' # <-- 次のインターセプターや実際のメソッドを呼び出す前の処理
13
+ result = invocation.proceed
14
+ puts 'After' # <-- 次のインターセプターや実際のメソッドを呼び出した後の処理
15
+ return result
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ s2app.aspect(:pattern => Example::Service, :interceptor => Example::SampleInterceptor.new)
7
+ container = s2app.create
8
+ service = container.get(Example::Service)
9
+
10
+ p service.add(2, 3)
@@ -0,0 +1,9 @@
1
+ module Example
2
+ class Service
3
+ s2comp
4
+ def initialize
5
+ @container = :container
6
+ end
7
+ attr_reader :container
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File::expand_path(File::dirname(__FILE__)) + '/../../lib')
2
+
3
+ require 's2container'
4
+ require 'example'
5
+
6
+ service = s2app.get(Example::Service)
7
+ p service.container.class.name
8
+