summaryrefslogtreecommitdiff
path: root/qpid/java/client/src/main
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2012-05-28 12:20:35 +0000
committerRobert Gemmell <robbie@apache.org>2012-05-28 12:20:35 +0000
commitb3bcd521a46ca9e351e295fc8685712291bd86dd (patch)
treea23875ade5aca1aae8c87e7ac10e42eb0bdf1fb3 /qpid/java/client/src/main
parent175c11c7b8056c144b6a9dd8b132cccba7ca442d (diff)
downloadqpid-python-b3bcd521a46ca9e351e295fc8685712291bd86dd.tar.gz
QPID-4023: restore connection URL setter, add check that URL details have been set before calling connect(), add unit+sys test to verify operation
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1343220 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/src/main')
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
index cc91746d98..8bc815d98e 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
@@ -55,12 +55,13 @@ public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionF
ObjectFactory, Referenceable, XATopicConnectionFactory,
XAQueueConnectionFactory, XAConnectionFactory
{
- private final ConnectionURL _connectionDetails;
+ protected static final String NO_URL_CONFIGURED = "The connection factory wasn't created with a proper URL, the connection details are empty";
+
+ private ConnectionURL _connectionDetails;
// The default constructor is necessary to allow AMQConnectionFactory to be deserialised from JNDI
public AMQConnectionFactory()
{
- _connectionDetails = null;
}
public AMQConnectionFactory(final String url) throws URLSyntaxException
@@ -106,6 +107,11 @@ public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionF
public Connection createConnection() throws JMSException
{
+ if(_connectionDetails == null)
+ {
+ throw new JMSException(NO_URL_CONFIGURED);
+ }
+
try
{
if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
@@ -158,7 +164,7 @@ public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionF
}
else
{
- throw new JMSException("The connection factory wasn't created with a proper URL, the connection details are empty");
+ throw new JMSException(NO_URL_CONFIGURED);
}
}
@@ -193,6 +199,12 @@ public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionF
return _connectionDetails.toString();
}
+ //setter necessary to use instances created with the default constructor (which we can't remove)
+ public final void setConnectionURLString(String url) throws URLSyntaxException
+ {
+ _connectionDetails = new AMQConnectionURL(url);
+ }
+
/**
* JNDI interface to create objects from References.
*
@@ -332,7 +344,7 @@ public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionF
}
else
{
- throw new JMSException("The connection factory wasn't created with a proper URL, the connection details are empty");
+ throw new JMSException(NO_URL_CONFIGURED);
}
}