Updated desktop application example for scoop concurrency mode.
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="desktop_app" uuid="E015841A-D456-46E1-8A18-E0CEB9E69CD5">
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="desktop_app" uuid="E015841A-D456-46E1-8A18-E0CEB9E69CD5">
|
||||||
<description>Vision2+web browser widget+embedded web service</description>
|
<description>Vision2+web browser widget+embedded web service</description>
|
||||||
<target name="desktop_app">
|
<target name="desktop_app">
|
||||||
<description>This example demonstrates how to build a vision2 desktop application that embed a web browser accessing the service of an embedded web service.</description>
|
<description>This example demonstrates how to build a vision2 desktop application that embed a web browser accessing the service of an embedded web service.</description>
|
||||||
<root class="DESKTOP_APP" feature="make_and_launch"/>
|
<root class="DESKTOP_APP" feature="make_and_launch"/>
|
||||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
<option warning="true" full_class_checking="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="all" syntax="transitional">
|
||||||
<assertions precondition="true" postcondition="true" check="true"/>
|
<assertions precondition="true" postcondition="true" check="true"/>
|
||||||
</option>
|
</option>
|
||||||
<setting name="concurrency" value="thread"/>
|
<setting name="concurrency" value="scoop"/>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf"/>
|
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf"/>
|
||||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
||||||
@@ -18,9 +18,9 @@
|
|||||||
<library name="wsf_standalone_connector" location="..\..\library\server\ewsgi\connectors\standalone\standalone-safe.ecf"/>
|
<library name="wsf_standalone_connector" location="..\..\library\server\ewsgi\connectors\standalone\standalone-safe.ecf"/>
|
||||||
<cluster name="src" location=".\src\" recursive="true">
|
<cluster name="src" location=".\src\" recursive="true">
|
||||||
<file_rule>
|
<file_rule>
|
||||||
<exclude>/EIFGENs$</exclude>
|
|
||||||
<exclude>/CVS$</exclude>
|
|
||||||
<exclude>/.svn$</exclude>
|
<exclude>/.svn$</exclude>
|
||||||
|
<exclude>/CVS$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
</file_rule>
|
</file_rule>
|
||||||
</cluster>
|
</cluster>
|
||||||
</target>
|
</target>
|
||||||
|
|||||||
@@ -24,20 +24,25 @@ feature {NONE} -- Initialization
|
|||||||
-- then launch the application.
|
-- then launch the application.
|
||||||
local
|
local
|
||||||
l_win: like main_window
|
l_win: like main_window
|
||||||
l_embedded_service: APP_EMBEDDED_WEB_SERVICE
|
l_embedded_service: separate APP_EMBEDDED_WEB_SERVICE
|
||||||
do
|
do
|
||||||
default_create
|
default_create
|
||||||
create l_win.make
|
create l_win.make
|
||||||
main_window := l_win
|
main_window := l_win
|
||||||
l_win.show
|
l_win.show
|
||||||
create l_embedded_service.make
|
create l_embedded_service.make
|
||||||
l_embedded_service.set_port_number (0) -- Use first available port number
|
setup_and_launch_web_service (l_embedded_service)
|
||||||
|
|
||||||
l_embedded_service.on_launched_actions.force (agent on_web_service_launched (l_win, l_embedded_service))
|
|
||||||
l_embedded_service.launch
|
|
||||||
launch
|
launch
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
setup_and_launch_web_service (a_web_service: separate APP_EMBEDDED_WEB_SERVICE)
|
||||||
|
do
|
||||||
|
a_web_service.set_port_number (0) -- Use first available port number
|
||||||
|
a_web_service.set_on_launched_action (agent on_web_service_launched (a_web_service))
|
||||||
|
a_web_service.launch
|
||||||
|
end
|
||||||
|
|
||||||
on_quit
|
on_quit
|
||||||
do
|
do
|
||||||
if attached main_window as win then
|
if attached main_window as win then
|
||||||
@@ -45,13 +50,15 @@ feature {NONE} -- Initialization
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
on_web_service_launched (a_win: attached like main_window; s: APP_EMBEDDED_WEB_SERVICE)
|
on_web_service_launched (a_web_service: separate APP_EMBEDDED_WEB_SERVICE)
|
||||||
do
|
do
|
||||||
add_idle_action_kamikaze (agent wait_for_termination (s, Void))
|
if attached main_window as win then
|
||||||
add_idle_action_kamikaze (agent a_win.open_link)
|
add_idle_action_kamikaze (agent wait_for_termination (a_web_service, Void))
|
||||||
|
add_idle_action_kamikaze (agent win.open_link)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
wait_for_termination (s: APP_EMBEDDED_WEB_SERVICE; a_timeout: detachable EV_TIMEOUT)
|
wait_for_termination (a_web_service: separate APP_EMBEDDED_WEB_SERVICE; a_timeout: detachable EV_TIMEOUT)
|
||||||
local
|
local
|
||||||
t: detachable EV_TIMEOUT
|
t: detachable EV_TIMEOUT
|
||||||
do
|
do
|
||||||
@@ -60,7 +67,7 @@ feature {NONE} -- Initialization
|
|||||||
t.set_interval (0)
|
t.set_interval (0)
|
||||||
end
|
end
|
||||||
if
|
if
|
||||||
attached s.observer as obs and then
|
attached a_web_service.observer as obs and then
|
||||||
observer_has_terminaded (obs)
|
observer_has_terminaded (obs)
|
||||||
then
|
then
|
||||||
if t /= Void then
|
if t /= Void then
|
||||||
@@ -70,7 +77,7 @@ feature {NONE} -- Initialization
|
|||||||
else
|
else
|
||||||
if t = Void then
|
if t = Void then
|
||||||
create t
|
create t
|
||||||
t.actions.extend (agent wait_for_termination (s, t))
|
t.actions.extend (agent wait_for_termination (a_web_service, t))
|
||||||
else
|
else
|
||||||
t.set_interval (1_000)
|
t.set_interval (1_000)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,13 +17,12 @@ inherit
|
|||||||
|
|
||||||
feature {NONE} -- Execution
|
feature {NONE} -- Execution
|
||||||
|
|
||||||
execute_embedded
|
execute_embedded
|
||||||
-- Execute the request
|
-- Execute the request
|
||||||
-- See `request.input' for input stream
|
-- See `request.input' for input stream
|
||||||
-- `request.meta_variables' for the CGI meta variable
|
-- `request.meta_variables' for the CGI meta variable
|
||||||
-- and `response' for output buffer
|
-- and `response' for output buffer
|
||||||
local
|
local
|
||||||
filter: WSF_AGENT_FILTER
|
|
||||||
m: WSF_PAGE_RESPONSE
|
m: WSF_PAGE_RESPONSE
|
||||||
do
|
do
|
||||||
if local_connection_restriction_enabled then
|
if local_connection_restriction_enabled then
|
||||||
@@ -41,7 +40,7 @@ feature {NONE} -- Execution
|
|||||||
execute
|
execute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
execute
|
execute
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ feature -- Initialization
|
|||||||
|
|
||||||
make
|
make
|
||||||
do
|
do
|
||||||
create on_launched_actions
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Execution
|
feature -- Execution
|
||||||
@@ -40,11 +39,23 @@ feature -- Execution
|
|||||||
on_launched (conn: WGI_STANDALONE_CONNECTOR [G])
|
on_launched (conn: WGI_STANDALONE_CONNECTOR [G])
|
||||||
do
|
do
|
||||||
set_port_number (conn.port)
|
set_port_number (conn.port)
|
||||||
on_launched_actions.call (Void)
|
if attached on_launched_action as act then
|
||||||
|
call_action (act)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
call_action (act: attached like on_launched_action)
|
||||||
|
do
|
||||||
|
act.call (Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
on_launched_actions: ACTION_SEQUENCE [TUPLE]
|
on_launched_action: detachable separate PROCEDURE [ANY, TUPLE]
|
||||||
|
|
||||||
|
set_on_launched_action (act: like on_launched_action)
|
||||||
|
do
|
||||||
|
on_launched_action := act
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user