2222
2323class DefaultFacade (Controller ):
2424 def __init__ (
25- self ,
26- action_mapping_path : str ,
27- internal_action_mapping_path ,
28- logger_configuration ,
29- log_file_path ,
30- component_name = None ,
31- type_mapping = None ,
32- action_mapper : DefaultActionMapper = None , # type: ignore
33- base = ModuleType ,
34- request : Request = None , # type: ignore
35- response : Response = None , # type: ignore
36- configuration : Configuration = None , # type: ignore
37- configuration_path_template = None ,
38- tracing_provider_instance = None ,
39- manifest_path = None ,
40- action_flow_path : Optional [str ] = None ,
41- object_configuration_paths : Optional [str ] = None ,
42- ** kwargs ,
25+ self ,
26+ action_mapping_path : str ,
27+ internal_action_mapping_path ,
28+ logger_configuration ,
29+ log_file_path ,
30+ component_name = None ,
31+ type_mapping = None ,
32+ action_mapper : DefaultActionMapper = None , # type: ignore
33+ base = ModuleType ,
34+ request : Request = None , # type: ignore
35+ response : Response = None , # type: ignore
36+ configuration : Configuration = None , # type: ignore
37+ configuration_path_template = None ,
38+ tracing_provider_instance = None ,
39+ manifest_path = None ,
40+ action_flow_path : Optional [str ] = None ,
41+ object_configuration_paths : Optional [str ] = None ,
42+ ** kwargs ,
4343 ):
4444 """_summary_
4545
@@ -177,7 +177,7 @@ def get_configuration_path(self) -> str:
177177 def get_flow_configuration_path (self ) -> str :
178178 """get the flow configuration path for the component"""
179179 return self .action_flow_path
180-
180+
181181 def get_object_configuration_path (self ) -> str :
182182 """get the object configuration path for the component"""
183183 return self .object_configuration_paths
@@ -192,11 +192,17 @@ def get_action_mapper(self) -> DefaultActionMapper:
192192 internal_config ,
193193 ),
194194 )
195+
195196 def setup (self , ** kwargs ):
196197 """setup the component"""
197198 self .action_mapper = self .get_action_mapper ()
198199 self ._register_type_mapping ()
199200
201+ def register (self , config : InifileConfiguration , ** kwargs ):
202+ """register the component with the system"""
203+ config .add_configuration (self .action_mapping_path )
204+ self .setup (** kwargs )
205+
200206 def unregister (self , config : InifileConfiguration , ** kwargs ):
201207 """unregister the component from the system"""
202208 ObjectFactory .clear_instance (f"{ self .component_name .lower ()} actionmapper" )
@@ -207,28 +213,40 @@ def get_manifest(self, **kwargs):
207213 return self .manifest
208214
209215 def _register_type_mapping (self ):
210- """any component may or may not have a type mapping defined,
211- if it does then it should be registered"""
212- if self .type_mapping :
216+ """Register optional type mappings.
217+
218+ Some legacy FTS components define type_mapping before the Type component
219+ action mapper is available. That must not abort component registration.
220+ """
221+
222+ if not self .type_mapping :
223+ return
224+
225+ actionmapper = ObjectFactory .get_instance ("SyncActionMapper" )
226+
227+ try :
213228 request = ObjectFactory .get_new_instance ("request" )
214229 request .set_action ("RegisterMachineToHumanMapping" )
215230 request .set_value ("machine_to_human_mapping" , self .type_mapping )
216231
217- actionmapper = ObjectFactory .get_instance ("SyncActionMapper" )
218232 response = ObjectFactory .get_new_instance ("response" )
219233 actionmapper .process_action (request , response )
220234
221235 request = ObjectFactory .get_new_instance ("request" )
222236 request .set_action ("RegisterHumanToMachineMapping" )
223- # reverse the mapping and save the reversed mapping
224237 request .set_value (
225- "human_to_machine_mapping" , {k : v for v , k in self .type_mapping .items ()}
238+ "human_to_machine_mapping" ,
239+ {k : v for v , k in self .type_mapping .items ()},
226240 )
227241
228- actionmapper = ObjectFactory .get_instance ("SyncActionMapper" )
229242 response = ObjectFactory .get_new_instance ("response" )
230243 actionmapper .process_action (request , response )
231244
245+ except ValueError as exc :
246+ if "No action key found" in str (exc ):
247+ return
248+ raise
249+
232250 def accept_visitor (self , node : Node , visitor , ** kwargs ):
233251 return node .accept_visitor (visitor )
234252
@@ -244,4 +262,4 @@ def __getstate__(self) -> dict:
244262 set_base = tmp .get ("base" , None )
245263 if set_base is not None :
246264 tmp ["base" ] = True
247- return tmp
265+ return tmp
0 commit comments