Servlet Container / J2EE Deployment

For enabling Resoa within your webcontainer, you need to setup a org.resoa.rest.RestServletContextListener. As an example here a webdefault.xml configuration for  Jetty:


<!-- ==================================================================== -->
<!-- Resoa Service Container instance -->
<!-- ==================================================================== -->
<context-param>
	<param-name>gatewayDir</param-name>
	<param-value>/resoa/resources</param-value> <!--default is /resoa -->
</context-param>
<context-param>
	<param-name>serviceConfigFile</param-name> <!--default is WEB-INF/resoa.xml -->
	<param-value>WEB-INF/resoa.xml</param-value>
</context-param>
<context-param>
	<param-name>serviceClasspath</param-name>
	<param-value>${jetty.base}/lib/ext</param-value>
</context-param>
<listener>
	<listener-class>org.resoa.rest.RestServletContextListener</listener-class>
</listener>

Three arguments control the behavior of your Resoa container:

  • gatewayDir: The root directory of your gateway. If services need to load files for configuration, they should use the gateway function resoaGateway.getConfigFile(String path). If the path does not start with a systen property (i.e. ${user.home}) or ‘/’, the path string is merged with the gateway root directory.
  • serviceConfigFile: If you deploy a WAR to your container, the ResoaServletContextListener will look for a configuration file. Default name is WEB-INF/resoa.xml.
  • serviceClasspath: set the path, the ResoaServiceDomainExplorer should use as the lookup environment for Resoa domain jars.

The serviceConfigFile WEB-INF/resoa.xml

If you develop a web application with Resoa services enabled, add a resoa.xml file to your WEB-INF folder, specifying the URL to service domain mapping. An example:

<Rest xmlns="http://www.resoa.org/deploy">
	<!-- Define the virtual Host domains for the application. -->
	<Hosts cookieDomain="foo.org" domain="myapp.foo.org"/>
	<Hosts cookieDomain="foo.com" domain="myapp.foo.com" />
	<!-- Define the URL to service dispatching -->
	<Dispatcher loginURL="/login.html">
		<SessionUrls>/member</SessionUrls><!-- URL's starting with /member will require authentication -->
		<SecureUrls>/secure</SecureUrls><!-- URL's starting with /secure will require HTTPS protocol -->
		<!-- Resoa URL to Service package routing. Map the java package name of your service model to an URL -->
		<Services path="/service/partner" package="org.foo.partner" />
		<Services path="/service/products" package="org.foo.products" />
		<Services path="/service/main" package="org.foo.main" />
		<Services path="/service/media" package="org.foo.media" />
	</Dispatcher>
</Rest>