import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvocationResponse; import org.jboss.remoting.Invocation; import org.jboss.remoting.callback.InvokerCallbackHandler; public class MyInvocationHandler implements InvokerCallbackHandler { public InvocationResponse invoke(InvocationRequest req) throws Throwable { Invocation inv = (Invocation) req.getParameter(); String result = "Hello, " + inv.getParameters()[0] + "!"; return new InvocationResponse(result); } public static void main(String[] args) throws Exception { ServerInvoker server = new ServerInvoker(); server.setServerInvokerName("MyInvoker"); server.setServerInvokerCallbackHandler(new MyInvocationHandler()); server.start(); } } import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.InvocationCallbackHandler; public class MyRemoteClient { public static void main(String[] args) throws Exception { Client client = new Client(new InvokerLocator("remoting://localhost:4444")); MyInvocation invocation = new MyInvocation("Alice"); Object result = client.invoke(invocation); System.out.println(result); } } import org.jboss.remoting.Invocation; public class MyInvocation extends Invocation { public MyInvocation(String name) { super("MyInvocation", new Object[]{name}); } } <subsystem xmlns="urn:jboss:domain:remoting:1.4"> <endpoint channel="remoting" worker="default" security-realm="ApplicationRealm"/> <connector name="remoting-connector" socket-binding="remoting" security-realm="ApplicationRealm"/> </subsystem> <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> <socket-binding name="remoting" port="4444"/> </socket-binding-group>


上一篇:
下一篇:
切换中文