summaryrefslogtreecommitdiff
path: root/java/client/src
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2010-06-25 13:51:32 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2010-06-25 13:51:32 +0000
commit0b4c056ec423a260d18b8c6c8120bd8d72fa1396 (patch)
tree85abdca2725f78bff720cf310f6b059cdc186cab /java/client/src
parente68d359866d03ccd574ce715be50a68c57acecf0 (diff)
downloadqpid-python-0b4c056ec423a260d18b8c6c8120bd8d72fa1396.tar.gz
QPID-2696
Modified the PropertiesFileInitialContextFactory to allow the new addressing strings to be specified in the jndi properties file. Downgraded some "info" log messages in AMQDestination to "debug". Added a test cases to cover the issue reported in the JIRA. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@957942 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java6
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQDestination.java42
-rw-r--r--java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java20
3 files changed, 45 insertions, 23 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java b/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
index a5c6f5f967..b6e433f532 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQAnyDestination.java
@@ -23,6 +23,7 @@ package org.apache.qpid.client;
import java.net.URISyntaxException;
import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.messaging.Address;
import org.apache.qpid.url.BindingURL;
/**
@@ -46,6 +47,11 @@ public class AMQAnyDestination extends AMQDestination
super(str);
}
+ public AMQAnyDestination(Address addr) throws Exception
+ {
+ super(addr);
+ }
+
public AMQAnyDestination(AMQShortString exchangeName,AMQShortString exchangeClass,
AMQShortString routingKey,boolean isExclusive,
boolean isAutoDelete, AMQShortString queueName,
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
index e1f29087a4..55812f8e01 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQDestination.java
@@ -147,6 +147,8 @@ public abstract class AMQDestination implements Destination, Referenceable
defaultDestSyntax = DestSyntax.getSyntaxType(
System.getProperty(ClientProperties.DEST_SYNTAX,
DestSyntax.ADDR.toString()));
+
+
}
protected AMQDestination(Address address) throws Exception
@@ -154,14 +156,18 @@ public abstract class AMQDestination implements Destination, Referenceable
this._address = address;
getInfoFromAddress();
_destSyntax = DestSyntax.ADDR;
- _logger.info("Based on " + address + " the selected destination syntax is " + _destSyntax);
+ _logger.debug("Based on " + address + " the selected destination syntax is " + _destSyntax);
}
protected AMQDestination(String str) throws URISyntaxException
{
if (str.startsWith("BURL:") ||
(!str.startsWith("ADDR:") && defaultDestSyntax == DestSyntax.BURL))
- {
+ {
+ if (str.startsWith("BURL:"))
+ {
+ str = str.substring(5,str.length());
+ }
_destSyntax = DestSyntax.BURL;
getInfoFromBindingURL(new AMQBindingURL(str));
}
@@ -180,7 +186,7 @@ public abstract class AMQDestination implements Destination, Referenceable
throw ex;
}
}
- _logger.info("Based on " + str + " the selected destination syntax is " + _destSyntax);
+ _logger.debug("Based on " + str + " the selected destination syntax is " + _destSyntax);
}
//retained for legacy support
@@ -188,7 +194,7 @@ public abstract class AMQDestination implements Destination, Referenceable
{
getInfoFromBindingURL(binding);
_destSyntax = DestSyntax.BURL;
- _logger.info("Based on " + binding + " the selected destination syntax is " + _destSyntax);
+ _logger.debug("Based on " + binding + " the selected destination syntax is " + _destSyntax);
}
protected void getInfoFromBindingURL(BindingURL binding)
@@ -270,7 +276,11 @@ public abstract class AMQDestination implements Destination, Referenceable
_bindingKeys = bindingKeys == null || bindingKeys.length == 0 ? new AMQShortString[0] : bindingKeys;
_destSyntax = DestSyntax.BURL;
_browseOnly = browseOnly;
- _logger.info("Based on " + toString() + " the selected destination syntax is " + _destSyntax);
+
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("Based on " + toString() + " the selected destination syntax is " + _destSyntax);
+ }
}
public DestSyntax getDestSyntax()
@@ -642,6 +652,24 @@ public abstract class AMQDestination implements Destination, Referenceable
}
}
+ public static Destination createDestination(String str) throws Exception
+ {
+ if (str.startsWith("BURL:") ||
+ (!str.startsWith("ADDR:") && defaultDestSyntax == DestSyntax.BURL))
+ {
+ if (str.startsWith("BURL:"))
+ {
+ str = str.substring(5,str.length());
+ }
+ return createDestination(new AMQBindingURL(str));
+ }
+ else
+ {
+ Address address = createAddressFromString(str);
+ return new AMQAnyDestination(address);
+ }
+ }
+
// ----- new address syntax -----------
public static class Binding
@@ -764,11 +792,11 @@ public abstract class AMQDestination implements Destination, Referenceable
this._routingKey = rk;
}
- private Address createAddressFromString(String str)
+ private static Address createAddressFromString(String str)
{
if (str.startsWith("ADDR:"))
{
- str = str.substring(str.indexOf(':')+1,str.length());
+ str = str.substring(5,str.length());
}
return Address.parse(str);
}
diff --git a/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java b/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
index 8b702c008f..f0f9a9840c 100644
--- a/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
+++ b/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
@@ -233,27 +233,15 @@ public class PropertiesFileInitialContextFactory implements InitialContextFactor
/**
* Factory method to create new Destination instances from an AMQP BindingURL
*/
- protected Destination createDestination(String bindingURL)
+ protected Destination createDestination(String str)
{
- AMQBindingURL binding;
try
{
- binding = new AMQBindingURL(bindingURL);
+ return AMQDestination.createDestination(str);
}
- catch (URISyntaxException urlse)
+ catch (Exception e)
{
- _logger.warn("Unable to create destination:" + urlse, urlse);
-
- return null;
- }
-
- try
- {
- return AMQDestination.createDestination(binding);
- }
- catch (IllegalArgumentException iaw)
- {
- _logger.warn("Binding: '" + binding + "' not supported");
+ _logger.warn("Unable to create destination:" + e, e);
return null;
}