From 83346c92a74caa6f0e139ce3853305b81b0b5b37 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Sun, 18 Dec 2011 12:57:24 +0100 Subject: [PATCH] added REQUEST.execution_variables ... to provide a solution to store data during request execution could be used for SESSION, or any "shared" data inside the same Request --- .../value/visitor/wsf_value_iterator.e | 5 ++ .../value/visitor/wsf_value_null_visitor.e | 4 ++ .../request/value/visitor/wsf_value_visitor.e | 6 ++ .../server/wsf/src/request/value/wsf_any.e | 65 +++++++++++++++++++ library/server/wsf/src/wsf_request.e | 39 +++++++++++ 5 files changed, 119 insertions(+) create mode 100644 library/server/wsf/src/request/value/wsf_any.e diff --git a/library/server/wsf/src/request/value/visitor/wsf_value_iterator.e b/library/server/wsf/src/request/value/visitor/wsf_value_iterator.e index a4c8300e..32ad02fc 100644 --- a/library/server/wsf/src/request/value/visitor/wsf_value_iterator.e +++ b/library/server/wsf/src/request/value/visitor/wsf_value_iterator.e @@ -38,6 +38,11 @@ feature -- Visitor process_iterable_of_value (v) end + process_any (v: WSF_ANY) + do + end + + ;note copyright: "2011-2011, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/library/server/wsf/src/request/value/visitor/wsf_value_null_visitor.e b/library/server/wsf/src/request/value/visitor/wsf_value_null_visitor.e index ffa0bf14..f18dd979 100644 --- a/library/server/wsf/src/request/value/visitor/wsf_value_null_visitor.e +++ b/library/server/wsf/src/request/value/visitor/wsf_value_null_visitor.e @@ -25,6 +25,10 @@ feature -- Visitor do end + process_any (v: WSF_ANY) + do + end + ;note copyright: "2011-2011, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/library/server/wsf/src/request/value/visitor/wsf_value_visitor.e b/library/server/wsf/src/request/value/visitor/wsf_value_visitor.e index 401caa92..0f5bceb4 100644 --- a/library/server/wsf/src/request/value/visitor/wsf_value_visitor.e +++ b/library/server/wsf/src/request/value/visitor/wsf_value_visitor.e @@ -35,6 +35,12 @@ feature -- Visitor deferred end + process_any (v: WSF_ANY) + require + v_attached: v /= Void + deferred + end + ;note copyright: "2011-2011, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/library/server/wsf/src/request/value/wsf_any.e b/library/server/wsf/src/request/value/wsf_any.e new file mode 100644 index 00000000..68d60fd9 --- /dev/null +++ b/library/server/wsf/src/request/value/wsf_any.e @@ -0,0 +1,65 @@ +note + description: "Summary description for {WSF_ANY}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_ANY + +inherit + WSF_VALUE + +create + make + +feature {NONE} -- Initialization + + make (a_name: READABLE_STRING_8; a_value: like item) + do + name := url_decoded_string (a_name) + item := a_value + end + +feature -- Access + + name: READABLE_STRING_32 + + item: detachable ANY + +feature -- Status report + + is_string: BOOLEAN = False + -- Is Current as a WSF_STRING representation? + +feature -- Query + + string_representation: STRING_32 + -- String representation of Current + -- if possible + do + if attached item as i then + Result := i.generating_type + else + Result := "Void" + end + end + +feature -- Visitor + + process (vis: WSF_VALUE_VISITOR) + do + vis.process_any (Current) + end + +note + copyright: "2011-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end diff --git a/library/server/wsf/src/wsf_request.e b/library/server/wsf/src/wsf_request.e index 0db688c9..b6063dc3 100644 --- a/library/server/wsf/src/wsf_request.e +++ b/library/server/wsf/src/wsf_request.e @@ -47,6 +47,10 @@ feature {NONE} -- Initialization raw_post_data_recorded := True create {STRING_32} empty_string.make_empty + create execution_variables_table.make (0) + execution_variables_table.compare_objects + execution_variables := execution_variables_table + initialize analyze end @@ -215,6 +219,39 @@ feature -- Access: global variable end end +feature -- Execution variables + + execution_variable (a_name: READABLE_STRING_8): detachable ANY + -- Execution variable related to `a_name' + require + a_name_valid: a_name /= Void and then not a_name.is_empty + do + if attached execution_variables_table.item (a_name) as v then + Result := v.item + end + end + + execution_variables: ITERABLE [WSF_ANY] + -- Execution variables values + + set_execution_variable (a_name: READABLE_STRING_32; a_value: detachable ANY) + do + execution_variables_table.force (create {WSF_ANY}.make (a_name, a_value), a_name) + ensure + param_set: attached {WSF_ANY} execution_variable (a_name) as val and then val ~ a_value + end + + unset_execution_variable (a_name: READABLE_STRING_32) + do + execution_variables_table.remove (a_name) + ensure + param_unset: execution_variable (a_name) = Void + end + +feature {NONE} -- Execution variables: implementation + + execution_variables_table: HASH_TABLE [WSF_ANY, READABLE_STRING_32] + feature -- Access: CGI Meta variables meta_variable (a_name: READABLE_STRING_8): detachable WSF_STRING @@ -802,6 +839,8 @@ feature {NONE} -- Cookies v := s.substring (i + 1, j - 1) p := j + 1 end + k.left_adjust + k.right_adjust add_value_to_table (k, v, l_cookies) end end