From 59316c9c65058ec7063441573f2cdbafadd80d63 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 20 Nov 2012 13:49:40 +0100 Subject: [PATCH] Added WSF_ROUTER_ITEM to replace a structure represented with named TUPLE Added debug_output to ease debugging --- .../wsf_uri_template_context_mapping.e | 10 +++ library/server/wsf/router/wsf_router.e | 8 +-- library/server/wsf/router/wsf_router_item.e | 69 +++++++++++++++++++ 3 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 library/server/wsf/router/wsf_router_item.e diff --git a/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_mapping.e b/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_mapping.e index 1c4a3a3d..fff3b931 100644 --- a/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_mapping.e +++ b/library/server/wsf/router/support/uri_template_with_context/wsf_uri_template_context_mapping.e @@ -10,6 +10,8 @@ class inherit WSF_ROUTER_CONTEXT_MAPPING [C] + DEBUG_OUTPUT + create make, make_from_template @@ -33,6 +35,14 @@ feature -- Access template: URI_TEMPLATE +feature -- Status report + + debug_output: STRING + -- String that should be displayed in debugger to represent `Current'. + do + Result := "URI-template: " + template.template + end + feature -- Element change set_handler (h: like handler) diff --git a/library/server/wsf/router/wsf_router.e b/library/server/wsf/router/wsf_router.e index 6def1112..fdfa0f22 100644 --- a/library/server/wsf/router/wsf_router.e +++ b/library/server/wsf/router/wsf_router.e @@ -8,7 +8,7 @@ class WSF_ROUTER inherit - ITERABLE [TUPLE [mapping: WSF_ROUTER_MAPPING; request_methods: detachable WSF_ROUTER_METHODS]] + ITERABLE [WSF_ROUTER_ITEM] create make, @@ -39,7 +39,7 @@ feature {NONE} -- Initialization create pre_execution_actions end - mappings: ARRAYED_LIST [TUPLE [mapping: WSF_ROUTER_MAPPING; request_methods: detachable WSF_ROUTER_METHODS]] + mappings: ARRAYED_LIST [WSF_ROUTER_ITEM] -- Existing mappings feature -- Mapping @@ -53,7 +53,7 @@ feature -- Mapping map_with_request_methods (a_mapping: WSF_ROUTER_MAPPING; rqst_methods: detachable WSF_ROUTER_METHODS) -- Map `a_mapping' for request methods `rqst_methods' do - mappings.extend ([a_mapping, rqst_methods]) + mappings.extend (create {WSF_ROUTER_ITEM}.make_with_request_methods (a_mapping, rqst_methods)) a_mapping.handler.on_mapped (a_mapping, rqst_methods) end @@ -161,7 +161,7 @@ feature -- Element change feature -- Traversing - new_cursor: ITERATION_CURSOR [TUPLE [mapping: WSF_ROUTER_MAPPING; request_methods: detachable WSF_ROUTER_METHODS]] + new_cursor: ITERATION_CURSOR [WSF_ROUTER_ITEM] -- Fresh cursor associated with current structure do Result := mappings.new_cursor diff --git a/library/server/wsf/router/wsf_router_item.e b/library/server/wsf/router/wsf_router_item.e new file mode 100644 index 00000000..77e3ae04 --- /dev/null +++ b/library/server/wsf/router/wsf_router_item.e @@ -0,0 +1,69 @@ +note + description: "Summary description for {WSF_ROUTER_ITEM}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_ROUTER_ITEM + +inherit + DEBUG_OUTPUT + +create + make, + make_with_request_methods + +feature {NONE} -- Initialization + + make (m: like mapping) + do + mapping := m + end + + make_with_request_methods (m: like mapping; r: like request_methods) + do + make (m) + set_request_methods (r) + end + +feature -- Access + + mapping: WSF_ROUTER_MAPPING + + request_methods: detachable WSF_ROUTER_METHODS + +feature -- Status report + + debug_output: STRING + -- String that should be displayed in debugger to represent `Current'. + do + if attached {DEBUG_OUTPUT} mapping as d then + create Result.make_from_string (d.debug_output) + else + create Result.make_from_string (mapping.generator) + end + if attached request_methods as mtds then + Result.append_string (" [ ") + across + mtds as c + loop + Result.append_string (c.item) + Result.append_string (" ") + end + Result.append_string ("]") + end + end + +feature -- Change + + set_request_methods (r: like request_methods) + -- Set `request_methods' to `r' + do + request_methods := r + end + +invariant + mapping_attached: mapping /= Void + +end