protected void setupServer(String listener, MBeanServer mbeanServer) throws Exception
{
HashMap config = new HashMap();
config.put(InvokerLocator.FORCE_REMOTE, "true");
addExtraServerConfig(config);
Connector connector = new Connector(config);
mbeanServer.registerMBean(connector, new ObjectName("test:type=connector"));
host = InetAddress.getLocalHost().getHostAddress();
port = PortUtil.findFreePort(host);
StringBuffer buf = new StringBuffer();
buf.append("<?xml version=\"1.0\"?>\n");
buf.append("<config>");
buf.append(" <invoker transport=\"" + getTransport() + "\">");
buf.append(" <attribute name=\"serverBindAddress\">" + host + "</attribute>");
buf.append(" <attribute name=\"serverBindPort\">" + port + "</attribute>");
buf.append(" <attribute name=\"" + ServerInvoker.CONNECTION_LISTENER + "\">" + listener + "</attribute>");
buf.append(" <attribute name=\"" + ServerInvoker.CLIENT_LEASE_PERIOD + "\">5000</attribute>");
buf.append(" </invoker>");
buf.append("</config>");
ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes());
Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
connector.setConfiguration(xml.getDocumentElement());
connector.create();
connector.addInvocationHandler("test", new TestInvocationHandler());
connector.start();
locatorURI = connector.getInvokerLocator();
log.info("Started remoting server with locator uri of: " + locatorURI);
}