From 0a0baee45ebcff44635907d457c4ff6810b09c87 Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Wed, 15 Apr 2015 09:47:28 +0000 Subject: QPID-6481: Move java source tree to top level git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1673693 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/example/Drain.java | 103 ------ .../main/java/org/apache/qpid/example/Hello.java | 83 ----- .../java/org/apache/qpid/example/ListReceiver.java | 101 ------ .../java/org/apache/qpid/example/ListSender.java | 86 ----- .../java/org/apache/qpid/example/MapReceiver.java | 52 --- .../java/org/apache/qpid/example/MapSender.java | 83 ----- .../java/org/apache/qpid/example/OptionParser.java | 351 --------------------- .../main/java/org/apache/qpid/example/Spout.java | 149 --------- .../java/org/apache/qpid/example/hello.properties | 27 -- 9 files changed, 1035 deletions(-) delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/Drain.java delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/ListReceiver.java delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/ListSender.java delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/MapReceiver.java delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/MapSender.java delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/Spout.java delete mode 100644 qpid/java/client/example/src/main/java/org/apache/qpid/example/hello.properties (limited to 'qpid/java/client/example/src/main') diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Drain.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Drain.java deleted file mode 100644 index f0eb83ad24..0000000000 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Drain.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.example; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Session; - -import org.apache.qpid.client.AMQAnyDestination; - -public class Drain extends OptionParser -{ - - static final Option FOREVER = new Option("f", - "forever", - "ignore timeout and wait forever", - null, - null, - Boolean.class); - - static final Option COUNT = new Option ("c", - "count", - "read c messages, then exit", - "COUNT", - "0", - Integer.class); - - - static - { - addOption(BROKER); - addOption(HELP); - addOption(TIMEOUT); - addOption(FOREVER); - addOption(COUNT); - addOption(CON_OPTIONS); - addOption(BROKER_OPTIONS); - } - - public Drain(String[] args, String usage, String desc) throws Exception - { - super(args, usage, desc); - - Connection con = createConnection(); - con.start(); - Session ssn = con.createSession(false,Session.AUTO_ACKNOWLEDGE); - Destination dest = new AMQAnyDestination(getAddress()); - MessageConsumer consumer = ssn.createConsumer(dest); - Message msg; - - long timeout = -1; - int count = 0; - int i = 0; - - if (containsOp(TIMEOUT)) { timeout = Integer.parseInt(getOp(TIMEOUT))*1000; } - if (containsOp(FOREVER)) { timeout = 0; } - if (containsOp(COUNT)) { count = Integer.parseInt(getOp(COUNT)); } - - while ((msg = consumer.receive(timeout)) != null) - { - System.out.println("\n------------- Msg -------------"); - System.out.println(msg); - System.out.println("-------------------------------\n"); - - if (count > 0) { - if (++i == count) { - break; - } - } - } - consumer.close(); - ssn.close(); - con.close(); - } - - public static void main(String[] args) throws Exception - { - String u = "Usage: drain [OPTIONS] 'ADDRESS'"; - String d = "Drains messages from the specified address."; - - new Drain(args,u,d); - } -} diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java deleted file mode 100644 index 109a72bcbf..0000000000 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.example; - -import java.io.InputStream; -import java.util.Properties; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.naming.Context; -import javax.naming.InitialContext; - - -public class Hello -{ - - public Hello() - { - } - - public static void main(String[] args) - { - Hello hello = new Hello(); - hello.runTest(); - } - - private void runTest() - { - try (InputStream resourceAsStream = this.getClass().getResourceAsStream("hello.properties")) - { - Properties properties = new Properties(); - properties.load(resourceAsStream); - Context context = new InitialContext(properties); - - ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("qpidConnectionfactory"); - Connection connection = connectionFactory.createConnection(); - connection.start(); - - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = (Destination) context.lookup("topicExchange"); - - MessageProducer messageProducer = session.createProducer(destination); - MessageConsumer messageConsumer = session.createConsumer(destination); - - TextMessage message = session.createTextMessage("Hello world!"); - messageProducer.send(message); - - message = (TextMessage)messageConsumer.receive(); - System.out.println(message.getText()); - - connection.close(); - context.close(); - } - catch (Exception exp) - { - exp.printStackTrace(); - } - } -} diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/ListReceiver.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/ListReceiver.java deleted file mode 100644 index b12cfab9de..0000000000 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/ListReceiver.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.example; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.MapMessage; -import javax.jms.StreamMessage; -import javax.jms.MessageConsumer; -import javax.jms.Session; -import javax.jms.MessageEOFException; - -import org.apache.qpid.client.AMQAnyDestination; -import org.apache.qpid.client.AMQConnection; - -import org.apache.qpid.jms.ListMessage; - -import java.util.Enumeration; -import java.util.Iterator; - -public class ListReceiver { - - public static void main(String[] args) throws Exception - { - if (args.length != 1) { - System.out.println("Usage: java org.apache.qpid.example.ListReceiver <-l | -m | -s>"); - System.out.println("where:"); - System.out.println("\t-l\tAccept ListMessage and print it"); - System.out.println("\t-m\tAccept ListMessage as a MapMessage"); - System.out.println("\t-s\tAccept ListMessage as a StreamMessage"); - return; - } - - Connection connection = - new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'"); - - connection.start(); - - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}"); - MessageConsumer consumer = session.createConsumer(queue); - - if (args[0].equals("-l")) { - System.out.println("Receiving as ListMessage"); - ListMessage m = (ListMessage)consumer.receive(); - System.out.println(m); - System.out.println("=========================================="); - System.out.println("Printing list contents:"); - Iterator i = m.iterator(); - while(i.hasNext()) - System.out.println(i.next()); - } - else if (args[0].equals("-m")) { - System.out.println("Receiving as MapMessage"); - MapMessage m = (MapMessage)consumer.receive(); - System.out.println(m); - System.out.println("=========================================="); - System.out.println("Printing map contents:"); - Enumeration keys = m.getMapNames(); - while(keys.hasMoreElements()) { - String key = (String)keys.nextElement(); - System.out.println(key + " => " + m.getObject(key)); - } - } - else if (args[0].equals("-s")) { - System.out.println("Receiving as StreamMessage"); - StreamMessage m = (StreamMessage)consumer.receive(); - System.out.println(m); - System.out.println("=========================================="); - System.out.println("Printing stream contents:"); - try { - while(true) - System.out.println(m.readObject()); - } - catch (MessageEOFException e) { - // DONE - } - } - - connection.close(); - } -} diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/ListSender.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/ListSender.java deleted file mode 100644 index fe2c1ec472..0000000000 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/ListSender.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.example; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Session; - -import org.apache.qpid.client.AMQAnyDestination; -import org.apache.qpid.client.AMQConnection; - -import org.apache.qpid.jms.ListMessage; - - -public class ListSender { - - public static void main(String[] args) throws Exception - { - Connection connection = - new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'"); - - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}"); - MessageProducer producer = session.createProducer(queue); - - ListMessage m = ((org.apache.qpid.jms.Session)session).createListMessage(); - m.setIntProperty("Id", 987654321); - m.setStringProperty("name", "Widget"); - m.setDoubleProperty("price", 0.99); - - List colors = new ArrayList(); - colors.add("red"); - colors.add("green"); - colors.add("white"); - m.add(colors); - - Map dimensions = new HashMap(); - dimensions.put("length",10.2); - dimensions.put("width",5.1); - dimensions.put("depth",2.0); - m.add(dimensions); - - List> parts = new ArrayList>(); - parts.add(Arrays.asList(new Integer[] {1,2,5})); - parts.add(Arrays.asList(new Integer[] {8,2,5})); - m.add(parts); - - Map specs = new HashMap(); - specs.put("colours", colors); - specs.put("dimensions", dimensions); - specs.put("parts", parts); - m.add(specs); - - producer.send((Message)m); - System.out.println("Sent: " + m); - connection.close(); - } - -} diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/MapReceiver.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/MapReceiver.java deleted file mode 100644 index 89db04f8d3..0000000000 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/MapReceiver.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.example; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.MapMessage; -import javax.jms.MessageConsumer; -import javax.jms.Session; - -import org.apache.qpid.client.AMQAnyDestination; -import org.apache.qpid.client.AMQConnection; - - -public class MapReceiver { - - public static void main(String[] args) throws Exception - { - Connection connection = - new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'"); - - connection.start(); - - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}"); - MessageConsumer consumer = session.createConsumer(queue); - - MapMessage m = (MapMessage)consumer.receive(); - System.out.println(m); - connection.close(); - } - -} \ No newline at end of file diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/MapSender.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/MapSender.java deleted file mode 100644 index 0ce9383add..0000000000 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/MapSender.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.example; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.MapMessage; -import javax.jms.MessageProducer; -import javax.jms.Session; - -import org.apache.qpid.client.AMQAnyDestination; -import org.apache.qpid.client.AMQConnection; - - -public class MapSender { - - public static void main(String[] args) throws Exception - { - Connection connection = - new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'"); - - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}"); - MessageProducer producer = session.createProducer(queue); - - MapMessage m = session.createMapMessage(); - m.setIntProperty("Id", 987654321); - m.setStringProperty("name", "Widget"); - m.setDoubleProperty("price", 0.99); - - List colors = new ArrayList(); - colors.add("red"); - colors.add("green"); - colors.add("white"); - m.setObject("colours", colors); - - Map dimensions = new HashMap(); - dimensions.put("length",10.2); - dimensions.put("width",5.1); - dimensions.put("depth",2.0); - m.setObject("dimensions",dimensions); - - List> parts = new ArrayList>(); - parts.add(Arrays.asList(new Integer[] {1,2,5})); - parts.add(Arrays.asList(new Integer[] {8,2,5})); - m.setObject("parts", parts); - - Map specs = new HashMap(); - specs.put("colours", colors); - specs.put("dimensions", dimensions); - specs.put("parts", parts); - m.setObject("specs",specs); - - producer.send(m); - connection.close(); - } - -} \ No newline at end of file diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java deleted file mode 100644 index 9360be4106..0000000000 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/OptionParser.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.example; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.jms.Connection; - -import org.apache.qpid.client.AMQConnection; - -public class OptionParser -{ - static final Option BROKER = new Option("b", - "broker", - "connect to specified broker", - "USER:PASS@HOST:PORT", - "guest:guest@localhost:5672", - String.class); - - static final Option HELP = new Option("h", - "help", - "show this help message and exit", - null, - null, - Boolean.class); - - static final Option TIMEOUT = new Option("t", - "timeout", - "timeout in seconds to wait before exiting", - "TIMEOUT", - "0", - Integer.class); - - static final Option CON_OPTIONS = new Option(null, - "con-option", - "JMS Connection URL options. Ex sync_ack=true sync_publish=all ", - "NAME=VALUE", - null, - String.class); - - - static final Option BROKER_OPTIONS = new Option(null, - "broker-option", - "JMS Broker URL options. Ex ssl=true sasl_mechs=GSSAPI ", - "NAME=VALUE", - null, - String.class); - - - private Map optMap = new HashMap(); - private static final List