Added SCOOP support for WSF.

WSF_SERVICE is deeply changed, and addition of WSF_EXECUTION.
Todo: code cleaning, removing useless things.
This commit is contained in:
2015-03-24 23:21:49 +01:00
parent ddf73077b3
commit bf0eb9a02d
51 changed files with 951 additions and 316 deletions

View File

@@ -4,21 +4,11 @@ note
revision: "$Revision$"
class
WGI_CGI_CONNECTOR
WGI_CGI_CONNECTOR [G -> WGI_EXECUTION create make end]
inherit
WGI_CONNECTOR
create
make
feature {NONE} -- Initialization
make (a_service: like service)
do
service := a_service
end
feature -- Access
Name: STRING_8 = "CGI"
@@ -27,24 +17,23 @@ feature -- Access
Version: STRING_8 = "0.1"
-- Version of Current connector
feature {NONE} -- Access
service: WGI_SERVICE
-- Gateway Service
feature -- Execution
launch
local
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_RESPONSE_STREAM
exec: detachable WGI_EXECUTION
rescued: BOOLEAN
do
if not rescued then
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment, create {WGI_CGI_INPUT_STREAM}.make, Current)
create res.make (create {WGI_CGI_OUTPUT_STREAM}.make, create {WGI_CGI_ERROR_STREAM}.make)
service.execute (req, res)
create {G} exec.make (req, res)
exec.execute
res.flush
res.push
exec.clean
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
@@ -59,6 +48,9 @@ feature -- Execution
res.push
end
end
if exec /= Void then
exec.clean
end
end
rescue
if not rescued then

View File

