Web Application Implementing
To create a new Iotellect Web Application from scratch, you need to implement some Java classes.
Web Application Class
Web Application Class should implement WebApplication
interface. Override deploy()
and stop()
methods to register and unregister the web application.
![]() | Example: registration of the web application: |
Note that a context path will be used in request to this application. The second parameter is the web application file (WAR file) name.
![]() | Example: unregistration of the web application: |
Use previously saved context to unregister the web application.
Plugin Class
Plugin Class should be inherited from AbstractContextPlugin
. You will need to override one of its initiating methods to add web application to the web server.
![]() | Example: using globalInit method to add the web application: |
It is enough for most web applications. In the rest this is a usual plugin class. You can read more about its implementation in the corresponding topic.
Java Servlet Class
Java Servlet Class should be inherited from HttpServlet
. This class and its methods are in charge of request and response processing. Detailed information about the servlet implementation can be found in the corresponding documentation https://tomcat.apache.org/tomcat-7.0-doc/servletapi/javax/servlet/http/HttpServlet.html.
![]() | Example: Simple doGet implementation: |
Particular attention should be paid to the interaction between servlet and Iotellect Server. Look at the demo web application in SDK to find examples of interaction with contexts and using user permissions.
Modifying Plugin Descriptor
To create a plugin descriptor for the web application, edit the following in demo plugin.properties
file:
Change the last word in
id
attribute of the<plugin>
tag to the new plugin ID. The ID should contain only lowercase letters, digits and underscores. For example, if your intended plugin ID isxyz
, set ID attribute tocom.tibbo.aggregate.common.plugin.context.xyz
Change
class
attribute of<plugin>
tag to full name of Plugin ClassEnter component description in the body
<doc-text>
tagChange
id
attribute of the<extension>
tag to the new plugin ID
Modifying Deployment Descriptor
Deployment descriptor describes how a web application should be deployed. To create one, edit the following in demo web.xml
file:
Change
<display-name>
element contentChange
<servlet-name>
element for<servlet>
and<servlet-mapping>
elementsChange
<servlet-class>
to full name of Java Servlet ClassCustomize servlet mapping and set up other deployment settings if it is necessary
![]() | More information about the web application deployment can be found on the website https://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html. |
Building and Deploying Plugin Archive
Follow these steps for build.xml
file from the example:
Change project name and names of the destination files (JAR and WAR files)
Run
build.gradle
using Gradle to build JAR and WAR filesCopy the JAR file to
%Iotellect Server Installation Folder/plugins/context
when Iotellect Server is not runningCopy the WAR file to
%Iotellect Server Installation Folder/admin
when Iotellect Server is not runningStart Iotellect Server
Execute request to the web application
![]() | Note that after the first launch, web application will be unpacked from the WAR file to a folder with the appropriate name. Web server works with an unpacked application from the folder. Therefore, if the WAR file changes, delete the folder with old version of the application before starting Iotellect Server. |
![]() | Building a web application requires extra files in the build path in addition to
|
Was this page helpful?