openfire - hessian RMI example in plugin
* openfire plugin configuration
public interface RMIService {
public int geStatus(String jid);
}
public class RMIServiceImpl extends HessianServlet implements RMIService {
public int geStatus(String jid) {
// process
}
}
public void initializePlugin(PluginManager pluginManager, File pluginDirectory) {
try {
this.server = new Server(8080);
ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);
handler.setContextPath("/");
handler.addServlet(RMIServiceImpl.class, "/rmi");
this.server.setHandler(handler);
this.server.start();
} catch(Exception e) {
logger.warn("Exception occurred!", e);
}
}
* client configuration
public interface RMIService {
public int geStatus(String jid);
}
public class HessianTest {
public static void main(String[] args) {
String url = "http://localhost:8080/rmi";
HessianProxyFactory factory = new HessianProxyFactory();
RMIService rs = null;
try {
rs = (RMIService) factory.create(RMIService.class, url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
System.out.println("status : " + rs.getStatus("test@test.com/test"));
}
}