【发布时间】:2015-08-24 06:08:32
【问题描述】:
我必须通过spring RMI将参数从客户端传递到服务器,请告知如何实现以下是我编辑的类
package com.javatpoint;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.remoting.support.RemoteInvocation;
@SuppressWarnings("serial")
public class CalculationImpl extends RemoteInvocation implements Calculation {
public int cube(int number) {
return number*number*number;
}
public CalculationImpl (MethodInvocation methodInvocation) {
super();
// Invoked in superclass
this.addAttribute("awer", "test1111");
}
private void addAttribute(String string, String string2) {
}
}
而客户端的xml是
<beans>
<bean id="calculationBean" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="remoteInvocationFactory" ref="invocationFactory"/>
<property name="serviceUrl" value="rmi://localhost:1099/CalculationService"></property>
<property name="serviceInterface" value="com.javatpoint.Calculation"></property>
</bean>
<bean id="invocationFactory" class="com.javatpoint.CalculationImpl"/>
</beans>
现在请告知如何自定义 rmiservice 导出器,以便它应该接收从客户端发送的值让我们在客户端 xml 中说如上所示参数 awer 的值是 test1111 现在我想自定义我的 rmiservice 导出器 所以它应该接收这个值并显示它
下面是我的 rmi 服务导出器。。
<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="registryPort" value="1099"></property>
</bean>
【问题讨论】:
-
您的问题有点不清楚,您是否希望远程对象能够接收示例'test1111'的字符串并打印它?!
-
是的,请告知如何实现这一点,我正在尝试远程对象能够接收字符串