diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2009-10-25 22:58:57 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2009-10-25 22:58:57 +0000 |
| commit | afcf8099695253651c73910a243fb29aa520b008 (patch) | |
| tree | e514bc51797181c567500a8ddbfc20ea9b89b908 /qpid/java/broker-plugins/src | |
| parent | f315ac548e346ded9ed1d081db4118e703c362b4 (diff) | |
| download | qpid-python-afcf8099695253651c73910a243fb29aa520b008.tar.gz | |
Merged from java-broker-0-10 branch
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@829675 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/src')
4 files changed, 87 insertions, 41 deletions
diff --git a/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchange.java b/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchange.java index aa64fab6cd..637997a947 100644 --- a/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchange.java +++ b/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchange.java @@ -20,10 +20,8 @@ */ package org.apache.qpid.extras.exchanges.diagnostic; -import java.util.List; -import java.util.Map; import java.util.ArrayList; -import java.util.Collection; +import java.util.Map; import javax.management.JMException; import javax.management.openmbean.OpenDataException; @@ -34,27 +32,31 @@ import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.BasicContentHeaderProperties; import org.apache.qpid.framing.FieldTable; import org.apache.qpid.server.exchange.AbstractExchange; -import org.apache.qpid.server.queue.IncomingMessage; import org.apache.qpid.server.queue.AMQQueue; +import org.apache.qpid.server.message.InboundMessage; import org.apache.qpid.junit.extensions.util.SizeOf; import org.apache.qpid.management.common.mbeans.annotations.MBeanConstructor; import org.apache.qpid.management.common.mbeans.annotations.MBeanDescription; +import org.apache.log4j.Logger; /** - * + * * This is a special diagnostic exchange type which doesn't actually do anything * with messages. When it receives a message, it writes information about the * current memory usage to the "memory" property of the message and places it on the - * diagnosticqueue for retrieval - * + * diagnosticqueue for retrieval + * * @author Aidan Skinner - * + * */ public class DiagnosticExchange extends AbstractExchange { - + + private static final Logger _logger = Logger.getLogger(DiagnosticExchange.class); + + public static final AMQShortString DIAGNOSTIC_EXCHANGE_CLASS = new AMQShortString("x-diagnostic"); public static final AMQShortString DIAGNOSTIC_EXCHANGE_NAME = new AMQShortString("diagnostic"); @@ -72,7 +74,7 @@ public class DiagnosticExchange extends AbstractExchange /** * Usual constructor. - * + * * @throws JMException */ @MBeanConstructor("Creates an MBean for AMQ Diagnostic exchange") @@ -85,7 +87,7 @@ public class DiagnosticExchange extends AbstractExchange /** * Returns nothing, there can be no tabular data for this... - * + * * @throws OpenDataException * @returns null * @todo ... or can there? Could this actually return all the @@ -99,7 +101,7 @@ public class DiagnosticExchange extends AbstractExchange /** * This exchange type doesn't support queues, so this method does * nothing. - * + * * @param queueName * the queue you'll fail to create * @param binding @@ -116,22 +118,20 @@ public class DiagnosticExchange extends AbstractExchange /** * Creates a new MBean instance - * + * * @return the newly created MBean * @throws AMQException * if something goes wrong */ - protected ExchangeMBean createMBean() throws AMQException + protected ExchangeMBean createMBean() throws JMException { - try - { - return new DiagnosticExchange.DiagnosticExchangeMBean(); - } - catch (JMException ex) - { - // _logger.error("Exception occured in creating the direct exchange mbean", ex); - throw new AMQException(null, "Exception occured in creating the direct exchange mbean", ex); - } + return new DiagnosticExchange.DiagnosticExchangeMBean(); + + } + + public Logger getLogger() + { + return _logger; } public AMQShortString getType() @@ -141,7 +141,7 @@ public class DiagnosticExchange extends AbstractExchange /** * Does nothing. - * + * * @param routingKey * pointless * @param queue @@ -156,9 +156,15 @@ public class DiagnosticExchange extends AbstractExchange // No op } + public void registerQueue(String routingKey, AMQQueue queue, Map<String, Object> args) throws AMQException + { + // No op + } + + /** * Does nothing. - * + * * @param routingKey * pointless * @param queue @@ -193,27 +199,29 @@ public class DiagnosticExchange extends AbstractExchange return false; } - public void route(IncomingMessage payload) throws AMQException + public ArrayList<AMQQueue> route(InboundMessage payload) { - + Long value = new Long(SizeOf.getUsedMemory()); AMQShortString key = new AMQShortString("memory"); - - FieldTable headers = ((BasicContentHeaderProperties)payload.getContentHeaderBody().properties).getHeaders(); + + //TODO shouldn't modify messages... perhaps put a new message on the queue? +/* FieldTable headers = ((BasicContentHeaderProperties)payload.getMessageHeader().properties).getHeaders(); headers.put(key, value); - ((BasicContentHeaderProperties)payload.getContentHeaderBody().properties).setHeaders(headers); + ((BasicContentHeaderProperties)payload.getMessageHeader().properties).setHeaders(headers);*/ AMQQueue q = getQueueRegistry().getQueue(new AMQShortString("diagnosticqueue")); ArrayList<AMQQueue> queues = new ArrayList<AMQQueue>(); queues.add(q); - payload.enqueue(queues); - + return queues; + } - + public boolean isBound(AMQShortString routingKey, FieldTable arguments, AMQQueue queue) { // TODO Auto-generated method stub return false; } + } diff --git a/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchangeType.java b/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchangeType.java index d96b4dc99e..b4d0d1aa0d 100644 --- a/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchangeType.java +++ b/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/DiagnosticExchangeType.java @@ -31,7 +31,7 @@ import org.apache.qpid.server.virtualhost.VirtualHost; */ public final class DiagnosticExchangeType implements ExchangeType<DiagnosticExchange> { - + public AMQShortString getName() { return DiagnosticExchange.DIAGNOSTIC_EXCHANGE_CLASS; diff --git a/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchange.java b/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchange.java index e43bd2ddc0..cb46b9c815 100644 --- a/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchange.java +++ b/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchange.java @@ -1,6 +1,6 @@ package org.apache.qpid.extras.exchanges.example; /* - * + * * 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 @@ -8,29 +8,31 @@ package org.apache.qpid.extras.exchanges.example; * 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. - * + * */ import java.util.List; import java.util.Map; +import java.util.ArrayList; import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.FieldTable; import org.apache.qpid.server.exchange.Exchange; -import org.apache.qpid.server.queue.IncomingMessage; +import org.apache.qpid.server.exchange.ExchangeReferrer; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.server.message.InboundMessage; public class TestExchange implements Exchange { @@ -63,6 +65,41 @@ public class TestExchange implements Exchange return false; } + public boolean isBound(String bindingKey, AMQQueue queue) + { + return false; + } + + public boolean isBound(String bindingKey) + { + return false; + } + + public Exchange getAlternateExchange() + { + return null; + } + + public void setAlternateExchange(Exchange exchange) + { + + } + + public void removeReference(ExchangeReferrer exchange) + { + + } + + public void addReference(ExchangeReferrer exchange) + { + + } + + public boolean hasReferrers() + { + return false; + } + public void initialise(VirtualHost host, AMQShortString name, boolean durable, boolean autoDelete) throws AMQException { @@ -102,8 +139,9 @@ public class TestExchange implements Exchange { } - public void route(IncomingMessage message) throws AMQException + public ArrayList<AMQQueue> route(InboundMessage message) { + return new ArrayList<AMQQueue>(); } public int getTicket() diff --git a/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchangeType.java b/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchangeType.java index 22833693ca..db02ca13ea 100644 --- a/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchangeType.java +++ b/qpid/java/broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/TestExchangeType.java @@ -40,7 +40,7 @@ public class TestExchangeType implements ExchangeType return null; } - public Exchange newInstance(VirtualHost host, AMQShortString name, boolean durable, + public Exchange newInstance(VirtualHost host, AMQShortString name, boolean durable, int token, boolean autoDelete) throws AMQException { |
