Spring-RCP using AppFuse webservices

To build a classical 3-tier architecture, you can use AppFuse as a back end. This full-featured web-framework provides many time-saving features, additionally it's very easy to export the managers as webservice and use them as a backend to your Spring-RCP application.

Webservice configuration

The first thing to do is to configure an existing AppFuse application to export the managers as a webservice. A detailed description can be found in this wiki: Webservices with HttpInvoker.

RCP configuration

In your Spring-RCP project some configuration files have to be modified, to make use of the new webservices.

src/main/resources/ctx/security-context-client.xml

The following beans have to be configured:

<bean id="remoteAuthenticationProvider" class="org.acegisecurity.providers.rcp.RemoteAuthenticationProvider">
	<property name="remoteAuthenticationManager" ref="remoteAuthenticationManager"/>
</bean>
 
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
	<property name="providers">
	  <list>
		<ref bean="remoteAuthenticationProvider"/>
	  </list>
	</property>
</bean>
 
<bean id="remotingSecurityConfigurer" class="org.springframework.richclient.security.RemotingSecurityConfigurer"/>

src/main/resources/ctx/richclient-remoting-context.xml

This file has to be created, all the managers will get defined here to make them accessible.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
 
<!-- This file defines remoting beans (all serverside managers etc.) -->
<beans>
	<!-- RequestExecutor with authentication, for secured webservices-->
	<bean id="httpInvokerRequestExecutor" class="org.springframework.richclient.security.remoting.BasicAuthHttpInvokerRequestExecutor"/>
 
	<!-- Proxy for the HTTPInvoker-exported UserManager -->
	<bean id="userManager" class="org.springframework.richclient.security.remoting.BasicAuthHttpInvokerProxyFactoryBean">
		<property name="serviceInterface" value="com.company.app.service.UserManager"/>
		<property name="serviceUrl" value="http://${serverName}:${httpPort}${contextPath}/ws/secure/UserManager"/>
		<property name="httpInvokerRequestExecutor" ref="httpInvokerRequestExecutor"/>
	</bean>
 
	<!-- Proxy for the HTTPInvoker-exported RemoteAuthenticationManager -->
	<bean id="remoteAuthenticationManager" class="org.springframework.richclient.security.remoting.BasicAuthHttpInvokerProxyFactoryBean">
		<property name="serviceInterface" value="org.acegisecurity.providers.rcp.RemoteAuthenticationManager" />
		<property name="serviceUrl" value="http://${serverName}:${httpPort}${contextPath}/ws/RemoteAuthenticationManager"/>
		<property name="httpInvokerRequestExecutor" ref="httpInvokerRequestExecutor"/>
	</bean>
 
</beans>

src/main/resources/remoting.properties

The server address is kept in this configuration file, so it's easier to change in the future at a central location. The configuration file has to be created as well and the following data is added.

# Properties file with server URL settings for remote access.
# Applied by PropertyPlaceholderConfigurer from "client-context.xml".

# local test server data
serverName=localhost
httpPort=8080
contextPath=

# live server data
#serverName=192.168.2.50
#httpPort=8180
#contextPath=/yourapp

src/main/resources/ctx/richclient-application-context.xml

To load the server properties on context creation, the following bean definition gets added to the file.

<!-- Resolves ${...} placeholders from client.properties -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
	<property name="locations">
		<list>
			<value>classpath:remoting.properties</value>
		</list>
	</property>
</bean>

pom.xml

Three additional dependencies have to be added to the pom.xml to use Spring-remoting:

<dependency>
	<groupId>com.caucho</groupId>
	<artifactId>hessian</artifactId>
	<version>3.0.13</version>
</dependency>
<dependency>
	<groupId>com.caucho</groupId>
	<artifactId>burlap</artifactId>
	<version>2.0.12</version>
</dependency>
<dependency>
	<groupId>javax.xml</groupId>
	<artifactId>jaxrpc</artifactId>
	<version>1.1</version>
</dependency>
Recent changes RSS feed Creative Commons License Donate Driven by DokuWiki