Added more content to the tutorial
This commit is contained in:
11
examples/tutorial/step_2/hello/alternatives/README.wiki
Normal file
11
examples/tutorial/step_2/hello/alternatives/README.wiki
Normal file
@@ -0,0 +1,11 @@
|
||||
This folder contains 2 alternatives code
|
||||
|
||||
1) "execute" using the WSF_SERVICE interface, i.e
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
...
|
||||
end
|
||||
|
||||
|
||||
2) "launcher" using the WSF_RESPONSE_SERVICE interface, but it uses a launcher to start the service, instead of inheriting from WSF_DEFAULT_SERVICE or WSF_DEFAULT_RESPONSE_SERVICE
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
note
|
||||
description: "[
|
||||
APPLICATION implements the `Hello World' service.
|
||||
|
||||
It inherits from WSF_DEFAULT_SERVICE to get default EWF connector ready
|
||||
only `execute' needs to be implemented.
|
||||
|
||||
`initialize' can be redefine to provide custom options if needed.
|
||||
|
||||
]"
|
||||
|
||||
class
|
||||
HELLO_APPLICATION
|
||||
|
||||
inherit
|
||||
WSF_DEFAULT_SERVICE
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
page: WSF_PAGE_RESPONSE
|
||||
do
|
||||
create page.make
|
||||
page.put_string ("Hello World")
|
||||
res.send (page)
|
||||
|
||||
--| another alternative would have been more low level
|
||||
--| by setting the status code, the content type, and the content length which is 11 for "Hello World"
|
||||
--| res.put_header ({WSF_HEADER}.ok, <<["Content-Type", "text/plain"], ["Content-Length", "11"]>>)
|
||||
--| res.put_string ("Hello World")
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="hello_with_execute" uuid="DB6E98D3-64A9-4FF6-8F11-9E626DCAED6D">
|
||||
|
||||
<target name="hello_with_execute">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<root class="HELLO_APPLICATION" feature="make_and_launch"/>
|
||||
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="wsf" location="..\..\..\..\..\..\library\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="default_nino" location="..\..\..\..\..\..\library\server\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="src" location=".\" />
|
||||
</target>
|
||||
|
||||
</system>
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -8,23 +8,25 @@ note
|
||||
]"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
HELLO_APPLICATION
|
||||
|
||||
inherit
|
||||
WSF_DEFAULT_RESPONSE_SERVICE
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
WSF_RESPONSE_SERVICE
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
make_and_launch
|
||||
local
|
||||
launcher: WSF_DEFAULT_SERVICE_LAUNCHER
|
||||
opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS
|
||||
do
|
||||
create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} service_options.make_from_file ("ewf.ini")
|
||||
Precursor
|
||||
--| Uncomment the following line, to read options from "ewf.ini" configuration file
|
||||
-- create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} opts.make_from_file ("ewf.ini")
|
||||
|
||||
create launcher.make_and_launch (Current, opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="hello_with_launcher" uuid="00871FE9-7114-4A09-BF4F-C0B833D4F1CB">
|
||||
|
||||
<target name="hello_with_launcher">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<root class="HELLO_APPLICATION" feature="make_and_launch"/>
|
||||
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="wsf" location="..\..\..\..\..\..\library\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="default_nino" location="..\..\..\..\..\..\library\server\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="src" location=".\"/>
|
||||
</target>
|
||||
|
||||
</system>
|
||||
@@ -7,14 +7,18 @@
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<root class="APPLICATION" feature="make_and_launch"/>
|
||||
<root class="HELLO_APPLICATION" feature="make_and_launch"/>
|
||||
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="wsf" location="..\..\..\..\library\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="default_nino" location="..\..\..\..\library\server\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="hello" location=".\" recursive="true"/>
|
||||
<cluster name="src" location=".\src" recursive="true"/>
|
||||
</target>
|
||||
|
||||
<target name="hello_custom" extends="hello">
|
||||
<root class="CUSTOM_HELLO_APPLICATION" feature="make_and_launch"/>
|
||||
</target>
|
||||
|
||||
</system>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the `Hello World' service.
|
||||
|
||||
It inherits from WSF_DEFAULT_RESPONSE_SERVICE to get default EWF connector ready
|
||||
only `response' needs to be implemented.
|
||||
In this example, it is redefined and specialized to be WSF_PAGE_RESPONSE
|
||||
|
||||
`initialize' can be redefine to provide custom options if needed.
|
||||
|
||||
]"
|
||||
|
||||
class
|
||||
CUSTOM_HELLO_APPLICATION
|
||||
|
||||
inherit
|
||||
WSF_DEFAULT_RESPONSE_SERVICE
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
--| Uncomment the following line, to be able to load options from the file ewf.ini
|
||||
-- create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} service_options.make_from_file ("ewf.ini")
|
||||
|
||||
--| You can also uncomment the following line if you use the Nino connector
|
||||
--| so that the server listens on port 9999
|
||||
--| quite often the port 80 is already busy
|
||||
-- set_service_option ("port", 9999)
|
||||
|
||||
--| Uncomment next line to have verbose option if available
|
||||
-- set_service_option ("verbose", True)
|
||||
|
||||
--| If you don't need any custom options, you are not obliged to redefine `initialize'
|
||||
Precursor
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
response (req: WSF_REQUEST): WSF_PAGE_RESPONSE
|
||||
-- Computed response message.
|
||||
do
|
||||
create Result.make
|
||||
Result.put_string ("Hello World")
|
||||
end
|
||||
|
||||
end
|
||||
31
examples/tutorial/step_2/hello/src/hello_application.e
Normal file
31
examples/tutorial/step_2/hello/src/hello_application.e
Normal file
@@ -0,0 +1,31 @@
|
||||
note
|
||||
description: "[
|
||||
This class implements the `Hello World' service.
|
||||
|
||||
It inherits from WSF_DEFAULT_RESPONSE_SERVICE to get default EWF connector ready
|
||||
only `response' needs to be implemented.
|
||||
In this example, it is redefined and specialized to be WSF_PAGE_RESPONSE
|
||||
|
||||
`initialize' can be redefine to provide custom options if needed.
|
||||
|
||||
]"
|
||||
|
||||
class
|
||||
HELLO_APPLICATION
|
||||
|
||||
inherit
|
||||
WSF_DEFAULT_RESPONSE_SERVICE
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
response (req: WSF_REQUEST): WSF_PAGE_RESPONSE
|
||||
-- Computed response message.
|
||||
do
|
||||
create Result.make
|
||||
Result.put_string ("Hello World")
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user