View Full Version : Remoting and a Swing Client
john.wheeler
Dec 3rd, 2004, 02:28 PM
Is it possible to make RPC's using the HTTPInvoker from a swing standalone app? If so, how does the configuration work? Do I need to embed a servlet engine in my standalone application?
thanks,
John
Alef Arendsen
Dec 6th, 2004, 05:33 AM
From a standalone application you can use the HttpInvokers to call beans in an ApplicationContext in a servlet container. The reference manual (http://www.springframework.org/docs/reference/remoting.html) describes all of Spring's remoting features in quite some detail so I suggest you have a look at that.
regards,
Alef
john.wheeler
Dec 6th, 2004, 01:21 PM
Thanks for the reply Alef,
I have read the remoting docs, and I guess I am just unfamiliar with spring, so are you saying I must use an embedded servlet container for remoting to be possible in my standalone app? Or is it just a matter of making my app see applicationContext.xml? How do I do this? Classpath?
John
From a standalone application you can use the HttpInvokers to call beans in an ApplicationContext in a servlet container. The reference manual (http://www.springframework.org/docs/reference/remoting.html) describes all of Spring's remoting features in quite some detail so I suggest you have a look at that.
regards,
Alef
Alef Arendsen
Dec 6th, 2004, 04:23 PM
The HttpInvokers stuff works with a client and a server. On the server end (HTTP-based, a Servlet container) you need to include the ServiceExporter, making the objects more or less listen to a URL... On the client end you don't need to include a web server or something like that, it's just a matter of including client interceptor (as mentioned in the docs).
This is only going to work for one-way communication (RPC from the client app to the server). So if this is what you want, yes, you only need to load the application context in your client application. This can be done by using hte ClasspathXmlApplicationContext or one of hte BeanFactoryLocators, also describes in the reference manual (I believe chapter 3, or maybe 4).
cornflakes
Jan 31st, 2005, 06:46 PM
John, I am having similar problems with a standalone client. I've posted a new topic on the forum .... any ideas would be greatly appreciated.
Kiran
drain
Feb 7th, 2005, 03:37 PM
This might help, assuming you have the server side setup correctly. Heres what i did. create applicationcontext.xml on client side, with spring jars and load app context when ur app starts using XML loader thing.
ctx = new FileSystemXmlApplicationContext(
"applicationContext.xml" );
then in applicationcontext.xml u want to specify the service u are calling.
<bean
id="RemoteEquipment"
class="org.springframework.remoting.httpinvoker.HttpInvok erProxyFactoryBean"
>
<property name="serviceUrl">
<value>http://135.8.106.132:7001/ASG/remoting/EquipmentService</value>
</property>
<property name="serviceInterface">
<value>network.service.RemoteEquipment</value>
</property>
</bean>
And create the interface u are using so mine is RemoteEquipment.java in network.service package.
public interface RemoteEquipment
{
public abstract List getEquipmentByGroup(String groupID,String searchString,int max);
public abstract boolean addEquipment(hibernate.pojo.Equipment equip);
}
Then when u want to call service do ...
network.service.RemoteEquipment dao = (network.service.RemoteEquipment) ctx.getBean("RemoteEquipment");
boolean result;
try
{
result = dao.addEquipment(equip);
}catch(Exception e)
{ ...
And thats it. HTH.
Adrian
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.