indexing description: "Origo node to build a software and return build results." author: "Patrick Ruckstuhl " date: "$Date$" revision: "$Revision$" class NODE_CONFIG inherit O_NODE_CLIENT redefine register_message_handlers, switches end O_CONFIG_CONSTANTS ARGUMENTS create make feature -- Status is_simulate: BOOLEAN is -- Should actions only be simulated and not executed? once Result := has_option (simulate_switch) end feature -- Access Peer_description: STRING is "Configuration node that allows to configure a server." -- Node's peer description name: STRING is "Origo Config" version: STRING is "$Revision$" feature {NONE} -- Callbacks write_files (a_msg: O_MESSAGE) is -- Write files as specified in a_msg. require a_msg_set: a_msg /= Void local l_args: HASH_TABLE [STRING, STRING] l_file: PLAIN_TEXT_FILE do -- files are specified as contents mapped to their filename from l_args := a_msg.arguments l_args.start until l_args.after loop if is_simulate then io.put_string ("Write: ") io.put_string (l_args.key_for_iteration) io.new_line else create l_file.make (l_args.key_for_iteration) if (l_file.exists and then l_file.is_writable) or l_file.is_creatable then l_file.open_write l_file.put_string (l_args.item_for_iteration) l_file.close end end l_args.forth end end launch_commands (a_msg: O_MESSAGE) is -- Launch commands as described in a_msg. require a_msg_set: a_msg /= Void local l_args: HASH_TABLE [STRING, STRING] l_prc_factory: PROCESS_FACTORY l_prc_launcher: PROCESS do create l_prc_factory -- commands from l_args := a_msg.arguments l_args.start until l_args.after loop if is_simulate then io.put_string ("Exec: ") io.put_string (l_args.item_for_iteration) io.new_line else l_prc_launcher := l_prc_factory.process_launcher_with_command_line (l_args.item_for_iteration, Void) l_prc_launcher.launch if l_prc_launcher.launched then l_prc_launcher.wait_for_exit end end l_args.forth end end feature {NONE} -- Argument handling switches: ARRAYED_LIST [ARGUMENT_SWITCH] is -- Command line switches. once Result := Precursor Result.extend (create {ARGUMENT_SWITCH}.make (simulate_switch, "Only simulate actions?", True, False)) end simulate_switch: STRING is "simulate" feature {NONE} -- Implementation register_message_handlers is -- Register message handlers. do Precursor register_message_handler (config_namespace, config_file_type, agent write_files) register_message_handler (config_namespace, config_command_type, agent launch_commands) register_message_handler (config_namespace, config_release_move_file_type, agent launch_commands) register_message_handler (config_namespace, config_release_delete_file_type, agent launch_commands) register_message_handler (config_namespace, config_user_icon_move_type, agent launch_commands) register_message_handler (config_namespace, config_user_icon_delete_type, agent launch_commands) end end