@@ -31,17 +31,7 @@ class WeakReference(Reference):
31
31
32
32
class Definition (object ):
33
33
def __init__ (self , clazz = None , arguments = None , kwargs = None ):
34
- self .module = None
35
- self .function = None
36
-
37
- if clazz :
38
- if isinstance (clazz , list ):
39
- self .module = clazz [0 ]
40
- self .function = clazz [1 ]
41
- else :
42
- self .module = "." .join (clazz .split ("." )[0 :- 1 ])
43
- self .function = clazz .split ("." )[- 1 ]
44
-
34
+ self .clazz = clazz
45
35
self .arguments = {} if arguments is None else arguments
46
36
self .kwargs = {} if kwargs is None else kwargs
47
37
self .method_calls = []
@@ -188,13 +178,23 @@ def build_container(self, container):
188
178
# @todo: start a threaded pool
189
179
190
180
def get_class (self , definition ):
191
- m = importlib .import_module (definition .module )
192
181
193
- f = definition .function .split ("." )
194
- clazz = getattr (m , f [0 ])
182
+ clazz = self .parameter_resolver .resolve (definition .clazz , self .parameters )
183
+
184
+ if isinstance (clazz , list ):
185
+ module = clazz [0 ]
186
+ function = clazz [1 ]
187
+ else :
188
+ module = "." .join (clazz .split ("." )[0 :- 1 ])
189
+ function = clazz .split ("." )[- 1 ]
190
+
191
+ module = importlib .import_module (module )
192
+
193
+ function = function .split ("." )
194
+ clazz = getattr (module , function [0 ])
195
195
196
- if len (f ) == 2 :
197
- return getattr (clazz , f [1 ])
196
+ if len (function ) == 2 :
197
+ return getattr (clazz , function [1 ])
198
198
199
199
return clazz
200
200
@@ -228,7 +228,7 @@ def get_instance(self, klass, definition, container):
228
228
def get_service (self , id , definition , container ):
229
229
230
230
if self .logger :
231
- self .logger .debug ("Get service: id=%s, module =%s, function=%s " % (id , definition .module , definition . function ))
231
+ self .logger .debug ("Get service: id=%s, class =%s" % (id , definition .clazz ))
232
232
233
233
if container .has (id ):
234
234
return container .get (id )
0 commit comments