2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
22
package org.jboss.test.remoting.detection.multicast.startup;
24
import java.net.InetAddress;
26
import org.apache.log4j.Level;
27
import org.jboss.jrunit.extensions.ServerTestCase;
28
import org.jboss.remoting.InvocationRequest;
29
import org.jboss.remoting.InvokerLocator;
30
import org.jboss.remoting.ServerInvocationHandler;
31
import org.jboss.remoting.ServerInvoker;
32
import org.jboss.remoting.callback.InvokerCallbackHandler;
33
import org.jboss.remoting.detection.multicast.MulticastDetector;
34
import org.jboss.remoting.network.NetworkRegistry;
35
import org.jboss.remoting.transport.Connector;
36
import org.jboss.test.remoting.TestUtil;
37
import javax.management.MBeanServer;
38
import javax.management.MBeanServerFactory;
39
import javax.management.ObjectName;
42
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
44
public class MulticastDetectorServer extends ServerTestCase
46
private MulticastDetector detector;
47
private Connector connector;
48
private NetworkRegistry registry;
50
public void setUp() throws Exception
52
detector = new MulticastDetector();
54
System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
55
System.out.println("jboss.identity = " + System.getProperty("jboss.identity"));
57
MBeanServer server = MBeanServerFactory.createMBeanServer();
59
registry = NetworkRegistry.getInstance();
60
server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));
62
int port = TestUtil.getRandomPort();
63
System.out.println("port = " + port);
65
String host = InetAddress.getLocalHost().getHostAddress();
66
String bindAddr = System.getProperty("jrunit.bind_addr", host);
67
InvokerLocator locator = new InvokerLocator("socket://" + bindAddr + ":" + port);
69
System.out.println("Starting remoting server with locator uri of: " + locator.getLocatorURI());
70
connector = new Connector();
71
connector.setInvokerLocator(locator.getLocatorURI());
74
TestInvocationHandler handler = new TestInvocationHandler();
75
connector.addInvocationHandler("mock", handler);
77
ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
78
server.registerMBean(connector, obj);
82
//Need to set new domain for identity
83
server.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector"));
89
public void tearDown() throws Exception
95
if (connector != null)
102
public static void main(String[] args)
104
org.apache.log4j.BasicConfigurator.configure();
105
org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
109
MulticastDetectorServer test = new MulticastDetectorServer();
119
static class TestInvocationHandler implements ServerInvocationHandler
121
public void addListener(InvokerCallbackHandler callbackHandler) {}
122
public Object invoke(final InvocationRequest invocation) throws Throwable
124
return "MulticastDetectorServer";
126
public void removeListener(InvokerCallbackHandler callbackHandler) {}
127
public void setMBeanServer(MBeanServer server) {}
128
public void setInvoker(ServerInvoker invoker) {}
b'\\ No newline at end of file'