uCosminexus Application Server, Web Service Development Guide
The examples described in this subsection explain how to develop RESTful Web Services (Web resources). The development includes implementation of root resource classes, sub-resource classes, and an exception mapping provider.
The following table describes the configuration of the Web resources to be developed. An example of this development is available as a sample in the following directory:
Cosminexus-installation-directory\jaxrs\samples\tutorial\
Table 12-1 Configuration of Web resources
| No. | Item | Value |
|---|---|---|
| 1 | Name of the J2EE server to be deployed | Jaxrsserver |
| 2 | Host name and port number of the Web server | webhost:8085 |
| 3 | URL of the naming server | corbaname::testserver:900 |
| 4 | Context root | Tutorial |
| 5 | Context path of the root resource class | Root |
| 6 | Root resource class | com.sample.resources.Resource |
| 7 | Sub-resource class | com.sample.resources.SubResource |
| 8 | Exception mapping provider | com.sample.providers.RuntimeExceptionMapper |
The following table describes the configuration of a current directory for the Web resource development.
Table 12-2 Configuration of a current directory
| Directory | Explanation | |||
|---|---|---|---|---|
| c:\temp\jaxrs\works\tutorial | A current directory. | |||
| server\ | This is to be used in the Web resource development. | |||
| META-INF\ | This corresponds to the META-INF directory of the EAR file. | |||
| application.xml | This is created in 12.3.4 Creating application.xml. | |||
| src\ | This stores source files (*.java) of a Web resource. This is used in 12.3.1 Creating root resource classes. | |||
| WEB-INF\ | This corresponds to the WEB-INF directory of a WAR file. | |||
| web.xml | This is created in 12.3.3 Creating web.xml. | |||
| classes\ | This stores the compiled class files (*.class). This is used in 12.3.2 Compiling Java sources. | |||
| tutorial.ear | This is created in 12.3.5 Creating an EAR file. | |||
| tutorial.war | ||||
| client\ | This is used in the the Web resource client development. | |||
| src\ | This stores source files (*.java) of a Web resource client. See 12.5.1 Creating Implementation Class of a Web resource client (by using client APIs) or 12.5.2 Creating Implementation Class of a Web resource client (by using java.net.HttpURLConnection) for details on how to create the Implementation Class of a Web resource. | |||
| classes\ | This stores compiled class files (*.class). This is created in 12.3.2 Compiling Java sources. | |||
| usrconf.cfg | This is created in 12.6.1 Creating an options definition file for Java applications. | |||
| usrconf.properties | This is created in 12.6.2 Creating a user property file for Java applications. | |||
Change the current directory path according to the environment to be developed.
Note that the directories and the file names listed in the above table are used in the descriptions hereafter. The parts in bold in the command execution examples and in Java sources indicate the specified and generated values used in the examples. Substitue those parts according to the environment to be built.
Furthermore, in the development examples described in this chapter, Web resources and Web resource clients are developed in the same environment. However, you can also develop them in different environments. For developing Web resources and HTTP clients in different environments, substitute the current directory path according to the respective environments.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.