I have been working on spring RMI and I have set up a host and one client.
Below is the code of my host. I want to modify it in such a way that host should know which client is accessing it, so in other words server should know which client port is accessing it.
How can I achieve this in Spring RMI?
interface :-
package com.javatpoint;
public interface Calculation {
int cube(int number);
}
class :-
package com.javatpoint;
public class CalculationImpl implements Calculation{
@Override
public int cube(int number) {
return number*number*number;
}
}
and finally the host configuration xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="calculationBean" class="com.javatpoint.CalculationImpl"></bean>
<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="service" ref="calculationBean"></property>
<property name="serviceInterface" value="com.javatpoint.Calculation"></property>
<property name="serviceName" value="CalculationService"></property>
<property name="replaceExistingBinding" value="true"></property>
<property name="registryPort" value="1099"></property>
</bean>
</beans>
following are my classes that are used
interface :-
package com.javatpoint;
public interface Calculation {
int cube(int number);
}
implementation class :-
public class CalculationImpl implements Calculation{
public int cube(int number) {
return number*number*number;
}
}
and the main class
package com.javatpoint;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Host
{
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
System.out.println("Waiting for requests");
}
}
now please advise how to add the method get client host Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…