Migrated most of the example and library to new design.
This commit is contained in:
92
library/server/wsf/router/filter/wsf_filtered_execution.e
Normal file
92
library/server/wsf/router/filter/wsf_filtered_execution.e
Normal file
@@ -0,0 +1,92 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FILTERED_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FILTERED_EXECUTION
|
||||
|
||||
inherit
|
||||
WSF_EXECUTION
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
initialize_filter
|
||||
end
|
||||
|
||||
initialize_filter
|
||||
-- Initialize `filter'
|
||||
do
|
||||
create_filter
|
||||
setup_filter
|
||||
end
|
||||
|
||||
create_filter
|
||||
-- Create `filter'
|
||||
deferred
|
||||
ensure
|
||||
filter_created: filter /= Void
|
||||
end
|
||||
|
||||
setup_filter
|
||||
-- Setup `filter'
|
||||
require
|
||||
filter_created: filter /= Void
|
||||
deferred
|
||||
end
|
||||
|
||||
append_filters (a_filters: ITERABLE [WSF_FILTER])
|
||||
-- Append collection `a_filters' of filters to the end of the `filter' chain.
|
||||
local
|
||||
f: like filter
|
||||
l_next_filter: detachable like filter
|
||||
do
|
||||
from
|
||||
f := filter
|
||||
l_next_filter := f.next
|
||||
until
|
||||
l_next_filter = Void
|
||||
loop
|
||||
f := l_next_filter
|
||||
l_next_filter := f.next
|
||||
end
|
||||
check f_attached_without_next: f /= Void and then f.next = Void end
|
||||
across
|
||||
a_filters as ic
|
||||
loop
|
||||
l_next_filter := ic.item
|
||||
f.set_next (l_next_filter)
|
||||
f := l_next_filter
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
filter: WSF_FILTER
|
||||
-- Filter
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute
|
||||
do
|
||||
filter.execute (request, response)
|
||||
end
|
||||
|
||||
;note
|
||||
copyright: "2011-2015, 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
|
||||
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
|
||||
@@ -48,7 +48,7 @@ feature -- Execution
|
||||
create l_sess
|
||||
router.dispatch (req, res, l_sess)
|
||||
if not l_sess.dispatched then
|
||||
execute_default
|
||||
execute_default (req, res)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -279,7 +279,7 @@ invariant
|
||||
unavailability_duration_xor_unavailable_until: unavailability_duration > 0 implies unavailable_until = Void
|
||||
|
||||
;note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
|
||||
copyright: "2011-2015, 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
|
||||
|
||||
68
library/server/wsf/router/wsf_filtered_routed_execution.e
Normal file
68
library/server/wsf/router/wsf_filtered_routed_execution.e
Normal file
@@ -0,0 +1,68 @@
|
||||
note
|
||||
description: "[
|
||||
Execution which is first filtered, and then pass to the router
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FILTERED_ROUTED_EXECUTION
|
||||
|
||||
inherit
|
||||
WSF_FILTERED_EXECUTION
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_ROUTED_EXECUTION
|
||||
undefine
|
||||
execute
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_FILTER
|
||||
rename
|
||||
execute as filter_execute
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialize
|
||||
|
||||
initialize
|
||||
local
|
||||
f: like filter
|
||||
do
|
||||
Precursor {WSF_ROUTED_EXECUTION}
|
||||
Precursor {WSF_FILTERED_EXECUTION}
|
||||
-- Current is a WSF_FILTER as well in order to call the router
|
||||
-- let's add Current at the end of the filter chain.
|
||||
from
|
||||
f := filter
|
||||
until
|
||||
not attached f.next as l_next
|
||||
loop
|
||||
f := l_next
|
||||
end
|
||||
f.set_next (Current)
|
||||
end
|
||||
|
||||
feature -- Execute Filter
|
||||
|
||||
filter_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter.
|
||||
do
|
||||
router_execute (req, res)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, 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
|
||||
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
|
||||
@@ -7,6 +7,20 @@ note
|
||||
deferred class
|
||||
WSF_ROUTED_EXECUTION
|
||||
|
||||
inherit
|
||||
WSF_EXECUTION
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialize
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
initialize_router
|
||||
end
|
||||
|
||||
feature -- Router
|
||||
|
||||
initialize_router
|
||||
@@ -34,14 +48,6 @@ feature -- Router
|
||||
|
||||
feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
deferred
|
||||
end
|
||||
|
||||
response: WSF_RESPONSE
|
||||
deferred
|
||||
end
|
||||
|
||||
router: WSF_ROUTER
|
||||
-- Router used to dispatch the request according to the WSF_REQUEST object
|
||||
-- and associated request methods
|
||||
@@ -51,19 +57,22 @@ feature -- Execution
|
||||
execute
|
||||
-- Dispatch the request
|
||||
-- and if handler is not found, execute the default procedure `execute_default'.
|
||||
do
|
||||
router_execute (request, response)
|
||||
end
|
||||
|
||||
router_execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
sess: WSF_ROUTER_SESSION
|
||||
do
|
||||
create sess
|
||||
router.dispatch (request, response, sess)
|
||||
router.dispatch (req, res, sess)
|
||||
if not sess.dispatched then
|
||||
execute_default
|
||||
execute_default (req, res)
|
||||
end
|
||||
ensure
|
||||
response_status_is_set: response.status_is_set
|
||||
end
|
||||
|
||||
execute_default
|
||||
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Dispatch requests without a matching handler.
|
||||
local
|
||||
msg: WSF_DEFAULT_ROUTER_RESPONSE
|
||||
@@ -73,4 +82,14 @@ feature -- Execution
|
||||
response.send (msg)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, 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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user