This is from the java_first_jms sample that I cleaned up. Why is the URL in
the server factory trivial? Why doesn't it need to state the host and the
port? Is 61616 some sort of a default?
Also, how would this look using the JAX-WS Endpoint class?
boolean amqBroker = args.length > 0 && "-activemqbroker".equals(args[0]);
if (amqBroker) {
/*
* The following make it easier to run this against something
other than ActiveMQ. You will have
* to get a JMS broker onto the right port of localhost.
*/
Class<?> brokerClass = ServerJMS.class.getClassLoader()
.loadClass("org.apache.activemq.broker.BrokerService");
if (brokerClass == null) {
System.err.println("ActiveMQ is not in the classpath, cannot
launch broker.");
return;
}
Object broker = brokerClass.newInstance();
Method addConnectorMethod =
brokerClass.getMethod("addConnector", String.class);
addConnectorMethod.invoke(broker, "tcp://localhost:61616");
Method startMethod = brokerClass.getMethod("start");
startMethod.invoke(broker);
}
Object implementor = new HelloWorldImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(HelloWorld.class);
svrFactory.setAddress("jms://");
svrFactory.setServiceBean(implementor);
svrFactory.create();
System.out.println("Server ready... Press any key to exit");
System.in.read();
System.out.println("Server exiting");
System.exit(0);