Added abstraction WSF_ROUTED, and WSF_FILTERED.
Added under library/server/obsolete/v0 the previous non concurrent friendly version of EWF/WSF, for backward compatiblity. Removed WSF_CALLBACK_SERVICE and WSF_TO_WGI_SERVICE which are not need with new EWF.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
note
|
||||
description: "[
|
||||
Create this service with a callback to implement {WSF_SERVICE}.execute (req, res)
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_CALLBACK_SERVICE
|
||||
|
||||
inherit
|
||||
WSF_SERVICE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
convert
|
||||
make ({PROCEDURE [ANY, TUPLE [WSF_REQUEST, WSF_RESPONSE]]})
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
make (a_callback: like callback)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
callback := a_callback
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
callback: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]
|
||||
-- Procedure called on `execute'
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the request
|
||||
do
|
||||
callback.call ([req, res])
|
||||
end
|
||||
|
||||
invariant
|
||||
callback_attached: callback /= Void
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
@@ -0,0 +1,31 @@
|
||||
note
|
||||
description: "Summary description for {WSF_DEFAULT_SERVICE_I}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_DEFAULT_SERVICE_I [G -> WSF_SERVICE_LAUNCHER create make_and_launch end]
|
||||
|
||||
inherit
|
||||
WSF_LAUNCHABLE_SERVICE
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
l_launcher: G
|
||||
do
|
||||
create l_launcher.make_and_launch (a_service, opts)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "Summary description for {WSF_LAUNCHABLE_SERVICE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_LAUNCHABLE_SERVICE
|
||||
|
||||
inherit
|
||||
WSF_SERVICE
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
frozen make_and_launch
|
||||
do
|
||||
initialize
|
||||
launch (Current, service_options)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize current service
|
||||
--| Could be redefine to set custom service option(s)
|
||||
do
|
||||
end
|
||||
|
||||
service_options: detachable WSF_SERVICE_LAUNCHER_OPTIONS
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Default service options
|
||||
|
||||
set_service_option (a_name: READABLE_STRING_GENERAL; a_value: detachable ANY)
|
||||
-- Set options related to WSF_SERVICE_LAUNCHER
|
||||
local
|
||||
opts: like service_options
|
||||
do
|
||||
opts := service_options
|
||||
if opts = Void then
|
||||
create opts.make
|
||||
service_options := opts
|
||||
end
|
||||
opts.set_option (a_name, a_value)
|
||||
ensure
|
||||
attached service_options as l_options and then l_options.option (a_name) = a_value
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
@@ -0,0 +1,41 @@
|
||||
note
|
||||
description: "[
|
||||
Inherit from this class to implement the main entry of your web service
|
||||
You just need to implement `execute', get data from the request `req'
|
||||
and return a response message
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_RESPONSE_SERVICE
|
||||
|
||||
inherit
|
||||
WSF_SERVICE
|
||||
|
||||
feature -- Response
|
||||
|
||||
response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE
|
||||
deferred
|
||||
ensure
|
||||
Result_attached: Result /= Void
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
res.send (response (req))
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
41
library/server/obsolete/v0/wsf/src/service/wsf_service.e
Normal file
41
library/server/obsolete/v0/wsf/src/service/wsf_service.e
Normal file
@@ -0,0 +1,41 @@
|
||||
note
|
||||
description: "[
|
||||
Inherit from this class to implement the main entry of your web service
|
||||
You just need to implement `execute', get data from the request `req'
|
||||
and write the response in `res'
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_SERVICE
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the request
|
||||
-- See `req.input' for input stream
|
||||
-- `req.meta_variables' for the CGI meta variable
|
||||
-- and `res' for output buffer
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
to_wgi_service: WGI_SERVICE
|
||||
-- Adapt Current WSF Service to plug into WGI component
|
||||
do
|
||||
create {WSF_TO_WGI_SERVICE} Result.make_from_service (Current)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
@@ -0,0 +1,132 @@
|
||||
note
|
||||
description: "[
|
||||
Component to launch the service using the default connector
|
||||
|
||||
How-to:
|
||||
|
||||
s: WSF_SERVICE_LAUNCHER
|
||||
create s.make_and_launch (service)
|
||||
|
||||
`service' can be Current if inherit from WSF_SERVICE
|
||||
or also `create {WSF_CALLBACK_SERVICE}.make (agent execute)'
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
-- ...
|
||||
end
|
||||
|
||||
You can also provide specific options that might be relevant
|
||||
only for specific connectors such as
|
||||
|
||||
|
||||
For instance, you can use
|
||||
create s.make_and_launch_and_options (agent execute, <<["port", 8099]>>)
|
||||
|
||||
And if Nino is the default connector it will support:
|
||||
port: numeric such as 8099 (or equivalent string as "8099")
|
||||
base: base_url (very specific to standalone server)
|
||||
force_single_threaded: use only one thread, useful for Nino
|
||||
verbose: to display verbose output, useful for Nino
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_SERVICE_LAUNCHER
|
||||
|
||||
inherit
|
||||
WSF_TO_WGI_SERVICE
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
frozen make (a_service: like service; a_options: like options)
|
||||
do
|
||||
make_from_service (a_service)
|
||||
options := a_options
|
||||
initialize
|
||||
ensure
|
||||
service_set: service = a_service
|
||||
options_set: options = a_options
|
||||
launchable: launchable
|
||||
end
|
||||
|
||||
frozen make_and_launch (a_service: like service; a_options: like options)
|
||||
do
|
||||
make (a_service, a_options)
|
||||
launch
|
||||
end
|
||||
|
||||
frozen make_callback (a_callback: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; a_options: like options)
|
||||
do
|
||||
make (create {WSF_CALLBACK_SERVICE}.make (a_callback), a_options)
|
||||
end
|
||||
|
||||
frozen make_callback_and_launch (a_callback: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; a_options: like options)
|
||||
do
|
||||
make (create {WSF_CALLBACK_SERVICE}.make (a_callback), a_options)
|
||||
end
|
||||
|
||||
initialize
|
||||
-- Initialize Current using `options' if attached
|
||||
-- and build the connector
|
||||
require
|
||||
service_set: service /= Void
|
||||
deferred
|
||||
ensure
|
||||
connector_attached: connector /= Void
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
launchable: BOOLEAN
|
||||
-- Is default service launchable?
|
||||
do
|
||||
Result := connector /= Void
|
||||
end
|
||||
|
||||
connector: detachable WGI_CONNECTOR
|
||||
-- Connector associated to current default service
|
||||
deferred
|
||||
end
|
||||
|
||||
connector_name: READABLE_STRING_8
|
||||
-- Connector's name associated to current default service
|
||||
do
|
||||
if attached connector as conn then
|
||||
Result := conn.name
|
||||
else
|
||||
check
|
||||
connector_attached: False
|
||||
end
|
||||
Result := ""
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
launch
|
||||
-- Launch default service
|
||||
require
|
||||
launchable: launchable
|
||||
deferred
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
options: detachable WSF_SERVICE_LAUNCHER_OPTIONS
|
||||
-- Custom options which might be support (or not) by the default service
|
||||
|
||||
invariant
|
||||
connector_attached: connector /= Void
|
||||
|
||||
note
|
||||
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
|
||||
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
|
||||
@@ -0,0 +1,124 @@
|
||||
note
|
||||
description: "[
|
||||
Options used by WSF_SERVICE_LAUNCHER
|
||||
|
||||
For instance options supported by Nino as default connector::
|
||||
port: numeric such as 8099 (or equivalent string as "8099")
|
||||
base: base_url (very specific to standalone server)
|
||||
force_single_threaded: use only one thread, useful for Nino
|
||||
verbose: to display verbose output, useful for Nino
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_SERVICE_LAUNCHER_OPTIONS
|
||||
|
||||
inherit
|
||||
TABLE_ITERABLE [detachable ANY, READABLE_STRING_GENERAL]
|
||||
redefine
|
||||
default_create
|
||||
end
|
||||
|
||||
create
|
||||
default_create,
|
||||
make,
|
||||
make_from_array,
|
||||
make_from_iterable
|
||||
|
||||
convert
|
||||
make_from_array ({ARRAY [TUPLE [name: READABLE_STRING_GENERAL; value: detachable ANY]]})
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
default_create
|
||||
do
|
||||
Precursor
|
||||
create options.make (0)
|
||||
end
|
||||
|
||||
make
|
||||
do
|
||||
default_create
|
||||
end
|
||||
|
||||
make_from_array (a_options: ARRAY [TUPLE [name: READABLE_STRING_GENERAL; value: detachable ANY]])
|
||||
do
|
||||
make
|
||||
append_array_of_options (a_options)
|
||||
end
|
||||
|
||||
make_from_iterable (a_options: TABLE_ITERABLE [detachable ANY, READABLE_STRING_GENERAL])
|
||||
do
|
||||
make
|
||||
append_options (a_options)
|
||||
end
|
||||
|
||||
feature -- Merging
|
||||
|
||||
append_array_of_options (a_options: ARRAY [TUPLE [name: READABLE_STRING_GENERAL; value: detachable ANY]])
|
||||
do
|
||||
across
|
||||
a_options as opt
|
||||
loop
|
||||
if attached opt.item as o then
|
||||
set_option (o.name, o.value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
append_options (a_options: TABLE_ITERABLE [detachable ANY, READABLE_STRING_GENERAL])
|
||||
do
|
||||
across
|
||||
a_options as o
|
||||
loop
|
||||
set_option (o.key, o.item)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
option (a_name: READABLE_STRING_GENERAL): detachable ANY
|
||||
do
|
||||
Result := options.item (a_name)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
new_cursor: TABLE_ITERATION_CURSOR [detachable ANY, READABLE_STRING_GENERAL]
|
||||
-- Fresh cursor associated with current structure
|
||||
do
|
||||
Result := options.new_cursor
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_option (a_name: READABLE_STRING_GENERAL; a_value: detachable ANY)
|
||||
do
|
||||
options.force (a_value, a_name)
|
||||
end
|
||||
|
||||
set_verbose (b: BOOLEAN)
|
||||
-- Set option "verbose" to `b'
|
||||
do
|
||||
set_option ("verbose", b)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
options: STRING_TABLE [detachable ANY]
|
||||
-- Custom options which might be support (or not) by the default service
|
||||
|
||||
invariant
|
||||
options_attached: options /= Void
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
@@ -0,0 +1,84 @@
|
||||
note
|
||||
description: "[
|
||||
Options used by WSF_SERVICE_LAUNCHER
|
||||
Built from ini configuration file
|
||||
]"
|
||||
|
||||
class
|
||||
WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI
|
||||
|
||||
inherit
|
||||
WSF_SERVICE_LAUNCHER_OPTIONS
|
||||
|
||||
create
|
||||
make_from_file,
|
||||
make_from_file_and_defaults
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_from_file (a_filename: READABLE_STRING_GENERAL)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
make
|
||||
import (a_filename)
|
||||
end
|
||||
|
||||
make_from_file_and_defaults (a_filename: READABLE_STRING_GENERAL; dft: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
make
|
||||
|
||||
if dft /= Void then
|
||||
append_options (dft)
|
||||
end
|
||||
|
||||
import (a_filename)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
import (a_filename: READABLE_STRING_GENERAL)
|
||||
-- Import ini file content
|
||||
local
|
||||
f: PLAIN_TEXT_FILE
|
||||
l,v: STRING_8
|
||||
p: INTEGER
|
||||
do
|
||||
create f.make_with_name (a_filename)
|
||||
if f.exists and f.is_readable then
|
||||
f.open_read
|
||||
from
|
||||
f.read_line
|
||||
until
|
||||
f.exhausted
|
||||
loop
|
||||
l := f.last_string
|
||||
l.left_adjust
|
||||
if not l.is_empty and then l[1] /= '#' then
|
||||
p := l.index_of ('=', 1)
|
||||
if p > 1 then
|
||||
v := l.substring (p + 1, l.count)
|
||||
l.keep_head (p - 1)
|
||||
v.left_adjust
|
||||
v.right_adjust
|
||||
l.right_adjust
|
||||
set_option (l.as_lower, v)
|
||||
end
|
||||
end
|
||||
f.read_line
|
||||
end
|
||||
f.close
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||
@@ -0,0 +1,67 @@
|
||||
note
|
||||
description: "[
|
||||
This class is the link between WGI_SERVICE and WSF_SERVICE
|
||||
It makes a WSF_SERVICE callable from the WGI_ world.
|
||||
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_TO_WGI_SERVICE
|
||||
|
||||
inherit
|
||||
WGI_SERVICE
|
||||
|
||||
WGI_EXPORTER
|
||||
|
||||
create
|
||||
make_from_service
|
||||
|
||||
feature {NONE} -- Make
|
||||
|
||||
make_from_service (a_service: like service)
|
||||
-- Make from WSF_SERVICE `a_service'
|
||||
do
|
||||
service := a_service
|
||||
end
|
||||
|
||||
service: WSF_SERVICE
|
||||
-- Associated WSF_SERVICE
|
||||
|
||||
feature {WGI_CONNECTOR} -- Implementation: Execution
|
||||
|
||||
execute (req: WGI_REQUEST; res: WGI_RESPONSE)
|
||||
-- Delegate the WGI processing to the WSF_SERVICE object
|
||||
-- <Precursor>
|
||||
local
|
||||
w_res: detachable WSF_RESPONSE
|
||||
w_req: detachable WSF_REQUEST
|
||||
do
|
||||
create w_res.make_from_wgi (res)
|
||||
create w_req.make_from_wgi (req)
|
||||
service.execute (w_req, w_res)
|
||||
w_req.destroy
|
||||
rescue
|
||||
if w_res /= Void then
|
||||
if not (w_res.status_committed or w_res.header_committed) then
|
||||
w_res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
|
||||
end
|
||||
w_res.flush
|
||||
end
|
||||
if w_req /= Void then
|
||||
w_req.destroy
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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