@@ -17,33 +17,16 @@ feature {NONE} -- Initialization
make
-- Initialize `Current'.
local
server: separate HTTPD_SERVER
fac: separate WSF_HTTPD_REQUEST_HANDLER_FACTORY [APP_WSF_EXECUTION]
conn: WGI_HTTPD_CONNECTOR [APP_WSF_EXECUTION]
do
print ("Hello%N")
create fac
create server.make (fac)
launch_server (server)
print ("Starting httpd server ...%N")
create conn.make
conn.set_port_number (9090)
conn.set_max_concurrent_connections (100)
conn.launch
end
launch_server (server: separate HTTPD_SERVER)
do
server.configuration.set_max_concurrent_connections (100)
server.configuration.set_http_server_port (9090)
server.launch
end
feature -- Status
feature -- Access
feature -- Change
feature {NONE} -- Implementation
invariant
-- invariant_clause: True
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -7,8 +7,9 @@
<exclude>/\.git$</exclude>
<exclude>/\.svn$</exclude>
</file_rule>
<option debug="true" warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<option debug="false" warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<debug name="dbglog" enabled="true"/>
<assertions precondition="true"/>
</option>
<setting name="concurrency" value="scoop"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
@@ -31,13 +32,12 @@
</condition>
</library>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="wsf" location="..\..\..\wsf\wsf-safe.ecf" readonly="false"/>
<cluster name="httpd_server" location=".\src\httpd\" recursive="true">
<file_rule>
<exclude>/concurrency$</exclude>
<exclude>/ssl$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/no_ssl$</exclude>
<exclude>/ssl$</exclude>
<exclude>/concurrency$</exclude>
</file_rule>
<cluster name="no_ssl" location="$|no_ssl\" recursive="true">
<condition>
@@ -73,11 +73,12 @@
</target>
<target name="dev" extends="connector_httpd">
<root class="HTTPD_CONNECTOR_DEV" feature="make"/>
<option debug="true">
<option debug="false">
<debug name="dbglog" enabled="true"/>
<assertions precondition="true" postcondition="true" check="true" supplier_precondition="true"/>
</option>
<setting name="concurrency" value="scoop"/>
<library name="wsf" location="..\..\..\wsf\wsf-safe.ecf" readonly="false"/>
<cluster name="dev" location="dev\" recursive="true"/>
</target>
<target name="dev_mt" extends="dev">

View File

@@ -42,7 +42,7 @@ feature -- Execution
cl := h.client_socket
a_listening_socket.accept_to (cl)
if h.is_connected then
h.execute
h.safe_execute
end
else
check is_not_full: False end

View File

@@ -16,6 +16,8 @@ feature {NONE} -- Initialization
make (a_factory: like factory)
-- `a_cfg': server configuration
-- `a_factory': connection handler builder
require
fac_is_separated: {PLATFORM}.is_scoop_capable implies not attached {HTTPD_REQUEST_HANDLER_FACTORY} a_factory
do
make_configured (create {like configuration}.make, a_factory)
end

View File

@@ -0,0 +1,183 @@
note
description: "Summary description for {WGI_HTTPD_CONNECTOR}."
author: ""
todo: "[
Check if server and configuration has to be 'separate' ?
currently yes, due to WGI_REQUEST.wgi_connector setting.
But we may get rid of this one...
See `{WGI_REQUEST}.wgi_connector' and `{WSF_REQUEST}.wgi_connector' ...
]"
date: "$Date$"
revision: "$Revision$"
class
WGI_HTTPD_CONNECTOR [G -> WGI_EXECUTION create make end]
inherit
WGI_CONNECTOR
create
make,
make_with_base
feature {NONE} -- Initialization
make
local
fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G]
do
-- Callbacks
create on_launched_actions
create on_stopped_actions
-- Server
create fac
create server.make (fac)
configuration := server_configuration (server)
set_factory_connector (Current, fac)
end
make_with_base (a_base: like base)
require
a_base_starts_with_slash: (a_base /= Void and then not a_base.is_empty) implies a_base.starts_with ("/")
do
make
set_base (a_base)
end
set_factory_connector (conn: detachable separate WGI_CONNECTOR; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G])
do
fac.set_connector (conn)
end
feature -- Access
name: STRING_8 = "httpd"
-- Name of Current connector
version: STRING_8 = "0.1"
-- Version of Current connector
feature -- Access
server: separate HTTPD_SERVER
configuration: separate HTTPD_CONFIGURATION
server_configuration (a_server: like server): like configuration
do
Result := a_server.configuration
end
feature -- Access
base: detachable READABLE_STRING_8
-- Root url base
feature -- Status report
launched: BOOLEAN
-- Server launched and listening on `port'
port: INTEGER
-- Listening port.
--| 0: not launched
feature -- Callbacks
on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
-- Actions triggered when launched
on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
-- Actions triggered when stopped
feature -- Element change
on_launched (a_port: INTEGER)
-- Server launched
do
launched := True
port := a_port
on_launched_actions.call ([Current])
end
on_stopped
-- Server stopped
do
on_stopped_actions.call ([Current])
launched := False
port := 0
end
feature -- Element change
set_base (b: like base)
require
b_starts_with_slash: (b /= Void and then not b.is_empty) implies b.starts_with ("/")
do
base := b
ensure
valid_base: (attached base as l_base and then not l_base.is_empty) implies l_base.starts_with ("/")
end
set_port_number (a_port_number: INTEGER)
require
a_port_number_positive_or_zero: a_port_number >= 0
do
set_port_on_configuration (a_port_number, configuration)
end
set_max_concurrent_connections (nb: INTEGER)
do
end
feature {NONE} -- Implementation
set_port_on_configuration (a_port_number: INTEGER; cfg: like configuration)
do
cfg.set_http_server_port (a_port_number)
end
set_max_concurrent_connections_on_configuration (nb: INTEGER; cfg: like configuration)
do
cfg.set_max_concurrent_connections (nb)
end
feature -- Server
launch
do
launched := False
port := 0
launch_server (server)
end
configure_server (a_configuration: like configuration)
do
if a_configuration.is_verbose then
if attached base as l_base then
io.error.put_string ("Base=" + l_base + "%N")
end
end
end
launch_server (a_server: like server)
do
configure_server (a_server.configuration)
a_server.launch
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, 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

View File

@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
set_source (a_source)
end
feature {WGI_NINO_CONNECTOR, WGI_SERVICE} -- Nino
feature {WGI_HTTPD_CONNECTOR, WGI_SERVICE} -- Nino
set_source (i: like source)
do

View File

@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
set_target (a_target)
end
feature {WGI_NINO_CONNECTOR, WGI_SERVICE} -- Nino
feature {WGI_HTTPD_CONNECTOR, WGI_SERVICE} -- Nino
set_target (o: like target)
do

View File

@@ -1,11 +1,11 @@
note
description: "Summary description for {WSF_HTTPD_REQUEST_HANDLER}."
description: "Summary description for {WGI_HTTPD_REQUEST_HANDLER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_HTTPD_REQUEST_HANDLER [G -> WSF_EXECUTION create make end]
WGI_HTTPD_REQUEST_HANDLER [G -> WGI_EXECUTION create make end]
inherit
HTTPD_REQUEST_HANDLER
@@ -15,7 +15,18 @@ inherit
REFACTORING_HELPER
create
make
make,
make_with_connector
feature {NONE} -- Initialization
make_with_connector (conn: like connector)
do
make
connector := conn
end
connector: detachable separate WGI_CONNECTOR
feature -- Request processing
@@ -27,8 +38,7 @@ feature -- Request processing
l_error: WGI_ERROR_STREAM
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_HTTPD_RESPONSE_STREAM
exec: WSF_EXECUTION
exec: detachable WGI_EXECUTION
retried: BOOLEAN
do
if not retried then
@@ -36,15 +46,33 @@ feature -- Request processing
create {WGI_HTTPD_OUTPUT_STREAM} l_output.make (a_socket)
create {WGI_HTTPD_ERROR_STREAM} l_error.make_stderr (a_socket.descriptor.out)
create req.make (httpd_environment (a_socket), l_input, Void)
create req.make (httpd_environment (a_socket), l_input, connector)
create res.make (l_output, l_error)
req.set_meta_string_variable ("RAW_HEADER_DATA", request_header)
exec := new_execution (req, res)
create {G} exec.make (req, res)
exec.execute
res.flush
res.push
exec.clean
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
if not res.status_is_set then
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error, Void)
end
if res.message_writable then
res.put_string ("<pre>")
res.put_string (l_trace)
res.put_string ("</pre>")
end
res.push
end
end
if exec /= Void then
exec.clean
end
end
rescue
if not retried then
@@ -53,11 +81,6 @@ feature -- Request processing
end
end
new_execution (req: WGI_REQUEST; res: WGI_RESPONSE): WSF_EXECUTION
do
create {G} Result.make (req, res)
end
base: detachable READABLE_STRING_8
do
--TODO

View File

@@ -1,20 +1,31 @@
note
description: "Summary description for {WSF_HTTPD_REQUEST_HANDLER_FACTORY}."
description: "Summary description for {WGI_HTTPD_REQUEST_HANDLER_FACTORY}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_HTTPD_REQUEST_HANDLER_FACTORY [G -> WSF_EXECUTION create make end]
WGI_HTTPD_REQUEST_HANDLER_FACTORY [G -> WGI_EXECUTION create make end]
inherit
HTTPD_REQUEST_HANDLER_FACTORY
feature -- Access
connector: detachable separate WGI_CONNECTOR
feature -- Element change
set_connector (conn: like connector)
do
connector := conn
end
feature -- Factory
new_handler: separate WSF_HTTPD_REQUEST_HANDLER [G]
new_handler: separate WGI_HTTPD_REQUEST_HANDLER [G]
do
create Result.make
create Result.make_with_connector (connector)
end
note

View File

@@ -6,19 +6,19 @@ note
revision: "$Revision$"
class
WGI_LIBFCGI_CONNECTOR
WGI_LIBFCGI_CONNECTOR [G -> WGI_EXECUTION create make end]
inherit
WGI_CONNECTOR
create
make
redefine
default_create
end
feature {NONE} -- Initialization
make (a_service: like service)
default_create
do
service := a_service
Precursor
create fcgi.make
create input.make (fcgi)
create output.make (fcgi)
@@ -32,11 +32,6 @@ feature -- Access
Version: STRING_8 = "0.1"
-- Version of Current connector
feature {NONE} -- Access
service: WGI_SERVICE
-- Gateway Service
feature -- Server
launch
@@ -59,14 +54,18 @@ feature -- Execution
local
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_RESPONSE_STREAM
exec: detachable WGI_EXECUTION
rescued: BOOLEAN
do
if not rescued then
a_input.reset
create req.make (vars, a_input, Current)
create res.make (a_output, a_output)
service.execute (req, res)
create {G} exec.make (req, res)
exec.execute
res.flush
res.push
exec.clean
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
@@ -81,6 +80,9 @@ feature -- Execution
res.push
end
end
if exec /= Void then
exec.clean
end
end
rescue
if not rescued then

View File

@@ -4,7 +4,7 @@ note
revision: "$Revision$"
class
WGI_NINO_CONNECTOR
WGI_NINO_CONNECTOR [G -> WGI_EXECUTION create make end]
inherit
WGI_CONNECTOR
@@ -118,7 +118,7 @@ feature -- Server
do
launched := False
port := 0
create {WGI_NINO_HANDLER} l_http_handler.make_with_callback (server, Current)
create {WGI_NINO_HANDLER [G]} l_http_handler.make_with_callback (server, Current)
if configuration.is_verbose then
if attached base as l_base then
io.error.put_string ("Base=" + l_base + "%N")
@@ -128,17 +128,40 @@ feature -- Server
end
process_request (env: STRING_TABLE [READABLE_STRING_8]; a_headers_text: STRING; a_socket: TCP_STREAM_SOCKET)
-- Process request ...
local
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_NINO_RESPONSE_STREAM
exec: detachable WGI_EXECUTION
retried: BOOLEAN
do
if not retried then
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_socket), Current)
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket), create {WGI_NINO_ERROR_STREAM}.make_stderr (a_socket.descriptor.out))
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
service.execute (req, res)
create {G} exec.make (req, res)
exec.execute
res.flush
res.push
exec.clean
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
if not res.status_is_set then
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error, Void)
end
if res.message_writable then
res.put_string ("<pre>")
res.put_string (l_trace)
res.put_string ("</pre>")
end
res.push
end
end
if exec /= Void then
exec.clean
end
end
rescue
if not retried then

View File

@@ -5,7 +5,7 @@ note
revision : "$Revision$"
class
WGI_NINO_HANDLER
WGI_NINO_HANDLER [G -> WGI_EXECUTION create make end]
inherit
HTTP_CONNECTION_HANDLER
@@ -27,7 +27,7 @@ feature {NONE} -- Initialization
callback := a_callback
end
callback: WGI_NINO_CONNECTOR
callback: WGI_NINO_CONNECTOR [G]
feature -- Access

View File

@@ -157,7 +157,7 @@ feature -- Eiffel WGI access
deferred
end
wgi_connector: detachable WGI_CONNECTOR
wgi_connector: detachable separate WGI_CONNECTOR
-- Associated Eiffel WGI connector
deferred
end

View File

@@ -11,20 +11,6 @@ note
deferred class
WGI_SERVICE
feature {WGI_CONNECTOR} -- Execution
execute (req: WGI_REQUEST; res: WGI_RESPONSE)
-- Execute the request
-- See `req.input' for input stream
-- `req.meta_variables' for the CGI meta variable
-- and `res' for output buffer
require
res_status_unset: not res.status_is_set
deferred
ensure
res_status_set: res.status_is_set
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -57,7 +57,7 @@ feature -- EWSGI access
wgi_implementation: STRING = "Eiffel Web Framework 0.1"
wgi_connector: detachable WGI_CONNECTOR
wgi_connector: detachable separate WGI_CONNECTOR
feature -- Access: CGI meta parameters

View File

@@ -0,0 +1,54 @@
note
description: "Summary description for {WGI_EXECUTION}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WGI_EXECUTION
--create
-- make
feature {NONE} -- Initialization
make (req: WGI_REQUEST; res: WGI_RESPONSE)
do
request := req
response := res
end
feature {NONE} -- Access
request: WGI_REQUEST
response: WGI_RESPONSE
feature -- Execution
execute
-- Execute the request based on `request' and `response'.
deferred
ensure
status_is_set: response.status_is_set
end
feature -- Cleaning
clean
-- Clean request data.
do
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, 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