From ec1d8ca52f891517025cea4d73e5e62512b88ae7 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Wed, 10 Sep 2014 12:57:34 -0300 Subject: [PATCH 1/2] Updated WSF_ROUTER, to import an existing router definition. --- library/server/wsf/router/wsf_router.e | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/library/server/wsf/router/wsf_router.e b/library/server/wsf/router/wsf_router.e index efd46a6d..92d2f22a 100644 --- a/library/server/wsf/router/wsf_router.e +++ b/library/server/wsf/router/wsf_router.e @@ -59,6 +59,8 @@ feature {NONE} -- Initialization no_handler_set: count = 0 end +feature {WSF_ROUTER} -- Access + mappings: ARRAYED_LIST [WSF_ROUTER_ITEM] -- Existing mappings @@ -91,6 +93,18 @@ feature -- Mapping a_mapping.handler.on_mapped (a_mapping, rqst_methods) end + import (a_router: WSF_ROUTER) + -- Importing an existing router definition `a_router'. + do + across a_router.mappings as c loop + if attached c.item.request_methods as l_methods then + map_with_request_methods (c.item.mapping, l_methods) + else + map (c.item.mapping) + end + end + end + feature -- Mapping handler handle (a_resource: READABLE_STRING_8; f: WSF_ROUTER_MAPPING_FACTORY) @@ -553,7 +567,7 @@ invariant pre_execution_actions_attached: pre_execution_actions /= Void note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software From 4fe5c5da7ea46d45746d3b9e2cf423a6e15cab9c Mon Sep 17 00:00:00 2001 From: jvelilla Date: Fri, 12 Sep 2014 10:54:22 -0300 Subject: [PATCH 2/2] Updated WSF_ROUTER.import feature. --- library/server/wsf/router/wsf_router.e | 45 +++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/library/server/wsf/router/wsf_router.e b/library/server/wsf/router/wsf_router.e index 92d2f22a..bac65e0e 100644 --- a/library/server/wsf/router/wsf_router.e +++ b/library/server/wsf/router/wsf_router.e @@ -59,8 +59,6 @@ feature {NONE} -- Initialization no_handler_set: count = 0 end -feature {WSF_ROUTER} -- Access - mappings: ARRAYED_LIST [WSF_ROUTER_ITEM] -- Existing mappings @@ -79,30 +77,41 @@ feature -- Mapping require a_mapping_attached: a_mapping /= Void do + extend (create {WSF_ROUTER_ITEM}.make_with_request_methods (a_mapping, rqst_methods)) + end + + import (a_mapping_items: ITERABLE [WSF_ROUTER_ITEM]) + -- Import mapping items from `a_mapping_items'. + -- note: this `a_mapping_items' could be an instance of WSF_ROUTER. + do + across + a_mapping_items as ic + loop + extend (ic.item) + end + end + +feature {WSF_ROUTER} -- Mapping + + extend (a_item: WSF_ROUTER_ITEM) + -- Extend `mappings' with `a_item'. + local + l_mapping: WSF_ROUTER_MAPPING + do + l_mapping := a_item.mapping debug ("router") -- Display conflict in mapping - if has_item_associated_with_resource (a_mapping.associated_resource, rqst_methods) then - io.error.put_string ("Mapping: " + a_mapping.debug_output + ": conflict with existing mapping") - if attached item_associated_with_resource (a_mapping.associated_resource, rqst_methods) as l_conflicted then + if has_item_associated_with_resource (l_mapping.associated_resource, a_item.request_methods) then + io.error.put_string ("Mapping: " + l_mapping.debug_output + ": conflict with existing mapping") + if attached item_associated_with_resource (l_mapping.associated_resource, a_item.request_methods) as l_conflicted then io.error.put_string (": " + l_conflicted.debug_output) end io.error.put_string ("%N") end end - mappings.extend (create {WSF_ROUTER_ITEM}.make_with_request_methods (a_mapping, rqst_methods)) - a_mapping.handler.on_mapped (a_mapping, rqst_methods) - end - import (a_router: WSF_ROUTER) - -- Importing an existing router definition `a_router'. - do - across a_router.mappings as c loop - if attached c.item.request_methods as l_methods then - map_with_request_methods (c.item.mapping, l_methods) - else - map (c.item.mapping) - end - end + mappings.extend (a_item) + l_mapping.handler.on_mapped (l_mapping, a_item.request_methods) end feature -- Mapping handler