You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ha...@apache.org on 2014/04/29 20:34:23 UTC
[11/14] Use autocrlf consistently for line endings
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java
index 20a33ff..01a8966 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverUriTest.java
@@ -1,48 +1,48 @@
-/**
- * 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.activemq.transport.failover;
-
-import junit.framework.Test;
-
-import org.apache.activemq.transport.tcp.TransportUriTest;
-
-public class FailoverUriTest extends TransportUriTest {
-
- @Override
- public void initCombosForTestUriOptionsWork() {
- addCombinationValues("prefix", new Object[]{"failover:(", "failover://("});
- addCombinationValues("postfix", new Object[] {")?initialReconnectDelay=1000&maxReconnectDelay=1000"
- , "?wireFormat.tightEncodingEnabled=false)?jms.useAsyncSend=true&jms.copyMessageOnSend=false"
- , "?wireFormat.maxInactivityDuration=0&keepAlive=true)?jms.prefetchPolicy.all=500&initialReconnectDelay=10000&useExponentialBackOff=false&maxReconnectAttempts=0&randomize=false"});
- }
-
- @Override
- public void initCombosForTestBadVersionNumberDoesNotWork() {
- addCombinationValues("prefix", new Object[]{"failover:("});
- addCombinationValues("postfix", new Object[] {")?initialReconnectDelay=1000&maxReconnectDelay=1000"});
- }
-
- @Override
- public void initCombosForTestBadPropertyNameFails() {
- addCombinationValues("prefix", new Object[]{"failover:("});
- addCombinationValues("postfix", new Object[] {")?initialReconnectDelay=1000&maxReconnectDelay=1000"});
- }
-
- public static Test suite() {
- return suite(FailoverUriTest.class);
- }
-}
+/**
+ * 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.activemq.transport.failover;
+
+import junit.framework.Test;
+
+import org.apache.activemq.transport.tcp.TransportUriTest;
+
+public class FailoverUriTest extends TransportUriTest {
+
+ @Override
+ public void initCombosForTestUriOptionsWork() {
+ addCombinationValues("prefix", new Object[]{"failover:(", "failover://("});
+ addCombinationValues("postfix", new Object[] {")?initialReconnectDelay=1000&maxReconnectDelay=1000"
+ , "?wireFormat.tightEncodingEnabled=false)?jms.useAsyncSend=true&jms.copyMessageOnSend=false"
+ , "?wireFormat.maxInactivityDuration=0&keepAlive=true)?jms.prefetchPolicy.all=500&initialReconnectDelay=10000&useExponentialBackOff=false&maxReconnectAttempts=0&randomize=false"});
+ }
+
+ @Override
+ public void initCombosForTestBadVersionNumberDoesNotWork() {
+ addCombinationValues("prefix", new Object[]{"failover:("});
+ addCombinationValues("postfix", new Object[] {")?initialReconnectDelay=1000&maxReconnectDelay=1000"});
+ }
+
+ @Override
+ public void initCombosForTestBadPropertyNameFails() {
+ addCombinationValues("prefix", new Object[]{"failover:("});
+ addCombinationValues("postfix", new Object[] {")?initialReconnectDelay=1000&maxReconnectDelay=1000"});
+ }
+
+ public static Test suite() {
+ return suite(FailoverUriTest.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.java
index bd4f64a..bef912a 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/DurableSubscriptionHangTestCase.java
@@ -1,135 +1,135 @@
-/**
- * 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.activemq.usecases;
-
-import java.util.concurrent.TimeUnit;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicSession;
-import javax.jms.TopicSubscriber;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.commons.lang.RandomStringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-import static org.junit.Assert.assertNotNull;
-
-public class DurableSubscriptionHangTestCase {
- private static final Logger LOG = LoggerFactory.getLogger(DurableSubscriptionHangTestCase.class);
- final static String brokerName = "DurableSubscriptionHangTestCase";
- final static String clientID = "myId";
- private static final String topicName = "myTopic";
- private static final String durableSubName = "mySub";
- BrokerService brokerService;
-
- @Before
- public void startBroker() throws Exception {
- brokerService = new BrokerService();
- brokerService.setDeleteAllMessagesOnStartup(true);
- brokerService.setBrokerName(brokerName);
- PolicyMap policyMap = new PolicyMap();
- PolicyEntry defaultEntry = new PolicyEntry();
- defaultEntry.setExpireMessagesPeriod(5000);
- policyMap.setDefaultEntry(defaultEntry);
- brokerService.setDestinationPolicy(policyMap);
- brokerService.start();
- }
-
- @After
- public void brokerStop() throws Exception {
- brokerService.stop();
- }
-
- @Test
- public void testHanging() throws Exception
- {
- registerDurableSubscription();
- produceExpiredAndOneNonExpiredMessages();
- TimeUnit.SECONDS.sleep(10); // make sure messages are expired
- Message message = collectMessagesFromDurableSubscriptionForOneMinute();
- LOG.info("got message:" + message);
- assertNotNull("Unable to read unexpired message", message);
- }
-
- private void produceExpiredAndOneNonExpiredMessages() throws JMSException {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
- TopicConnection connection = connectionFactory.createTopicConnection();
- TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
- Topic topic = session.createTopic(topicName);
- MessageProducer producer = session.createProducer(topic);
- producer.setTimeToLive(TimeUnit.SECONDS.toMillis(1));
- for(int i=0; i<40000; i++)
- {
- sendRandomMessage(session, producer);
- }
- producer.setTimeToLive(TimeUnit.DAYS.toMillis(1));
- sendRandomMessage(session, producer);
- connection.close();
- LOG.info("produceExpiredAndOneNonExpiredMessages done");
- }
-
- private void registerDurableSubscription() throws JMSException
- {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
- TopicConnection connection = connectionFactory.createTopicConnection();
- connection.setClientID(clientID);
- TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
- Topic topic = topicSession.createTopic(topicName);
- TopicSubscriber durableSubscriber = topicSession.createDurableSubscriber(topic, durableSubName);
- connection.start();
- durableSubscriber.close();
- connection.close();
- LOG.info("Durable Sub Registered");
- }
-
- private Message collectMessagesFromDurableSubscriptionForOneMinute() throws Exception
- {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
- TopicConnection connection = connectionFactory.createTopicConnection();
-
- connection.setClientID(clientID);
- TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
- Topic topic = topicSession.createTopic(topicName);
- connection.start();
- TopicSubscriber subscriber = topicSession.createDurableSubscriber(topic, durableSubName);
- LOG.info("About to receive messages");
- Message message = subscriber.receive(120000);
- subscriber.close();
- connection.close();
- LOG.info("collectMessagesFromDurableSubscriptionForOneMinute done");
-
- return message;
- }
-
- private void sendRandomMessage(TopicSession session, MessageProducer producer) throws JMSException {
- TextMessage textMessage = session.createTextMessage();
- textMessage.setText(RandomStringUtils.random(500, "abcdefghijklmnopqrstuvwxyz"));
- producer.send(textMessage);
- }
-}
+/**
+ * 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.activemq.usecases;
+
+import java.util.concurrent.TimeUnit;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicSession;
+import javax.jms.TopicSubscriber;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.region.policy.PolicyEntry;
+import org.apache.activemq.broker.region.policy.PolicyMap;
+import org.apache.commons.lang.RandomStringUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import static org.junit.Assert.assertNotNull;
+
+public class DurableSubscriptionHangTestCase {
+ private static final Logger LOG = LoggerFactory.getLogger(DurableSubscriptionHangTestCase.class);
+ final static String brokerName = "DurableSubscriptionHangTestCase";
+ final static String clientID = "myId";
+ private static final String topicName = "myTopic";
+ private static final String durableSubName = "mySub";
+ BrokerService brokerService;
+
+ @Before
+ public void startBroker() throws Exception {
+ brokerService = new BrokerService();
+ brokerService.setDeleteAllMessagesOnStartup(true);
+ brokerService.setBrokerName(brokerName);
+ PolicyMap policyMap = new PolicyMap();
+ PolicyEntry defaultEntry = new PolicyEntry();
+ defaultEntry.setExpireMessagesPeriod(5000);
+ policyMap.setDefaultEntry(defaultEntry);
+ brokerService.setDestinationPolicy(policyMap);
+ brokerService.start();
+ }
+
+ @After
+ public void brokerStop() throws Exception {
+ brokerService.stop();
+ }
+
+ @Test
+ public void testHanging() throws Exception
+ {
+ registerDurableSubscription();
+ produceExpiredAndOneNonExpiredMessages();
+ TimeUnit.SECONDS.sleep(10); // make sure messages are expired
+ Message message = collectMessagesFromDurableSubscriptionForOneMinute();
+ LOG.info("got message:" + message);
+ assertNotNull("Unable to read unexpired message", message);
+ }
+
+ private void produceExpiredAndOneNonExpiredMessages() throws JMSException {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
+ TopicConnection connection = connectionFactory.createTopicConnection();
+ TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ Topic topic = session.createTopic(topicName);
+ MessageProducer producer = session.createProducer(topic);
+ producer.setTimeToLive(TimeUnit.SECONDS.toMillis(1));
+ for(int i=0; i<40000; i++)
+ {
+ sendRandomMessage(session, producer);
+ }
+ producer.setTimeToLive(TimeUnit.DAYS.toMillis(1));
+ sendRandomMessage(session, producer);
+ connection.close();
+ LOG.info("produceExpiredAndOneNonExpiredMessages done");
+ }
+
+ private void registerDurableSubscription() throws JMSException
+ {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
+ TopicConnection connection = connectionFactory.createTopicConnection();
+ connection.setClientID(clientID);
+ TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ Topic topic = topicSession.createTopic(topicName);
+ TopicSubscriber durableSubscriber = topicSession.createDurableSubscriber(topic, durableSubName);
+ connection.start();
+ durableSubscriber.close();
+ connection.close();
+ LOG.info("Durable Sub Registered");
+ }
+
+ private Message collectMessagesFromDurableSubscriptionForOneMinute() throws Exception
+ {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName);
+ TopicConnection connection = connectionFactory.createTopicConnection();
+
+ connection.setClientID(clientID);
+ TopicSession topicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ Topic topic = topicSession.createTopic(topicName);
+ connection.start();
+ TopicSubscriber subscriber = topicSession.createDurableSubscriber(topic, durableSubName);
+ LOG.info("About to receive messages");
+ Message message = subscriber.receive(120000);
+ subscriber.close();
+ connection.close();
+ LOG.info("collectMessagesFromDurableSubscriptionForOneMinute done");
+
+ return message;
+ }
+
+ private void sendRandomMessage(TopicSession session, MessageProducer producer) throws JMSException {
+ TextMessage textMessage = session.createTextMessage();
+ textMessage.setText(RandomStringUtils.random(500, "abcdefghijklmnopqrstuvwxyz"));
+ producer.send(textMessage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java
index ac6b314..2d3b64c 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/TestBrokerConnectionDuplexExcludedDestinations.java
@@ -1,171 +1,171 @@
-/**
- * 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.activemq.usecases;
-
-import java.net.URI;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import junit.framework.TestCase;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-
-public class TestBrokerConnectionDuplexExcludedDestinations extends TestCase {
-
- BrokerService receiverBroker;
- BrokerService senderBroker;
-
- Connection hubConnection;
- Session hubSession;
-
- Connection spokeConnection;
- Session spokeSession;
-
- @Override
- public void setUp() throws Exception {
- // Hub broker
- String configFileName = "org/apache/activemq/usecases/receiver-duplex.xml";
- URI uri = new URI("xbean:" + configFileName);
- receiverBroker = BrokerFactory.createBroker(uri);
- receiverBroker.setPersistent(false);
- receiverBroker.setBrokerName("Hub");
-
- // Spoke broker
- configFileName = "org/apache/activemq/usecases/sender-duplex.xml";
- uri = new URI("xbean:" + configFileName);
- senderBroker = BrokerFactory.createBroker(uri);
- senderBroker.setPersistent(false);
- senderBroker.setBrokerName("Spoke");
-
- // Start both Hub and Spoke broker
- receiverBroker.start();
- senderBroker.start();
-
- // create hub session
- ConnectionFactory cfHub = new ActiveMQConnectionFactory("tcp://localhost:62002");
-
- hubConnection = cfHub.createConnection();
- hubConnection.start();
- hubSession = hubConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // create spoke session
- ConnectionFactory cfSpoke = new ActiveMQConnectionFactory("tcp://localhost:62001");
- spokeConnection = cfSpoke.createConnection();
- spokeConnection.start();
- spokeSession = spokeConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- }
-
- @Override
- public void tearDown() throws Exception {
- hubSession.close();
- hubConnection.stop();
- hubConnection.close();
-
- spokeSession.close();
- spokeConnection.stop();
- spokeConnection.close();
-
- senderBroker.stop();
- receiverBroker.stop();
- }
-
- public void testDuplexSendFromHubToSpoke() throws Exception {
-
- //create hub producer
- MessageProducer hubProducer = hubSession.createProducer(null);
- hubProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- hubProducer.setDisableMessageID(true);
- hubProducer.setDisableMessageTimestamp(true);
-
- //create spoke producer
- MessageProducer spokeProducer = hubSession.createProducer(null);
- spokeProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- spokeProducer.setDisableMessageID(true);
- spokeProducer.setDisableMessageTimestamp(true);
-
- Queue excludedQueueHub = hubSession.createQueue("exclude.test.foo");
- TextMessage excludedMsgHub = hubSession.createTextMessage();
- excludedMsgHub.setText(excludedQueueHub.toString());
-
- Queue includedQueueHub = hubSession.createQueue("include.test.foo");
-
- TextMessage includedMsgHub = hubSession.createTextMessage();
- includedMsgHub.setText(includedQueueHub.toString());
-
- Queue alwaysIncludedQueueHub = hubSession.createQueue("always.include.test.foo");
-
- TextMessage alwaysIncludedMsgHub = hubSession.createTextMessage();
- alwaysIncludedMsgHub.setText(alwaysIncludedQueueHub.toString());
-
- // Sending from Hub queue
- hubProducer.send(excludedQueueHub, excludedMsgHub);
- hubProducer.send(includedQueueHub, includedMsgHub);
- hubProducer.send(alwaysIncludedQueueHub, alwaysIncludedMsgHub);
-
- Queue excludedQueueSpoke = spokeSession.createQueue("exclude.test.foo");
- MessageConsumer excludedConsumerSpoke = spokeSession.createConsumer(excludedQueueSpoke);
-
- Thread.sleep(100);
-
- Queue includedQueueSpoke = spokeSession.createQueue("include.test.foo");
- MessageConsumer includedConsumerSpoke = spokeSession.createConsumer(includedQueueSpoke);
-
- Thread.sleep(100);
-
- Queue alwaysIncludedQueueSpoke = spokeSession.createQueue("always.include.test.foo");
- MessageConsumer alwaysIncludedConsumerSpoke = spokeSession.createConsumer(alwaysIncludedQueueHub);
-
- Thread.sleep(100);
- TextMessage alwaysIncludedMsgSpoke = spokeSession.createTextMessage();
- alwaysIncludedMsgSpoke.setText(alwaysIncludedQueueSpoke.toString());
- spokeProducer.send(alwaysIncludedQueueSpoke, alwaysIncludedMsgSpoke);
-
- MessageConsumer alwaysIncludedConsumerHub = spokeSession.createConsumer(alwaysIncludedQueueHub);
- assertNotNull(alwaysIncludedConsumerHub);
-
- // Receiving from excluded Spoke queue
- Message msg = excludedConsumerSpoke.receive(200);
- assertNull(msg);
-
- // Receiving from included Spoke queue
- msg = includedConsumerSpoke.receive(200);
- assertEquals(includedMsgHub, msg);
-
- // Receiving from included Spoke queue
- msg = alwaysIncludedConsumerSpoke.receive(200);
- assertEquals(alwaysIncludedMsgHub, msg);
-
- // we should be able to receive excluded queue message on Hub
- MessageConsumer excludedConsumerHub = hubSession.createConsumer(excludedQueueHub);
- msg = excludedConsumerHub.receive(200);;
- assertEquals(excludedMsgHub, msg);
-
- hubProducer.close();
- excludedConsumerSpoke.close();
- }
-}
+/**
+ * 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.activemq.usecases;
+
+import java.net.URI;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import junit.framework.TestCase;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+
+public class TestBrokerConnectionDuplexExcludedDestinations extends TestCase {
+
+ BrokerService receiverBroker;
+ BrokerService senderBroker;
+
+ Connection hubConnection;
+ Session hubSession;
+
+ Connection spokeConnection;
+ Session spokeSession;
+
+ @Override
+ public void setUp() throws Exception {
+ // Hub broker
+ String configFileName = "org/apache/activemq/usecases/receiver-duplex.xml";
+ URI uri = new URI("xbean:" + configFileName);
+ receiverBroker = BrokerFactory.createBroker(uri);
+ receiverBroker.setPersistent(false);
+ receiverBroker.setBrokerName("Hub");
+
+ // Spoke broker
+ configFileName = "org/apache/activemq/usecases/sender-duplex.xml";
+ uri = new URI("xbean:" + configFileName);
+ senderBroker = BrokerFactory.createBroker(uri);
+ senderBroker.setPersistent(false);
+ senderBroker.setBrokerName("Spoke");
+
+ // Start both Hub and Spoke broker
+ receiverBroker.start();
+ senderBroker.start();
+
+ // create hub session
+ ConnectionFactory cfHub = new ActiveMQConnectionFactory("tcp://localhost:62002");
+
+ hubConnection = cfHub.createConnection();
+ hubConnection.start();
+ hubSession = hubConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // create spoke session
+ ConnectionFactory cfSpoke = new ActiveMQConnectionFactory("tcp://localhost:62001");
+ spokeConnection = cfSpoke.createConnection();
+ spokeConnection.start();
+ spokeSession = spokeConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ hubSession.close();
+ hubConnection.stop();
+ hubConnection.close();
+
+ spokeSession.close();
+ spokeConnection.stop();
+ spokeConnection.close();
+
+ senderBroker.stop();
+ receiverBroker.stop();
+ }
+
+ public void testDuplexSendFromHubToSpoke() throws Exception {
+
+ //create hub producer
+ MessageProducer hubProducer = hubSession.createProducer(null);
+ hubProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ hubProducer.setDisableMessageID(true);
+ hubProducer.setDisableMessageTimestamp(true);
+
+ //create spoke producer
+ MessageProducer spokeProducer = hubSession.createProducer(null);
+ spokeProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ spokeProducer.setDisableMessageID(true);
+ spokeProducer.setDisableMessageTimestamp(true);
+
+ Queue excludedQueueHub = hubSession.createQueue("exclude.test.foo");
+ TextMessage excludedMsgHub = hubSession.createTextMessage();
+ excludedMsgHub.setText(excludedQueueHub.toString());
+
+ Queue includedQueueHub = hubSession.createQueue("include.test.foo");
+
+ TextMessage includedMsgHub = hubSession.createTextMessage();
+ includedMsgHub.setText(includedQueueHub.toString());
+
+ Queue alwaysIncludedQueueHub = hubSession.createQueue("always.include.test.foo");
+
+ TextMessage alwaysIncludedMsgHub = hubSession.createTextMessage();
+ alwaysIncludedMsgHub.setText(alwaysIncludedQueueHub.toString());
+
+ // Sending from Hub queue
+ hubProducer.send(excludedQueueHub, excludedMsgHub);
+ hubProducer.send(includedQueueHub, includedMsgHub);
+ hubProducer.send(alwaysIncludedQueueHub, alwaysIncludedMsgHub);
+
+ Queue excludedQueueSpoke = spokeSession.createQueue("exclude.test.foo");
+ MessageConsumer excludedConsumerSpoke = spokeSession.createConsumer(excludedQueueSpoke);
+
+ Thread.sleep(100);
+
+ Queue includedQueueSpoke = spokeSession.createQueue("include.test.foo");
+ MessageConsumer includedConsumerSpoke = spokeSession.createConsumer(includedQueueSpoke);
+
+ Thread.sleep(100);
+
+ Queue alwaysIncludedQueueSpoke = spokeSession.createQueue("always.include.test.foo");
+ MessageConsumer alwaysIncludedConsumerSpoke = spokeSession.createConsumer(alwaysIncludedQueueHub);
+
+ Thread.sleep(100);
+ TextMessage alwaysIncludedMsgSpoke = spokeSession.createTextMessage();
+ alwaysIncludedMsgSpoke.setText(alwaysIncludedQueueSpoke.toString());
+ spokeProducer.send(alwaysIncludedQueueSpoke, alwaysIncludedMsgSpoke);
+
+ MessageConsumer alwaysIncludedConsumerHub = spokeSession.createConsumer(alwaysIncludedQueueHub);
+ assertNotNull(alwaysIncludedConsumerHub);
+
+ // Receiving from excluded Spoke queue
+ Message msg = excludedConsumerSpoke.receive(200);
+ assertNull(msg);
+
+ // Receiving from included Spoke queue
+ msg = includedConsumerSpoke.receive(200);
+ assertEquals(includedMsgHub, msg);
+
+ // Receiving from included Spoke queue
+ msg = alwaysIncludedConsumerSpoke.receive(200);
+ assertEquals(alwaysIncludedMsgHub, msg);
+
+ // we should be able to receive excluded queue message on Hub
+ MessageConsumer excludedConsumerHub = hubSession.createConsumer(excludedQueueHub);
+ msg = excludedConsumerHub.receive(200);;
+ assertEquals(excludedMsgHub, msg);
+
+ hubProducer.close();
+ excludedConsumerSpoke.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-duplex.xml
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-duplex.xml b/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-duplex.xml
index d13c9a0..a8195c0 100644
--- a/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-duplex.xml
+++ b/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-duplex.xml
@@ -1,63 +1,63 @@
-<!--
- 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.
--->
-<beans
- xmlns="http://www.springframework.org/schema/beans"
- xmlns:amq="http://activemq.apache.org/schema/core"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
-
- <!-- Allows us to use system properties as variables in this configuration file -->
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
-
- <broker brokerName="sender" persistent="false" useJmx="true" xmlns="http://activemq.apache.org/schema/core" > <!-- dataDirectory="${activemq.base}/data"> -->
-
-
- <!-- The store and forward broker networks ActiveMQ will listen to -->
- <networkConnectors>
- <!-- by default just auto discover the other brokers -->
- <networkConnector name="monitoring" uri="static:(tcp://localhost:62002)" duplex="true" >
- <dynamicallyIncludedDestinations>
- <queue physicalName="include.test.foo"/>
- <topic physicalName="include.test.bar"/>
- </dynamicallyIncludedDestinations>
- <excludedDestinations>
- <queue physicalName="exclude.test.foo"/>
- <topic physicalName="exclude.test.bar"/>
- </excludedDestinations>
- <staticallyIncludedDestinations>
- <queue physicalName="always.include.test.foo"/>
- <topic physicalName="always.include.test.bar"/>
- </staticallyIncludedDestinations>
-
- </networkConnector>
- </networkConnectors>
-
-
-
- <!-- The transport connectors ActiveMQ will listen to -->
- <transportConnectors>
- <transportConnector uri="tcp://localhost:62001"/>
- </transportConnectors>
-
-
- </broker>
-
-
-</beans>
-
-
+<!--
+ 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.
+-->
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+
+ <!-- Allows us to use system properties as variables in this configuration file -->
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+ <broker brokerName="sender" persistent="false" useJmx="true" xmlns="http://activemq.apache.org/schema/core" > <!-- dataDirectory="${activemq.base}/data"> -->
+
+
+ <!-- The store and forward broker networks ActiveMQ will listen to -->
+ <networkConnectors>
+ <!-- by default just auto discover the other brokers -->
+ <networkConnector name="monitoring" uri="static:(tcp://localhost:62002)" duplex="true" >
+ <dynamicallyIncludedDestinations>
+ <queue physicalName="include.test.foo"/>
+ <topic physicalName="include.test.bar"/>
+ </dynamicallyIncludedDestinations>
+ <excludedDestinations>
+ <queue physicalName="exclude.test.foo"/>
+ <topic physicalName="exclude.test.bar"/>
+ </excludedDestinations>
+ <staticallyIncludedDestinations>
+ <queue physicalName="always.include.test.foo"/>
+ <topic physicalName="always.include.test.bar"/>
+ </staticallyIncludedDestinations>
+
+ </networkConnector>
+ </networkConnectors>
+
+
+
+ <!-- The transport connectors ActiveMQ will listen to -->
+ <transportConnectors>
+ <transportConnector uri="tcp://localhost:62001"/>
+ </transportConnectors>
+
+
+ </broker>
+
+
+</beans>
+
+
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-unit-tests/src/test/resources/spring-embedded-xbean-local.xml
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/resources/spring-embedded-xbean-local.xml b/activemq-unit-tests/src/test/resources/spring-embedded-xbean-local.xml
index ae3652c..584faea 100644
--- a/activemq-unit-tests/src/test/resources/spring-embedded-xbean-local.xml
+++ b/activemq-unit-tests/src/test/resources/spring-embedded-xbean-local.xml
@@ -1,80 +1,80 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<!-- START SNIPPET: spring -->
-<beans
- xmlns="http://www.springframework.org/schema/beans"
- xmlns:amq="http://activemq.apache.org/schema/core"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://activemq.apache.org/schema/core classpath:activemq.xsd">
-
- <!-- lets create an embedded ActiveMQ Broker -->
- <amq:broker useJmx="false" persistent="false">
- <amq:transportConnectors>
- <amq:transportConnector uri="tcp://localhost:0" />
- </amq:transportConnectors>
- </amq:broker>
-
- <!-- ActiveMQ destinations to use -->
- <amq:queue id="destination" physicalName="org.apache.activemq.spring.Test.spring.embedded"/>
-
- <!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
- <amq:connectionFactory id="jmsFactory" brokerURL="vm://localhost"/>
-
-
- <!-- Spring JMS Template -->
- <bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
- <property name="connectionFactory">
- <!-- lets wrap in a pool to avoid creating a connection per send -->
- <bean class="org.springframework.jms.connection.SingleConnectionFactory">
- <property name="targetConnectionFactory">
- <ref local="jmsFactory" />
- </property>
- </bean>
- </property>
- </bean>
-
- <bean id="consumerJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
- <property name="connectionFactory" ref="jmsFactory"/>
- </bean>
-
- <!-- a sample POJO which uses a Spring JmsTemplate -->
- <bean id="producer" class="org.apache.activemq.spring.SpringProducer">
- <property name="template">
- <ref bean="myJmsTemplate"></ref>
- </property>
-
- <property name="destination">
- <ref bean="destination" />
- </property>
-
- <property name="messageCount">
- <value>10</value>
- </property>
- </bean>
-
- <!-- a sample POJO consumer -->
- <bean id="consumer" class="org.apache.activemq.spring.SpringConsumer">
- <property name="template" ref="consumerJmsTemplate"/>
- <property name="destination" ref="destination"/>
- </bean>
-
-</beans>
-
-<!-- END SNIPPET: spring -->
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!-- START SNIPPET: spring -->
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.apache.org/schema/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.apache.org/schema/core classpath:activemq.xsd">
+
+ <!-- lets create an embedded ActiveMQ Broker -->
+ <amq:broker useJmx="false" persistent="false">
+ <amq:transportConnectors>
+ <amq:transportConnector uri="tcp://localhost:0" />
+ </amq:transportConnectors>
+ </amq:broker>
+
+ <!-- ActiveMQ destinations to use -->
+ <amq:queue id="destination" physicalName="org.apache.activemq.spring.Test.spring.embedded"/>
+
+ <!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
+ <amq:connectionFactory id="jmsFactory" brokerURL="vm://localhost"/>
+
+
+ <!-- Spring JMS Template -->
+ <bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
+ <property name="connectionFactory">
+ <!-- lets wrap in a pool to avoid creating a connection per send -->
+ <bean class="org.springframework.jms.connection.SingleConnectionFactory">
+ <property name="targetConnectionFactory">
+ <ref local="jmsFactory" />
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="consumerJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
+ <property name="connectionFactory" ref="jmsFactory"/>
+ </bean>
+
+ <!-- a sample POJO which uses a Spring JmsTemplate -->
+ <bean id="producer" class="org.apache.activemq.spring.SpringProducer">
+ <property name="template">
+ <ref bean="myJmsTemplate"></ref>
+ </property>
+
+ <property name="destination">
+ <ref bean="destination" />
+ </property>
+
+ <property name="messageCount">
+ <value>10</value>
+ </property>
+ </bean>
+
+ <!-- a sample POJO consumer -->
+ <bean id="consumer" class="org.apache.activemq.spring.SpringConsumer">
+ <property name="template" ref="consumerJmsTemplate"/>
+ <property name="destination" ref="destination"/>
+ </bean>
+
+</beans>
+
+<!-- END SNIPPET: spring -->
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/formatTimestamp.tag
----------------------------------------------------------------------
diff --git a/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/formatTimestamp.tag b/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/formatTimestamp.tag
index 1a4a54b..f8b9cdc 100644
--- a/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/formatTimestamp.tag
+++ b/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/formatTimestamp.tag
@@ -1,29 +1,29 @@
-<%--
- 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.
---%>
-<%@ attribute name="timestamp" type="java.lang.String"%>
-<%@ tag import="java.util.Date" %>
-<%@ tag import="java.text.SimpleDateFormat" %>
-<%
- if (timestamp != null) {
- long time = Long.parseLong(timestamp);
- Date date = new Date(time);
-
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS z");
-
- out.println(formatter.format(date));
- }
-%>
+<%--
+ 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.
+--%>
+<%@ attribute name="timestamp" type="java.lang.String"%>
+<%@ tag import="java.util.Date" %>
+<%@ tag import="java.text.SimpleDateFormat" %>
+<%
+ if (timestamp != null) {
+ long time = Long.parseLong(timestamp);
+ Date date = new Date(time);
+
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS z");
+
+ out.println(formatter.format(date));
+ }
+%>
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-web-demo/src/main/webapp/js/amq.js
----------------------------------------------------------------------
diff --git a/activemq-web-demo/src/main/webapp/js/amq.js b/activemq-web-demo/src/main/webapp/js/amq.js
index 2d7cf6b..773719b 100644
--- a/activemq-web-demo/src/main/webapp/js/amq.js
+++ b/activemq-web-demo/src/main/webapp/js/amq.js
@@ -1,307 +1,307 @@
-/**
- *
- * 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.
- */
-
-// AMQ Ajax handler
-// This class provides the main API for using the Ajax features of AMQ. It
-// allows JMS messages to be sent and received from javascript when used
-// with the org.apache.activemq.web.MessageListenerServlet.
-//
-// This version of the file provides an adapter interface for the jquery library
-// and a namespace for the Javascript file, private/public variables and
-// methods, and other scripting niceties. -- jim cook 2007/08/28
-
-var org = org || {};
-org.activemq = org.activemq || {};
-
-org.activemq.Amq = function() {
- var connectStatusHandler;
-
- // Just a shortcut to eliminate some redundant typing.
- var adapter = org.activemq.AmqAdapter;
-
- if (typeof adapter == 'undefined') {
- throw 'An org.activemq.AmqAdapter must be declared before the amq.js script file.'
- }
-
- // The URI of the AjaxServlet.
- var uri;
-
- // The number of seconds that the long-polling socket will stay connected.
- // Best to keep this to a value less than one minute.
- var timeout;
-
- // A session should not be considered initialized until the JSESSIONID is returned
- // from the initial GET request. Otherwise subscription POSTS may register the
- // subscription with the wrong session.
- var sessionInitialized = false;
-
- // This callback will be called after the first GET request returns.
- var sessionInitializedCallback;
-
- // Poll delay. if set to positive integer, this is the time to wait in ms
- // before sending the next poll after the last completes.
- var pollDelay;
-
- // Inidicates whether logging is active or not. Not by default.
- var logging = false;
-
- // 5 second delay if an error occurs during poll. This could be due to
- // server capacity problems or a timeout condition.
- var pollErrorDelay = 5000;
-
- // Map of handlers that will respond to message receipts. The id used during
- // addListener(id, destination, handler) is used to key the callback
- // handler.
- var messageHandlers = {};
-
- // Indicates whether an AJAX post call is in progress.
- var batchInProgress = false;
-
- // A collection of pending messages that accumulate when an AJAX call is in
- // progress. These messages will be delivered as soon as the current call
- // completes. The array contains objects in the format { destination,
- // message, messageType }.
- var messageQueue = [];
-
- // String to distinguish this client from others sharing the same session.
- // This can occur when multiple browser windows or tabs using amq.js simultaneously.
- // All windows share the same JESSIONID, but need to consume messages independently.
- var clientId = null;
-
- /**
- * Iterate over the returned XML and for each message in the response,
- * invoke the handler with the matching id.
- */
- var messageHandler = function(data) {
- var response = data.getElementsByTagName("ajax-response");
- if (response != null && response.length == 1) {
- connectStatusHandler(true);
- var responses = response[0].childNodes; // <response>
- for (var i = 0; i < responses.length; i++) {
- var responseElement = responses[i];
-
- // only process nodes of type element.....
- if (responseElement.nodeType != 1) continue;
-
- var id = responseElement.getAttribute('id');
-
- var handler = messageHandlers[id];
-
- if (logging && handler == null) {
- adapter.log('No handler found to match message with id = ' + id);
- continue;
- }
-
- // Loop thru and handle each <message>
- for (var j = 0; j < responseElement.childNodes.length; j++) {
- handler(responseElement.childNodes[j]);
- }
- }
- }
- };
-
- var errorHandler = function(xhr, status, ex) {
- connectStatusHandler(false);
- if (logging) adapter.log('Error occurred in ajax call. HTTP result: ' +
- xhr.status + ', status: ' + status);
- }
-
- var pollErrorHandler = function(xhr, status, ex) {
- connectStatusHandler(false);
- if (status === 'error' && xhr.status === 0) {
- if (logging) adapter.log('Server connection dropped.');
- setTimeout(function() { sendPoll(); }, pollErrorDelay);
- return;
- }
- if (logging) adapter.log('Error occurred in poll. HTTP result: ' +
- xhr.status + ', status: ' + status);
- setTimeout(function() { sendPoll(); }, pollErrorDelay);
- }
-
- var pollHandler = function(data) {
- try {
- messageHandler(data);
- } catch(e) {
- if (logging) adapter.log('Exception in the poll handler: ' + data, e);
- throw(e);
- } finally {
- setTimeout(sendPoll, pollDelay);
- }
- };
-
- var initHandler = function(data) {
- sessionInitialized = true;
- if(sessionInitializedCallback) {
- sessionInitializedCallback();
- }
- pollHandler(data);
- }
-
- var sendPoll = function() {
- // Workaround IE6 bug where it caches the response
- // Generate a unique query string with date and random
- var now = new Date();
- var timeoutArg = sessionInitialized ? timeout : 0.001;
- var data = 'timeout=' + timeoutArg * 1000
- + '&d=' + now.getTime()
- + '&r=' + Math.random();
- var successCallback = sessionInitialized ? pollHandler : initHandler;
-
- var options = { method: 'get',
- data: addClientId( data ),
- success: successCallback,
- error: pollErrorHandler};
- adapter.ajax(uri, options);
- };
-
- var sendJmsMessage = function(destination, message, type, headers) {
- var message = {
- destination: destination,
- message: message,
- messageType: type
- };
- // Add message to outbound queue
- if (batchInProgress) {
- messageQueue[messageQueue.length] = {message:message, headers:headers};
- } else {
- org.activemq.Amq.startBatch();
- adapter.ajax(uri, { method: 'post',
- data: addClientId( buildParams( [message] ) ),
- error: errorHandler,
- headers: headers,
- success: org.activemq.Amq.endBatch});
- }
- };
-
- var buildParams = function(msgs) {
- var s = [];
- for (var i = 0, c = msgs.length; i < c; i++) {
- if (i != 0) s[s.length] = '&';
- s[s.length] = ((i == 0) ? 'destination' : 'd' + i);
- s[s.length] = '=';
- s[s.length] = msgs[i].destination;
- s[s.length] = ((i == 0) ? '&message' : '&m' + i);
- s[s.length] = '=';
- s[s.length] = msgs[i].message;
- s[s.length] = ((i == 0) ? '&type' : '&t' + i);
- s[s.length] = '=';
- s[s.length] = msgs[i].messageType;
- }
- return s.join('');
- }
-
- // add clientId to data if it exists, before passing data to ajax connection adapter.
- var addClientId = function( data ) {
- var output = data || '';
- if( clientId ) {
- if( output.length > 0 ) {
- output += '&';
- }
- output += 'clientId='+clientId;
- }
- return output;
- }
-
- return {
- // optional clientId can be supplied to allow multiple clients (browser windows) within the same session.
- init : function(options) {
- connectStatusHandler = options.connectStatusHandler || function(connected){};
- uri = options.uri || '/amq';
- pollDelay = typeof options.pollDelay == 'number' ? options.pollDelay : 0;
- timeout = typeof options.timeout == 'number' ? options.timeout : 25;
- logging = options.logging;
- sessionInitializedCallback = options.sessionInitializedCallback
- clientId = options.clientId;
- adapter.init(options);
- sendPoll();
-
- },
-
- startBatch : function() {
- batchInProgress = true;
- },
-
- endBatch : function() {
- if (messageQueue.length > 0) {
- var messagesToSend = [];
- var messagesToQueue = [];
- var outgoingHeaders = null;
-
- // we need to ensure that messages which set headers are sent by themselves.
- // if 2 'listen' messages were sent together, and a 'selector' header were added to one of them,
- // AMQ would add the selector to both 'listen' commands.
- for(i=0;i<messageQueue.length;i++) {
- // a message with headers should always be sent by itself. if other messages have been added, send this one later.
- if ( messageQueue[ i ].headers && messagesToSend.length == 0 ) {
- messagesToSend[ messagesToSend.length ] = messageQueue[ i ].message;
- outgoingHeaders = messageQueue[ i ].headers;
- } else if ( ! messageQueue[ i ].headers && ! outgoingHeaders ) {
- messagesToSend[ messagesToSend.length ] = messageQueue[ i ].message;
- } else {
- messagesToQueue[ messagesToQueue.length ] = messageQueue[ i ];
- }
- }
- var body = buildParams(messagesToSend);
- messageQueue = messagesToQueue;
- org.activemq.Amq.startBatch();
- adapter.ajax(uri, {
- method: 'post',
- headers: outgoingHeaders,
- data: addClientId( body ),
- success: org.activemq.Amq.endBatch,
- error: errorHandler});
- } else {
- batchInProgress = false;
- }
- },
-
- // Send a JMS message to a destination (eg topic://MY.TOPIC). Message
- // should be xml or encoded xml content.
- sendMessage : function(destination, message) {
- sendJmsMessage(destination, message, 'send');
- },
-
- // Listen on a channel or topic.
- // handler must be a function taking a message argument
- //
- // Supported options:
- // selector: If supplied, it should be a SQL92 string like "property-name='value'"
- // http://activemq.apache.org/selectors.html
- //
- // Example: addListener( 'handler', 'topic://test-topic', function(msg) { return msg; }, { selector: "property-name='property-value'" } )
- addListener : function(id, destination, handler, options) {
- messageHandlers[id] = handler;
- var headers = options && options.selector ? {selector:options.selector} : null;
- sendJmsMessage(destination, id, 'listen', headers);
- },
-
- // remove Listener from channel or topic.
- removeListener : function(id, destination) {
- messageHandlers[id] = null;
- sendJmsMessage(destination, id, 'unlisten');
- },
-
- // for unit testing
- getMessageQueue: function() {
- return messageQueue;
- },
- testPollHandler: function( data ) {
- return pollHandler( data );
- }
- };
-}();
+/**
+ *
+ * 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.
+ */
+
+// AMQ Ajax handler
+// This class provides the main API for using the Ajax features of AMQ. It
+// allows JMS messages to be sent and received from javascript when used
+// with the org.apache.activemq.web.MessageListenerServlet.
+//
+// This version of the file provides an adapter interface for the jquery library
+// and a namespace for the Javascript file, private/public variables and
+// methods, and other scripting niceties. -- jim cook 2007/08/28
+
+var org = org || {};
+org.activemq = org.activemq || {};
+
+org.activemq.Amq = function() {
+ var connectStatusHandler;
+
+ // Just a shortcut to eliminate some redundant typing.
+ var adapter = org.activemq.AmqAdapter;
+
+ if (typeof adapter == 'undefined') {
+ throw 'An org.activemq.AmqAdapter must be declared before the amq.js script file.'
+ }
+
+ // The URI of the AjaxServlet.
+ var uri;
+
+ // The number of seconds that the long-polling socket will stay connected.
+ // Best to keep this to a value less than one minute.
+ var timeout;
+
+ // A session should not be considered initialized until the JSESSIONID is returned
+ // from the initial GET request. Otherwise subscription POSTS may register the
+ // subscription with the wrong session.
+ var sessionInitialized = false;
+
+ // This callback will be called after the first GET request returns.
+ var sessionInitializedCallback;
+
+ // Poll delay. if set to positive integer, this is the time to wait in ms
+ // before sending the next poll after the last completes.
+ var pollDelay;
+
+ // Inidicates whether logging is active or not. Not by default.
+ var logging = false;
+
+ // 5 second delay if an error occurs during poll. This could be due to
+ // server capacity problems or a timeout condition.
+ var pollErrorDelay = 5000;
+
+ // Map of handlers that will respond to message receipts. The id used during
+ // addListener(id, destination, handler) is used to key the callback
+ // handler.
+ var messageHandlers = {};
+
+ // Indicates whether an AJAX post call is in progress.
+ var batchInProgress = false;
+
+ // A collection of pending messages that accumulate when an AJAX call is in
+ // progress. These messages will be delivered as soon as the current call
+ // completes. The array contains objects in the format { destination,
+ // message, messageType }.
+ var messageQueue = [];
+
+ // String to distinguish this client from others sharing the same session.
+ // This can occur when multiple browser windows or tabs using amq.js simultaneously.
+ // All windows share the same JESSIONID, but need to consume messages independently.
+ var clientId = null;
+
+ /**
+ * Iterate over the returned XML and for each message in the response,
+ * invoke the handler with the matching id.
+ */
+ var messageHandler = function(data) {
+ var response = data.getElementsByTagName("ajax-response");
+ if (response != null && response.length == 1) {
+ connectStatusHandler(true);
+ var responses = response[0].childNodes; // <response>
+ for (var i = 0; i < responses.length; i++) {
+ var responseElement = responses[i];
+
+ // only process nodes of type element.....
+ if (responseElement.nodeType != 1) continue;
+
+ var id = responseElement.getAttribute('id');
+
+ var handler = messageHandlers[id];
+
+ if (logging && handler == null) {
+ adapter.log('No handler found to match message with id = ' + id);
+ continue;
+ }
+
+ // Loop thru and handle each <message>
+ for (var j = 0; j < responseElement.childNodes.length; j++) {
+ handler(responseElement.childNodes[j]);
+ }
+ }
+ }
+ };
+
+ var errorHandler = function(xhr, status, ex) {
+ connectStatusHandler(false);
+ if (logging) adapter.log('Error occurred in ajax call. HTTP result: ' +
+ xhr.status + ', status: ' + status);
+ }
+
+ var pollErrorHandler = function(xhr, status, ex) {
+ connectStatusHandler(false);
+ if (status === 'error' && xhr.status === 0) {
+ if (logging) adapter.log('Server connection dropped.');
+ setTimeout(function() { sendPoll(); }, pollErrorDelay);
+ return;
+ }
+ if (logging) adapter.log('Error occurred in poll. HTTP result: ' +
+ xhr.status + ', status: ' + status);
+ setTimeout(function() { sendPoll(); }, pollErrorDelay);
+ }
+
+ var pollHandler = function(data) {
+ try {
+ messageHandler(data);
+ } catch(e) {
+ if (logging) adapter.log('Exception in the poll handler: ' + data, e);
+ throw(e);
+ } finally {
+ setTimeout(sendPoll, pollDelay);
+ }
+ };
+
+ var initHandler = function(data) {
+ sessionInitialized = true;
+ if(sessionInitializedCallback) {
+ sessionInitializedCallback();
+ }
+ pollHandler(data);
+ }
+
+ var sendPoll = function() {
+ // Workaround IE6 bug where it caches the response
+ // Generate a unique query string with date and random
+ var now = new Date();
+ var timeoutArg = sessionInitialized ? timeout : 0.001;
+ var data = 'timeout=' + timeoutArg * 1000
+ + '&d=' + now.getTime()
+ + '&r=' + Math.random();
+ var successCallback = sessionInitialized ? pollHandler : initHandler;
+
+ var options = { method: 'get',
+ data: addClientId( data ),
+ success: successCallback,
+ error: pollErrorHandler};
+ adapter.ajax(uri, options);
+ };
+
+ var sendJmsMessage = function(destination, message, type, headers) {
+ var message = {
+ destination: destination,
+ message: message,
+ messageType: type
+ };
+ // Add message to outbound queue
+ if (batchInProgress) {
+ messageQueue[messageQueue.length] = {message:message, headers:headers};
+ } else {
+ org.activemq.Amq.startBatch();
+ adapter.ajax(uri, { method: 'post',
+ data: addClientId( buildParams( [message] ) ),
+ error: errorHandler,
+ headers: headers,
+ success: org.activemq.Amq.endBatch});
+ }
+ };
+
+ var buildParams = function(msgs) {
+ var s = [];
+ for (var i = 0, c = msgs.length; i < c; i++) {
+ if (i != 0) s[s.length] = '&';
+ s[s.length] = ((i == 0) ? 'destination' : 'd' + i);
+ s[s.length] = '=';
+ s[s.length] = msgs[i].destination;
+ s[s.length] = ((i == 0) ? '&message' : '&m' + i);
+ s[s.length] = '=';
+ s[s.length] = msgs[i].message;
+ s[s.length] = ((i == 0) ? '&type' : '&t' + i);
+ s[s.length] = '=';
+ s[s.length] = msgs[i].messageType;
+ }
+ return s.join('');
+ }
+
+ // add clientId to data if it exists, before passing data to ajax connection adapter.
+ var addClientId = function( data ) {
+ var output = data || '';
+ if( clientId ) {
+ if( output.length > 0 ) {
+ output += '&';
+ }
+ output += 'clientId='+clientId;
+ }
+ return output;
+ }
+
+ return {
+ // optional clientId can be supplied to allow multiple clients (browser windows) within the same session.
+ init : function(options) {
+ connectStatusHandler = options.connectStatusHandler || function(connected){};
+ uri = options.uri || '/amq';
+ pollDelay = typeof options.pollDelay == 'number' ? options.pollDelay : 0;
+ timeout = typeof options.timeout == 'number' ? options.timeout : 25;
+ logging = options.logging;
+ sessionInitializedCallback = options.sessionInitializedCallback
+ clientId = options.clientId;
+ adapter.init(options);
+ sendPoll();
+
+ },
+
+ startBatch : function() {
+ batchInProgress = true;
+ },
+
+ endBatch : function() {
+ if (messageQueue.length > 0) {
+ var messagesToSend = [];
+ var messagesToQueue = [];
+ var outgoingHeaders = null;
+
+ // we need to ensure that messages which set headers are sent by themselves.
+ // if 2 'listen' messages were sent together, and a 'selector' header were added to one of them,
+ // AMQ would add the selector to both 'listen' commands.
+ for(i=0;i<messageQueue.length;i++) {
+ // a message with headers should always be sent by itself. if other messages have been added, send this one later.
+ if ( messageQueue[ i ].headers && messagesToSend.length == 0 ) {
+ messagesToSend[ messagesToSend.length ] = messageQueue[ i ].message;
+ outgoingHeaders = messageQueue[ i ].headers;
+ } else if ( ! messageQueue[ i ].headers && ! outgoingHeaders ) {
+ messagesToSend[ messagesToSend.length ] = messageQueue[ i ].message;
+ } else {
+ messagesToQueue[ messagesToQueue.length ] = messageQueue[ i ];
+ }
+ }
+ var body = buildParams(messagesToSend);
+ messageQueue = messagesToQueue;
+ org.activemq.Amq.startBatch();
+ adapter.ajax(uri, {
+ method: 'post',
+ headers: outgoingHeaders,
+ data: addClientId( body ),
+ success: org.activemq.Amq.endBatch,
+ error: errorHandler});
+ } else {
+ batchInProgress = false;
+ }
+ },
+
+ // Send a JMS message to a destination (eg topic://MY.TOPIC). Message
+ // should be xml or encoded xml content.
+ sendMessage : function(destination, message) {
+ sendJmsMessage(destination, message, 'send');
+ },
+
+ // Listen on a channel or topic.
+ // handler must be a function taking a message argument
+ //
+ // Supported options:
+ // selector: If supplied, it should be a SQL92 string like "property-name='value'"
+ // http://activemq.apache.org/selectors.html
+ //
+ // Example: addListener( 'handler', 'topic://test-topic', function(msg) { return msg; }, { selector: "property-name='property-value'" } )
+ addListener : function(id, destination, handler, options) {
+ messageHandlers[id] = handler;
+ var headers = options && options.selector ? {selector:options.selector} : null;
+ sendJmsMessage(destination, id, 'listen', headers);
+ },
+
+ // remove Listener from channel or topic.
+ removeListener : function(id, destination) {
+ messageHandlers[id] = null;
+ sendJmsMessage(destination, id, 'unlisten');
+ },
+
+ // for unit testing
+ getMessageQueue: function() {
+ return messageQueue;
+ },
+ testPollHandler: function( data ) {
+ return pollHandler( data );
+ }
+ };
+}();
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-web-demo/src/main/webapp/js/amq_dojo_adapter.js
----------------------------------------------------------------------
diff --git a/activemq-web-demo/src/main/webapp/js/amq_dojo_adapter.js b/activemq-web-demo/src/main/webapp/js/amq_dojo_adapter.js
index 5197e0d..04a887c 100644
--- a/activemq-web-demo/src/main/webapp/js/amq_dojo_adapter.js
+++ b/activemq-web-demo/src/main/webapp/js/amq_dojo_adapter.js
@@ -1,84 +1,84 @@
-/**
- *
- * 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.
- */
-
-// AMQ Ajax Adapter for Dojo
-// This class provides an adapter interface for the Dojo library to perform
-// some of the library-dependent tasks...namely logging and ajax.
-
-var org = org || {};
-org.activemq = org.activemq || {};
-
-org.activemq.AmqAdapter = {
-
- init: function(options) {
- },
-
-/**
- * Implement this method to make an AJAX call to the AjaxServlet. An
- * options object will accompany this class and will contain the properties
- * that describe the details of the AJAX call. The options object will
- * have the following properties:
- *
- * - method: 'get' or 'post'
- * - data: query data to accompany the post or get.
- * - success: A callback function that is invoked upon successful
- * completion of the AJAX call. The parameter is:
- * - data: The result of the AJAX call. In the case of XML
- * data should resolve to a Document element.
- * - error: A callback when some type of error occurs. The callback
- * function's parameters should be:
- * - xhr: The XmlHttpRequest object.
- * - status: A text string of the status.
- * - ex: The exception that caused the error.
- * - headers: An object containing additional headers for the ajax request.
- */
- ajax: function(uri, options) {
- if (options.method == 'post') {
- dojo.xhrPost({
- url: uri,
- handleAs: "xml",
- postData: options.data,
- headers: options.headers,
- load : options.success ? options.success : function() {},
- error: options.error ? function(ex, ioargs) {
- options.error(ioargs.xhr,ioargs.xhr.status, ex);
- } : function() {}
- });
- } else {
- if (options.data)
- {
- uri += "?";
- uri += options.data;
- }
- dojo.xhrGet({
- url: uri,
- handleAs: "xml",
- headers: options.headers,
- load : options.success ? options.success : function() {},
- error: options.error ? function(ex, ioargs) {
- options.error(ioargs.xhr,ioargs.xhr.status, ex);
- } : function() {}
- });
- }
- },
-
- log: function(message, exception) {
- if (typeof console != 'undefined' && console.log) console.log(message);
- }
-
-};
+/**
+ *
+ * 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.
+ */
+
+// AMQ Ajax Adapter for Dojo
+// This class provides an adapter interface for the Dojo library to perform
+// some of the library-dependent tasks...namely logging and ajax.
+
+var org = org || {};
+org.activemq = org.activemq || {};
+
+org.activemq.AmqAdapter = {
+
+ init: function(options) {
+ },
+
+/**
+ * Implement this method to make an AJAX call to the AjaxServlet. An
+ * options object will accompany this class and will contain the properties
+ * that describe the details of the AJAX call. The options object will
+ * have the following properties:
+ *
+ * - method: 'get' or 'post'
+ * - data: query data to accompany the post or get.
+ * - success: A callback function that is invoked upon successful
+ * completion of the AJAX call. The parameter is:
+ * - data: The result of the AJAX call. In the case of XML
+ * data should resolve to a Document element.
+ * - error: A callback when some type of error occurs. The callback
+ * function's parameters should be:
+ * - xhr: The XmlHttpRequest object.
+ * - status: A text string of the status.
+ * - ex: The exception that caused the error.
+ * - headers: An object containing additional headers for the ajax request.
+ */
+ ajax: function(uri, options) {
+ if (options.method == 'post') {
+ dojo.xhrPost({
+ url: uri,
+ handleAs: "xml",
+ postData: options.data,
+ headers: options.headers,
+ load : options.success ? options.success : function() {},
+ error: options.error ? function(ex, ioargs) {
+ options.error(ioargs.xhr,ioargs.xhr.status, ex);
+ } : function() {}
+ });
+ } else {
+ if (options.data)
+ {
+ uri += "?";
+ uri += options.data;
+ }
+ dojo.xhrGet({
+ url: uri,
+ handleAs: "xml",
+ headers: options.headers,
+ load : options.success ? options.success : function() {},
+ error: options.error ? function(ex, ioargs) {
+ options.error(ioargs.xhr,ioargs.xhr.status, ex);
+ } : function() {}
+ });
+ }
+ },
+
+ log: function(message, exception) {
+ if (typeof console != 'undefined' && console.log) console.log(message);
+ }
+
+};
http://git-wip-us.apache.org/repos/asf/activemq/blob/3f32507f/activemq-web-demo/src/main/webapp/js/amq_jquery_adapter.js
----------------------------------------------------------------------
diff --git a/activemq-web-demo/src/main/webapp/js/amq_jquery_adapter.js b/activemq-web-demo/src/main/webapp/js/amq_jquery_adapter.js
index d73fc0e..6c6eca6 100755
--- a/activemq-web-demo/src/main/webapp/js/amq_jquery_adapter.js
+++ b/activemq-web-demo/src/main/webapp/js/amq_jquery_adapter.js
@@ -1,88 +1,88 @@
-/**
- *
- * 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.
- */
-
-// AMQ Ajax Adapter for jQuery
-// This class provides an adapter interface for the jquery library to perform
-// some of the library-dependent tasks...namely logging and ajax.
-
-var org = org || {};
-org.activemq = org.activemq || {};
-
-org.activemq.AmqAdapter = {
-
- init: function(options) {
- },
-
- /**
- * Implement this method to make an AJAX call to the AjaxServlet. An
- * options object will accompany this class and will contain the properties
- * that describe the details of the AJAX call. The options object will
- * have the following properties:
- *
- * - method: 'get' or 'post'
- * - data: query data to accompany the post or get.
- * - success: A callback function that is invoked upon successful
- * completion of the AJAX call. The parameter is:
- * - data: The result of the AJAX call. In the case of XML
- * data should resolve to a Document element.
- * - error: A callback when some type of error occurs. The callback
- * function's parameters should be:
- * - xhr: The XmlHttpRequest object.
- * - status: A text string of the status.
- * - ex: The exception that caused the error.
- * - headers: An object containing additional headers for the ajax request.
- */
- ajax: function(uri, options) {
- request = {
- url: uri,
- data: options.data,
- success: options.success || function(){},
- error: options.error || function(){}
- }
- var headers = {};
- if( options.headers ) {
- headers = options.headers;
- }
-
- if (options.method == 'post') {
- request.type = 'POST';
- /* Force "Connection: close" for Mozilla browsers to work around
- * a bug where XMLHttpReqeuest sends an incorrect Content-length
- * header. See Mozilla Bugzilla #246651.
- */
- headers[ 'Connection' ] = 'close';
- } else {
- request.type = 'GET';
- request.dataType = 'xml';
- }
-
- if( headers ) {
- request.beforeSend = function(xhr) {
- for( h in headers ) {
- xhr.setRequestHeader( h, headers[ h ] );
- }
- }
- }
-
- jQuery.ajax( request );
- },
-
- log: function(message, exception) {
- if (typeof console != 'undefined' && console.log) console.log(message);
- }
-};
+/**
+ *
+ * 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.
+ */
+
+// AMQ Ajax Adapter for jQuery
+// This class provides an adapter interface for the jquery library to perform
+// some of the library-dependent tasks...namely logging and ajax.
+
+var org = org || {};
+org.activemq = org.activemq || {};
+
+org.activemq.AmqAdapter = {
+
+ init: function(options) {
+ },
+
+ /**
+ * Implement this method to make an AJAX call to the AjaxServlet. An
+ * options object will accompany this class and will contain the properties
+ * that describe the details of the AJAX call. The options object will
+ * have the following properties:
+ *
+ * - method: 'get' or 'post'
+ * - data: query data to accompany the post or get.
+ * - success: A callback function that is invoked upon successful
+ * completion of the AJAX call. The parameter is:
+ * - data: The result of the AJAX call. In the case of XML
+ * data should resolve to a Document element.
+ * - error: A callback when some type of error occurs. The callback
+ * function's parameters should be:
+ * - xhr: The XmlHttpRequest object.
+ * - status: A text string of the status.
+ * - ex: The exception that caused the error.
+ * - headers: An object containing additional headers for the ajax request.
+ */
+ ajax: function(uri, options) {
+ request = {
+ url: uri,
+ data: options.data,
+ success: options.success || function(){},
+ error: options.error || function(){}
+ }
+ var headers = {};
+ if( options.headers ) {
+ headers = options.headers;
+ }
+
+ if (options.method == 'post') {
+ request.type = 'POST';
+ /* Force "Connection: close" for Mozilla browsers to work around
+ * a bug where XMLHttpReqeuest sends an incorrect Content-length
+ * header. See Mozilla Bugzilla #246651.
+ */
+ headers[ 'Connection' ] = 'close';
+ } else {
+ request.type = 'GET';
+ request.dataType = 'xml';
+ }
+
+ if( headers ) {
+ request.beforeSend = function(xhr) {
+ for( h in headers ) {
+ xhr.setRequestHeader( h, headers[ h ] );
+ }
+ }
+ }
+
+ jQuery.ajax( request );
+ },
+
+ log: function(message, exception) {
+ if (typeof console != 'undefined' && console.log) console.log(message);
+ }
+};