diff --git a/spring-amqp-core/src/main/java/org/springframework/amqp/core/AmqpAdmin.java b/spring-amqp-core/src/main/java/org/springframework/amqp/core/AmqpAdmin.java
index 60c34820..fd0748fd 100644
--- a/spring-amqp-core/src/main/java/org/springframework/amqp/core/AmqpAdmin.java
+++ b/spring-amqp-core/src/main/java/org/springframework/amqp/core/AmqpAdmin.java
@@ -1,17 +1,14 @@
/*
* Copyright 2002-2010 the original author or authors.
- *
- * Licensed 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.
+ *
+ * Licensed 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.springframework.amqp.core;
@@ -30,18 +27,17 @@ public interface AmqpAdmin {
void declareExchange(Exchange exchange);
/**
- * Delete an exchange. Look at implementation specific subclass for implementation specific behavior, for example
+ * Delete an exchange. Look at implementation specific subclass for implementation specific behavior, for example
* for RabbitMQ this will delete the exchange without regard for whether it is in use or not.
* @param exchangeName the name of the exchange
*/
void deleteExchange(String exchangeName);
-
// Queue Operations
-
+
/**
- * Declare a queue whose name is automatically named. It is created with
- * exclusive = true, autoDelete=true, and durable = false.
+ * Declare a queue whose name is automatically named. It is created with exclusive = true, autoDelete=true, and
+ * durable = false.
*/
Queue declareQueue();
@@ -52,29 +48,28 @@ public interface AmqpAdmin {
void declareQueue(Queue queue);
/**
- * Delete a queue, without regard for whether it is in use or has messages on it
+ * Delete a queue, without regard for whether it is in use or has messages on it
* @param queueName the name of the queue
*/
void deleteQueue(String queueName);
- // Note that nowait option is not readily exposed in Rabbit Java API but is for Rabbit .NET API.
+ // Note that nowait option is not readily exposed in Rabbit Java API but is for Rabbit .NET API.
/**
* Delete a queue
* @param queueName the name of the queue
* @param unused true if the queue should be deleted only if not in use
- * @param empty true if the queue should be deleted only if empty
+ * @param empty true if the queue should be deleted only if empty
*/
void deleteQueue(String queueName, boolean unused, boolean empty);
/**
- * Purges the contents of the given queue.
+ * Purges the contents of the given queue.
* @param queueName the name of the queue
* @param noWait true to not await completion of the purge
*/
void purgeQueue(String queueName, boolean noWait);
-
// Binding opertaions
/**
@@ -83,7 +78,11 @@ public interface AmqpAdmin {
*/
void declareBinding(Binding binding);
-
- //Note unbindQueue/removeBinding was not introduced until 0.9 of the specification.
+ /**
+ * Remove a binding of a queue to an exchange. Note unbindQueue/removeBinding was not introduced until 0.9 of the
+ * specification.
+ * @param binding a description of the binding to remove.
+ */
+ void removeBinding(Binding binding);
}
diff --git a/spring-amqp-core/src/test/resources/log4j.properties b/spring-amqp-core/src/test/resources/log4j.properties
index 6ddfb097..4bcc6e81 100644
--- a/spring-amqp-core/src/test/resources/log4j.properties
+++ b/spring-amqp-core/src/test/resources/log4j.properties
@@ -6,4 +6,5 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.category.org.springframework.amqp=DEBUG
log4j.category.org.springframework.beans.factory=INFO
+log4j.category.org.springframework.util.exec.Execute=TRACE
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionParameters.java b/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionParameters.java
index 6a98ede4..8032ad64 100644
--- a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionParameters.java
+++ b/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionParameters.java
@@ -17,6 +17,8 @@
package org.springframework.erlang.connection;
+import org.springframework.util.Assert;
+
import com.ericsson.otp.erlang.OtpPeer;
import com.ericsson.otp.erlang.OtpSelf;
@@ -32,7 +34,8 @@ public class ConnectionParameters {
private OtpPeer otpPeer;
public ConnectionParameters(OtpSelf otpSelf, OtpPeer otpPeer) {
- //TODO assert not null...
+ Assert.notNull(otpSelf, "OtpSelf must be non-null");
+ Assert.notNull(otpPeer, "OtpPeer must be non-null");
this.otpSelf = otpSelf;
this.otpPeer = otpPeer;
}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/connection/SimpleConnectionFactory.java b/spring-erlang/src/main/java/org/springframework/erlang/connection/SimpleConnectionFactory.java
index 5f8ead47..52c1fa51 100644
--- a/spring-erlang/src/main/java/org/springframework/erlang/connection/SimpleConnectionFactory.java
+++ b/spring-erlang/src/main/java/org/springframework/erlang/connection/SimpleConnectionFactory.java
@@ -1,17 +1,14 @@
/*
* Copyright 2002-2010 the original author or authors.
- *
- * Licensed 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.
+ *
+ * Licensed 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.springframework.erlang.connection;
@@ -31,47 +28,42 @@ import com.ericsson.otp.erlang.OtpPeer;
import com.ericsson.otp.erlang.OtpSelf;
/**
- * A simple implementation of {@link ConnectionFactory} that return a new connection
- * for each invocation of the createConnection method.
- *
- * Note that use of this ConnectionFactory with ErlangTemplate has unstable behavior when
- * invoked frequently and will be deprecated. See {@link SingleConnectionFactory} for an
- * alternative implementation.
- *
- *
- * Provides a more traditional API to creating a connection to a remote erlang node than
- * the JInterface API.
- *
- *
The following is taken from the JInterface javadocs that describe the valid
- * node names that can be used. These naming constraints apply to the string values
- * you pass into the node names in SimpleConnectionFactory's constructor.
*
- * About nodenames: Erlang nodenames consist of two components, an alivename and
- * a hostname separated by '@'. Additionally, there are two nodename formats:
- * short and long. Short names are of the form "alive@hostname", while long
- * names are of the form "alive@host.fully.qualified.domainname". Erlang has
- * special requirements regarding the use of the short and long formats, in
- * particular they cannot be mixed freely in a network of communicating nodes,
- * however Jinterface makes no distinction. See the Erlang documentation for
- * more information about nodenames.
+ * A simple implementation of {@link ConnectionFactory} that return a new connection for each invocation of the
+ * createConnection method.
+ *
+ *
+ * Note that use of this ConnectionFactory with ErlangTemplate has unstable behavior when invoked frequently and will be
+ * deprecated. See {@link SingleConnectionFactory} for an alternative implementation.
+ *
+ *
+ * Provides a more traditional API to creating a connection to a remote erlang node than the JInterface API.
+ *
+ *
+ * The following is taken from the JInterface javadocs that describe the valid node names that can be used. These naming
+ * constraints apply to the string values you pass into the node names in SimpleConnectionFactory's constructor.
+ *
+ *
+ * About nodenames: Erlang nodenames consist of two components, an alivename and a hostname separated by '@'.
+ * Additionally, there are two nodename formats: short and long. Short names are of the form "alive@hostname", while
+ * long names are of the form "alive@host.fully.qualified.domainname". Erlang has special requirements regarding the use
+ * of the short and long formats, in particular they cannot be mixed freely in a network of communicating nodes, however
+ * Jinterface makes no distinction. See the Erlang documentation for more information about nodenames.
*
*
*
- * The constructors for the AbstractNode classes will create names exactly as
- * you provide them as long as the name contains '@'. If the string you provide
- * contains no '@', it will be treated as an alivename and the name of the local
- * host will be appended, resulting in a shortname. Nodenames longer than 255
- * characters will be truncated without warning.
+ * The constructors for the AbstractNode classes will create names exactly as you provide them as long as the name
+ * contains '@'. If the string you provide contains no '@', it will be treated as an alivename and the name of the local
+ * host will be appended, resulting in a shortname. Nodenames longer than 255 characters will be truncated without
+ * warning.
*
*
*
- * Upon initialization, this class attempts to read the file .erlang.cookie in
- * the user's home directory, and uses the trimmed first line of the file as the
- * default cookie by those constructors lacking a cookie argument. If for any
- * reason the file cannot be found or read, the default cookie will be set to
- * the empty string (""). The location of a user's home directory is determined
- * using the system property "user.home", which may not be automatically set on
- * all platforms.
+ * Upon initialization, this class attempts to read the file .erlang.cookie in the user's home directory, and uses the
+ * trimmed first line of the file as the default cookie by those constructors lacking a cookie argument. If for any
+ * reason the file cannot be found or read, the default cookie will be set to the empty string (""). The location of a
+ * user's home directory is determined using the system property "user.home", which may not be automatically set on all
+ * platforms.
*
* @author Mark Pollack
* @author Mark Fisher
@@ -79,9 +71,9 @@ import com.ericsson.otp.erlang.OtpSelf;
public class SimpleConnectionFactory implements ConnectionFactory, InitializingBean {
protected final Log logger = LogFactory.getLog(getClass());
-
+
private boolean uniqueSelfNodeName = true;
-
+
private String selfNodeName;
private String cookie;
@@ -92,7 +84,6 @@ public class SimpleConnectionFactory implements ConnectionFactory, InitializingB
private OtpPeer otpPeer;
-
public SimpleConnectionFactory(String selfNodeName, String cookie, String peerNodeName) {
this(selfNodeName, peerNodeName);
this.cookie = cookie;
@@ -103,17 +94,15 @@ public class SimpleConnectionFactory implements ConnectionFactory, InitializingB
this.peerNodeName = peerNodeName;
}
-
public Connection createConnection() throws UnknownHostException, OtpAuthException, IOException {
try {
return new DefaultConnection(otpSelf.connect(otpPeer));
- }
- catch (IOException ex) {
- throw new OtpIOException("failed to connect from '" + this.selfNodeName
- + "' to peer node '" + this.peerNodeName + "'", ex);
+ } catch (IOException ex) {
+ throw new OtpIOException("failed to connect from '" + this.selfNodeName + "' to peer node '"
+ + this.peerNodeName + "'", ex);
}
}
-
+
public boolean isUniqueSelfNodeName() {
return uniqueSelfNodeName;
}
@@ -123,8 +112,9 @@ public class SimpleConnectionFactory implements ConnectionFactory, InitializingB
}
public void afterPropertiesSet() {
- Assert.isTrue(this.selfNodeName != null || this.peerNodeName != null,
- "'selfNodeName' or 'peerNodeName' is required");
+
+ Assert.isTrue(this.selfNodeName != null && this.peerNodeName != null,
+ "'selfNodeName' and 'peerNodeName' are required");
String selfNodeNameToUse = this.selfNodeName;
if (isUniqueSelfNodeName()) {
selfNodeNameToUse = this.selfNodeName + "-" + UUID.randomUUID().toString();
@@ -133,16 +123,14 @@ public class SimpleConnectionFactory implements ConnectionFactory, InitializingB
try {
if (this.cookie == null) {
this.otpSelf = new OtpSelf(selfNodeNameToUse.trim());
- }
- else {
+ } else {
this.otpSelf = new OtpSelf(selfNodeNameToUse.trim(), this.cookie);
}
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new OtpIOException(e);
}
this.otpPeer = new OtpPeer(this.peerNodeName.trim());
-
+
}
}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/core/Application.java b/spring-erlang/src/main/java/org/springframework/erlang/core/Application.java
index 21480961..8ceca86b 100644
--- a/spring-erlang/src/main/java/org/springframework/erlang/core/Application.java
+++ b/spring-erlang/src/main/java/org/springframework/erlang/core/Application.java
@@ -16,6 +16,8 @@
package org.springframework.erlang.core;
+import java.io.Serializable;
+
/**
* Describes an Erlang application. Only three fields are supported as that is the level
* of information that rabbitmq returns when performing a status request.
@@ -25,7 +27,8 @@ package org.springframework.erlang.core;
* @author Mark Pollack
*
*/
-public class Application {
+@SuppressWarnings("serial")
+public class Application implements Serializable {
private String description;
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/core/ErlangTemplate.java b/spring-erlang/src/main/java/org/springframework/erlang/core/ErlangTemplate.java
index 44525667..dd5242e1 100644
--- a/spring-erlang/src/main/java/org/springframework/erlang/core/ErlangTemplate.java
+++ b/spring-erlang/src/main/java/org/springframework/erlang/core/ErlangTemplate.java
@@ -124,9 +124,7 @@ public class ErlangTemplate extends ErlangAccessor implements ErlangOperations {
finally {
org.springframework.erlang.connection.ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory());
}
-
-
-
+ // TODO: physically close and reopen the connection if there is an exception
}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/core/Node.java b/spring-erlang/src/main/java/org/springframework/erlang/core/Node.java
index 21ef3203..9a6efe5f 100644
--- a/spring-erlang/src/main/java/org/springframework/erlang/core/Node.java
+++ b/spring-erlang/src/main/java/org/springframework/erlang/core/Node.java
@@ -19,13 +19,16 @@
*/
package org.springframework.erlang.core;
+import java.io.Serializable;
+
/**
* Simple description class for an Erlang node.
*
* @author Mark Pollack
*
*/
-public class Node {
+@SuppressWarnings("serial")
+public class Node implements Serializable {
private String name;
diff --git a/spring-erlang/src/main/java/org/springframework/util/exec/Execute.java b/spring-erlang/src/main/java/org/springframework/util/exec/Execute.java
index 0fa825d0..a29a67b0 100644
--- a/spring-erlang/src/main/java/org/springframework/util/exec/Execute.java
+++ b/spring-erlang/src/main/java/org/springframework/util/exec/Execute.java
@@ -1,17 +1,14 @@
/*
* Copyright 2002-2010 the original author or authors.
- *
- * Licensed 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.
+ *
+ * Licensed 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.springframework.util.exec;
@@ -24,21 +21,22 @@ import java.io.StringReader;
import java.util.StringTokenizer;
import java.util.Vector;
-/* Derived from ant exec task. All the 'backward compat with jdk1.1, 1.2'
- removed. Since jdk1.3 supports working dir, no need for scripts.
-
- All ant-specific code has been removed as well, this is a completely
- independent component.
-
- Costin
- */
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
- * Runs an external program.
+ * Runs an external program. Derived from ant exec task. All the 'backward compat with jdk1.1, 1.2' removed. Since
+ * jdk1.3 supports working dir, no need for scripts. All ant-specific code has been removed as well, this is a
+ * completely independent component.
+ *
*
* @author thomas.haas@softwired-inc.com
+ * @author Costin Leau
*/
public class Execute {
+
+ private static Log log = LogFactory.getLog(Execute.class);
+
/** Invalid exit code. **/
public final static int INVALID = Integer.MAX_VALUE;
@@ -72,8 +70,7 @@ public class Execute {
// Just try to use what we got
}
- BufferedReader in = new BufferedReader(new StringReader(
- out.toString()));
+ BufferedReader in = new BufferedReader(new StringReader(out.toString()));
String var = null;
String line, lineSep = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
@@ -128,8 +125,7 @@ public class Execute {
}
/**
- * Creates a new execute object using PumpStreamHandler for
- * stream handling.
+ * Creates a new execute object using PumpStreamHandler for stream handling.
*/
public Execute() {
this(new PumpStreamHandler(), null);
@@ -138,9 +134,7 @@ public class Execute {
/**
* Creates a new execute object.
*
- * @param streamHandler
- * the stream handler used to handle the input and output streams
- * of the subprocess.
+ * @param streamHandler the stream handler used to handle the input and output streams of the subprocess.
*/
public Execute(ExecuteStreamHandler streamHandler) {
this(streamHandler, null);
@@ -149,12 +143,8 @@ public class Execute {
/**
* Creates a new execute object.
*
- * @param streamHandler
- * the stream handler used to handle the input and output streams
- * of the subprocess.
- * @param watchdog
- * a watchdog for the subprocess or null to to
- * disable a timeout for the subprocess.
+ * @param streamHandler the stream handler used to handle the input and output streams of the subprocess.
+ * @param watchdog a watchdog for the subprocess or null to to disable a timeout for the subprocess.
*/
public Execute(ExecuteStreamHandler streamHandler, ExecuteWatchdog watchdog) {
this.streamHandler = streamHandler;
@@ -177,8 +167,7 @@ public class Execute {
/**
* Sets the commandline of the subprocess to launch.
*
- * @param commandline
- * the commandline of the subprocess to launch
+ * @param commandline the commandline of the subprocess to launch
*/
public void setCommandline(String[] commandline) {
cmdl = commandline;
@@ -187,8 +176,7 @@ public class Execute {
/**
* Set whether to propagate the default environment or not.
*
- * @param newenv
- * whether to propagate the process environment.
+ * @param newenv whether to propagate the process environment.
*/
public void setNewenvironment(boolean newenv) {
newEnvironment = newenv;
@@ -208,9 +196,8 @@ public class Execute {
/**
* Sets the environment variables for the subprocess to launch.
*
- * @param env
- * array of Strings, each element of which has an environment
- * variable settings in format key=value
+ * @param env array of Strings, each element of which has an environment variable settings in format
+ * key=value
*/
public void setEnvironment(String[] env) {
this.env = env;
@@ -219,13 +206,10 @@ public class Execute {
/**
* Sets the working directory of the process to execute.
*
- *
- * This is emulated using the antRun scripts unless the OS is Windows NT in
- * which case a cmd.exe is spawned, or MRJ and setting user.dir works, or
- * JDK 1.3 and there is official support in java.lang.Runtime.
+ *
This is emulated using the antRun scripts unless the OS is Windows NT in which case a cmd.exe is spawned, or
+ * MRJ and setting user.dir works, or JDK 1.3 and there is official support in java.lang.Runtime.
*
- * @param wd
- * the working directory of the process.
+ * @param wd the working directory of the process.
*/
public void setWorkingDirectory(File wd) {
workingDirectory = wd;
@@ -235,12 +219,10 @@ public class Execute {
* Runs a process defined by the command line and returns its exit status.
*
* @return the exit status of the subprocess or INVALID
- * @throws Exception
- * if launching of the subprocess failed
+ * @throws Exception if launching of the subprocess failed
*/
public int execute() throws Exception {
- process = Runtime.getRuntime().exec(getCommandline(), getEnvironment(),
- workingDirectory);
+ process = Runtime.getRuntime().exec(getCommandline(), getEnvironment(), workingDirectory);
try {
streamHandler.setProcessInputStream(process.getOutputStream());
streamHandler.setProcessOutputStream(process.getInputStream());
@@ -251,23 +233,29 @@ public class Execute {
}
streamHandler.start();
- if (watchdog != null)
+ if (watchdog != null) {
watchdog.start(process, Thread.currentThread());
+ }
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled()) {
log.trace("Waiting process ");
+ }
waitFor(process);
process = null;
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled()) {
log.trace("End waiting, stop threads ");
- if (watchdog != null)
+ }
+ if (watchdog != null) {
watchdog.stop();
- if (log.isTraceEnabled())
+ }
+ if (log.isTraceEnabled()) {
log.trace("Watchdog stopped ");
+ }
streamHandler.stop();
- if (log.isTraceEnabled())
+ if (log.isTraceEnabled()) {
log.trace("Stream handler stopped ");
+ }
if (watchdog != null) {
Exception ex = watchdog.getException();
if (ex != null)
@@ -302,6 +290,7 @@ public class Execute {
setExitValue(process.exitValue());
} catch (InterruptedException e) {
log.info("waitFor() interrupted ");
+ Thread.currentThread().interrupt();
}
}
@@ -312,8 +301,7 @@ public class Execute {
/**
* query the exit value of the process.
*
- * @return the exit value, 1 if the process was killed, or Project.INVALID
- * if no exit value has been received
+ * @return the exit value, 1 if the process was killed, or Project.INVALID if no exit value has been received
*/
public int getExitValue() {
return exitValue;
@@ -355,25 +343,19 @@ public class Execute {
return execute(envVars, v, baseDir);
}
- public static int execute(Vector envVars, Vector cmd,
- File baseDir) {
+ public static int execute(Vector envVars, Vector cmd, File baseDir) {
return execute(envVars, cmd, baseDir, 10000 /* default time to wait */);
}
/**
* Wrapper for common execution patterns
*
- * @param envVars
- * Environment variables to execute with (optional)
- * @param cmd
- * a vector of the commands to execute
- * @param baseDir
- * the base directory to run from (optional)
- * @param timeToWait
- * milliseconds to wait for completion
+ * @param envVars Environment variables to execute with (optional)
+ * @param cmd a vector of the commands to execute
+ * @param baseDir the base directory to run from (optional)
+ * @param timeToWait milliseconds to wait for completion
*/
- public static int execute(Vector envVars, Vector cmd,
- File baseDir, int timeToWait) {
+ public static int execute(Vector envVars, Vector cmd, File baseDir, int timeToWait) {
try {
// We can collect the out or provide in if needed
ExecuteWatchdog watchdog = new ExecuteWatchdog(timeToWait);
@@ -407,13 +389,9 @@ public class Execute {
log.debug("Exit value " + status);
return status;
} catch (Exception ex) {
- // ex.printStackTrace();
System.err.println("An error has occurred in Execute.");
return -1;
}
}
- private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
- .getLog(Execute.class);
-
}
diff --git a/spring-erlang/src/main/java/org/springframework/util/exec/ExecuteWatchdog.java b/spring-erlang/src/main/java/org/springframework/util/exec/ExecuteWatchdog.java
index 16f25723..014b52a9 100644
--- a/spring-erlang/src/main/java/org/springframework/util/exec/ExecuteWatchdog.java
+++ b/spring-erlang/src/main/java/org/springframework/util/exec/ExecuteWatchdog.java
@@ -103,7 +103,7 @@ public class ExecuteWatchdog implements Runnable {
/**
- * Watches the process and terminates it, if it runs for to long.
+ * Watches the process and terminates it, if it runs for too long.
*/
public synchronized void run() {
try {
@@ -117,7 +117,7 @@ public class ExecuteWatchdog implements Runnable {
} catch (InterruptedException e) {}
}
- // if we are here, either someone stopped the watchdog,
+ // If we are here, either someone stopped the watchdog,
// we are on timeout and the process must be killed, or
// we are on timeout and the process has already stopped.
try {
@@ -125,13 +125,11 @@ public class ExecuteWatchdog implements Runnable {
// before being here
process.exitValue();
} catch (IllegalThreadStateException e){
- // the process is not terminated, if this is really
+ // The process is not terminated, if this is really
// a timeout and not a manual stop then kill it.
- //System.out.println("ExecuteWatchdog: timeout");
if (watch){
killedProcess = true;
if( ! dontkill ) {
- //System.out.println("ExecuteWatchdog: destroying process");
process.destroy();
}
if( execThread != null ) {
@@ -144,7 +142,6 @@ public class ExecuteWatchdog implements Runnable {
} finally {
cleanUp();
}
- //System.out.println("ExecuteWatchdog: done");
}
diff --git a/spring-rabbit-admin/.classpath b/spring-rabbit-admin/.classpath
deleted file mode 100644
index 3bde1346..00000000
--- a/spring-rabbit-admin/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/spring-rabbit-admin/.project b/spring-rabbit-admin/.project
deleted file mode 100644
index df9ae64f..00000000
--- a/spring-rabbit-admin/.project
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- spring-rabbit-admin
-
-
-
-
-
- org.eclipse.wst.common.project.facet.core.builder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.maven.ide.eclipse.maven2Builder
-
-
-
-
- org.springframework.ide.eclipse.core.springbuilder
-
-
-
-
-
- org.springframework.ide.eclipse.core.springnature
- org.maven.ide.eclipse.maven2Nature
- org.eclipse.jdt.core.javanature
- org.eclipse.wst.common.project.facet.core.nature
-
-
diff --git a/spring-rabbit-admin/.settings/org.maven.ide.eclipse.prefs b/spring-rabbit-admin/.settings/org.maven.ide.eclipse.prefs
deleted file mode 100644
index 3b616447..00000000
--- a/spring-rabbit-admin/.settings/org.maven.ide.eclipse.prefs
+++ /dev/null
@@ -1,9 +0,0 @@
-#Tue Jun 29 21:59:01 EDT 2010
-activeProfiles=
-eclipse.preferences.version=1
-fullBuildGoals=process-test-resources
-includeModules=false
-resolveWorkspaceProjects=true
-resourceFilterGoals=process-resources resources\:testResources
-skipCompilerPlugin=true
-version=1
diff --git a/spring-rabbit-admin/.springBeans b/spring-rabbit-admin/.springBeans
deleted file mode 100644
index dbe284d5..00000000
--- a/spring-rabbit-admin/.springBeans
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- 1
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-rabbit-admin/pom.xml b/spring-rabbit-admin/pom.xml
deleted file mode 100644
index 6eb4e22e..00000000
--- a/spring-rabbit-admin/pom.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-
- 4.0.0
-
- org.springframework.amqp
- spring-amqp-parent
- 1.0.0.BUILD-SNAPSHOT
- ../spring-amqp-parent/pom.xml
-
- spring-rabbit-admin
- jar
- Spring RabbitMQ Administrative Support
-
-
- com.rabbitmq
- amqp-client
-
-
- org.springframework.amqp
- spring-amqp
-
-
- org.springframework.amqp
- spring-rabbit
-
-
- org.springframework.amqp
- spring-erlang
-
-
-
-
- org.springframework
- spring-aop
-
-
- org.springframework
- spring-oxm
-
-
- org.springframework
- spring-tx
-
-
- org.springframework
- spring-test
- compile
-
-
-
-
- commons-io
- commons-io
-
-
-
-
- org.slf4j
- slf4j-api
-
-
- org.slf4j
- jcl-over-slf4j
- compile
-
-
- org.slf4j
- slf4j-log4j12
- runtime
-
-
- log4j
- log4j
-
-
- javax.mail
- mail
-
-
- javax.jms
- jms
-
-
- com.sun.jdmk
- jmxtools
-
-
- com.sun.jmx
- jmxri
-
-
- runtime
-
-
-
- javax.annotation
- jsr250-api
- true
-
-
-
- cglib
- cglib-nodep
- true
-
-
-
- org.mockito
- mockito-all
- test
-
-
-
- junit
- junit
- compile
-
-
-
-
-
-
- com.springsource.bundlor
- com.springsource.bundlor.maven
-
-
-
-
diff --git a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/RabbitConfiguration.java b/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/RabbitConfiguration.java
deleted file mode 100644
index fa5261bf..00000000
--- a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/RabbitConfiguration.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2002-2010 the original author or authors.
- *
- * Licensed 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.springframework.amqp.rabbit.test;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * RabbitConfiguration defines class-level metadata for configuring Rabbit integration tests.
- *
- * @author Mark Pollack
- *
- */
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface RabbitConfiguration {
-
- String hostname() default "localhost";
-
- String username() default "guest";
-
- String password() default "guest";
-}
diff --git a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/RabbitTestExecutionListener.java b/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/RabbitTestExecutionListener.java
deleted file mode 100644
index a32a3a03..00000000
--- a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/RabbitTestExecutionListener.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2002-2010 the original author or authors.
- *
- * Licensed 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.springframework.amqp.rabbit.test;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.amqp.rabbit.admin.RabbitBrokerAdmin;
-import org.springframework.amqp.rabbit.admin.RabbitStatus;
-import org.springframework.amqp.rabbit.connection.SingleConnectionFactory;
-import org.springframework.core.annotation.AnnotationUtils;
-import org.springframework.erlang.OtpIOException;
-import org.springframework.test.context.TestContext;
-import org.springframework.test.context.support.AbstractTestExecutionListener;
-import org.springframework.test.context.transaction.TransactionConfiguration;
-import org.springframework.test.context.transaction.TransactionConfigurationAttributes;
-
-/**
- * A TestExeuctionListener that will start/reset the RabbitMQ node before the methods in the
- * TestClass are executed. If the node was started before the test methods were executed,
- * the node will be stopped after the test methods are executed .
- *
- * @author Mark Pollack
- */
-public class RabbitTestExecutionListener extends AbstractTestExecutionListener{
-
- private static final Log logger = LogFactory.getLog(RabbitTestExecutionListener.class);
-
- private RabbitBrokerAdmin rabbitAdminTemplate;
-
- private boolean startedNode;
-
-
- @Override
- public void beforeTestClass(TestContext testContext) throws Exception {
- initializeRabbitAdminTemplate(testContext);
- recycleBrokerApp();
- }
-
- @Override
- public void afterTestClass(TestContext testContext) throws Exception {
- if (startedNode) {
- rabbitAdminTemplate.stopNode();
- startedNode = false;
- }
- }
-
- private void recycleBrokerApp() {
- try {
- RabbitStatus status = rabbitAdminTemplate.getStatus();
- logger.debug(status);
- rabbitAdminTemplate.stopBrokerApplication();
- rabbitAdminTemplate.resetNode();
- rabbitAdminTemplate.startBrokerApplication();
- }
- catch (OtpIOException e) {
- // Can't connect because broker node isn't running.
- rabbitAdminTemplate.startNode();
- startedNode = true;
- //TODO - need to wait on output for 'broker running'
- try {
- Thread.sleep(2000);
- }
- catch (InterruptedException e1) {
- logger.error("Error waiting for broker to start");
- }
- }
- }
-
- /**
- * Retrieves the {@link TransactionConfigurationAttributes} for the
- * specified {@link Class class} which may optionally declare or inherit a
- * {@link TransactionConfiguration @TransactionConfiguration}. If a
- * {@link TransactionConfiguration} annotation is not present for the
- * supplied class, the default values for attributes defined in
- * {@link TransactionConfiguration} will be used instead.
- * @param clazz the Class object corresponding to the test class for which
- * the configuration attributes should be retrieved
- */
- private void initializeRabbitAdminTemplate(TestContext testContext) {
-
- //Could potentially get the information from the BeanFactory by implementing a BeanFactoryPostProcessor
- if (this.rabbitAdminTemplate == null) {
- Class> clazz = testContext.getTestClass();
- Class annotationType = RabbitConfiguration.class;
- RabbitConfiguration config = clazz.getAnnotation(annotationType);
- if (logger.isDebugEnabled()) {
- logger.debug("Retrieved @RabbitConfiguration [" + config + "] for test class [" + clazz + "]");
- }
- String hostname;
- String username;
- String password;
- if (config != null) {
- hostname = config.hostname();
- username = config.username();
- password = config.password();
- }
- else {
- hostname = (String) AnnotationUtils.getDefaultValue(annotationType, "hostname");
- username = (String) AnnotationUtils.getDefaultValue(annotationType, "username");
- password = (String) AnnotationUtils.getDefaultValue(annotationType, "password");
- }
- if (logger.isDebugEnabled()) {
- logger.debug(
- String.format("Retrieved hostname=[%s] username=[%s], password=[%s] for class [%s]",
- hostname, username, password, clazz));
- }
- SingleConnectionFactory connectionFactory;
- if (hostname.equals("localhost")) {
- //This will try to get the local host name
- connectionFactory = new SingleConnectionFactory();
- }
- else {
- connectionFactory = new SingleConnectionFactory(hostname);
- }
- connectionFactory.setUsername(username);
- connectionFactory.setPassword(password);
- rabbitAdminTemplate = new RabbitBrokerAdmin(connectionFactory);
- }
- }
-
-}
diff --git a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/SpringRabbitJUnit4ClassRunner.java b/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/SpringRabbitJUnit4ClassRunner.java
deleted file mode 100644
index b2770ab1..00000000
--- a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/test/SpringRabbitJUnit4ClassRunner.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2002-2010 the original author or authors.
- *
- * Licensed 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.springframework.amqp.rabbit.test;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-
-import org.junit.runners.model.InitializationError;
-import org.springframework.test.context.TestContextManager;
-import org.springframework.test.context.TestExecutionListener;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.util.ReflectionUtils;
-
-/**
- * A specialized JUnit4 class runner so that we can add a RabbitTestExecutionListener.
- *
- * The RabbitTestExecutionListener needs to run before the DependencyInjectionTestExecutionListener
- * so that the RabbitMQ broker application and be 'reset' or the RabbitMQ node
- * started before the application context is created so that RabbitMQ broker configuration can
- * execute when the applicatin context is created.
- *
- *
- * @author Mark Pollack
- *
- */
-public class SpringRabbitJUnit4ClassRunner extends SpringJUnit4ClassRunner {
-
- public SpringRabbitJUnit4ClassRunner(Class> clazz)
- throws InitializationError {
- super(clazz);
- }
-
-
- /**
- * Creates a new {@link TestContextManager} for the supplied test class and
- * the configured default ContextLoader class name.
- * Can be overridden by subclasses.
- *
- * @param clazz the test class to be managed
- * @see #getDefaultContextLoaderClassName(Class)
- */
- protected TestContextManager createTestContextManager(Class> clazz) {
- TestContextManager mgr = new TestContextManager(clazz, getDefaultContextLoaderClassName(clazz));
-
- Field executionListenersField = ReflectionUtils.findField(TestContextManager.class, "testExecutionListeners");
- executionListenersField.setAccessible(true);
- @SuppressWarnings("unchecked")
- ArrayList executionListeners =
- (ArrayList) ReflectionUtils.getField(executionListenersField, mgr);
- ArrayList newExecutionListeners = new ArrayList();
- newExecutionListeners.add(new RabbitTestExecutionListener());
- for (TestExecutionListener testExecutionListener : executionListeners) {
- newExecutionListeners.add(testExecutionListener);
- }
- ReflectionUtils.setField(executionListenersField, mgr, newExecutionListeners);
-
- //puts to the back of the list - need it before context is created as broker configuration instructions are
- //executed as part of the context creation.
- //mgr.registerTestExecutionListeners(new RabbitTestExecutionListener());
-
- return mgr;
- }
-
-
-}
diff --git a/spring-rabbit-admin/src/test/java/org/springframework/amqp/rabbit/test/RabbitTestExecutionListenerIntegrationTests.java b/spring-rabbit-admin/src/test/java/org/springframework/amqp/rabbit/test/RabbitTestExecutionListenerIntegrationTests.java
deleted file mode 100644
index d231ded9..00000000
--- a/spring-rabbit-admin/src/test/java/org/springframework/amqp/rabbit/test/RabbitTestExecutionListenerIntegrationTests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.springframework.amqp.rabbit.test;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-
-@RunWith(SpringRabbitJUnit4ClassRunner.class)
-@ContextConfiguration
-@RabbitConfiguration
-@Ignore // only works on Windows at the moment
-public class RabbitTestExecutionListenerIntegrationTests {
-
- @Test
- public void doNothing() throws InterruptedException {
- Thread.sleep(1000);
- System.out.println("inside DO NOTHING");
- System.out.println("inside DO NOTHING");
- }
-
- @Test
- public void doNothingAgain() throws InterruptedException {
- Thread.sleep(1000);
- System.out.println("inside DO AGAIN");
- System.out.println("inside DO AGAIN");
- }
-}
diff --git a/spring-rabbit-admin/src/test/resources/log4j.properties b/spring-rabbit-admin/src/test/resources/log4j.properties
deleted file mode 100644
index 6ddfb097..00000000
--- a/spring-rabbit-admin/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-log4j.rootCategory=INFO, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
-
-log4j.category.org.springframework.amqp=DEBUG
-log4j.category.org.springframework.beans.factory=INFO
-
diff --git a/spring-rabbit-admin/src/test/resources/org/springframework/amqp/rabbit/test/ConfigureBrokerAnntotationTests-context.xml b/spring-rabbit-admin/src/test/resources/org/springframework/amqp/rabbit/test/ConfigureBrokerAnntotationTests-context.xml
deleted file mode 100644
index 50181ac6..00000000
--- a/spring-rabbit-admin/src/test/resources/org/springframework/amqp/rabbit/test/ConfigureBrokerAnntotationTests-context.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
diff --git a/spring-rabbit-admin/template.mf b/spring-rabbit-admin/template.mf
deleted file mode 100644
index 1c320dcc..00000000
--- a/spring-rabbit-admin/template.mf
+++ /dev/null
@@ -1,13 +0,0 @@
-Bundle-SymbolicName: org.springframework.amqp.rabbit.admin
-Bundle-Name: Spring RabbitMQ Administrative Support
-Bundle-Vendor: SpringSource
-Bundle-ManifestVersion: 2
-Import-Template:
- org.springframework.*;version="[3.0.5, 4.0.0)",
- org.springframework.amqp.*;version="[1.0.0, 1.1.0)",
- org.apache.commons.logging;version="[1.1.1, 2.0.0)",
- com.rabbitmq.*;version="[1.8.1, 2.0.0)",
- com.ericsson.otp.erlang;version="[1.5.3, 2.0.0)",
- org.junit.*;version="0",
- org.w3c.dom.*;version="0",
- javax.xml.*;version="0"
diff --git a/spring-rabbit/pom.xml b/spring-rabbit/pom.xml
index ab8232eb..e961025e 100644
--- a/spring-rabbit/pom.xml
+++ b/spring-rabbit/pom.xml
@@ -19,6 +19,11 @@
org.springframework.amqpspring-amqp
+
+ org.springframework.amqp
+ spring-erlang
+ true
+
diff --git a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/admin/QueueInfo.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/admin/QueueInfo.java
old mode 100644
new mode 100755
similarity index 100%
rename from spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/admin/QueueInfo.java
rename to spring-rabbit/src/main/java/org/springframework/amqp/rabbit/admin/QueueInfo.java
diff --git a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/admin/RabbitAdminAuthException.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/admin/RabbitAdminAuthException.java
old mode 100644
new mode 100755
similarity index 100%
rename from spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/admin/RabbitAdminAuthException.java
rename to spring-rabbit/src/main/java/org/springframework/amqp/rabbit/admin/RabbitAdminAuthException.java
diff --git a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/admin/RabbitBrokerAdmin.java b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/admin/RabbitBrokerAdmin.java
old mode 100644
new mode 100755
similarity index 50%
rename from spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/admin/RabbitBrokerAdmin.java
rename to spring-rabbit/src/main/java/org/springframework/amqp/rabbit/admin/RabbitBrokerAdmin.java
index d94ff3f9..edf4d237
--- a/spring-rabbit-admin/src/main/java/org/springframework/amqp/rabbit/admin/RabbitBrokerAdmin.java
+++ b/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/admin/RabbitBrokerAdmin.java
@@ -15,43 +15,38 @@ package org.springframework.amqp.rabbit.admin;
import java.io.File;
import java.io.FilenameFilter;
+import java.io.UnsupportedEncodingException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
+import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.amqp.core.Binding;
-import org.springframework.amqp.core.Exchange;
-import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.rabbit.connection.ConnectionFactory;
-import org.springframework.amqp.rabbit.core.ChannelCallback;
-import org.springframework.amqp.rabbit.core.RabbitAdmin;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.erlang.OtpAuthException;
-import org.springframework.erlang.OtpIOException;
-import org.springframework.erlang.connection.SingleConnectionFactory;
+import org.springframework.erlang.OtpException;
+import org.springframework.erlang.connection.ConnectionFactory;
+import org.springframework.erlang.connection.SimpleConnectionFactory;
import org.springframework.erlang.core.Application;
import org.springframework.erlang.core.ErlangTemplate;
import org.springframework.erlang.core.Node;
import org.springframework.jmx.export.annotation.ManagedOperation;
-import org.springframework.jmx.export.annotation.ManagedOperationParameter;
-import org.springframework.jmx.export.annotation.ManagedOperationParameters;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.exec.Execute;
import org.springframework.util.exec.Os;
-import com.rabbitmq.client.AMQP.Exchange.DeleteOk;
-import com.rabbitmq.client.Channel;
-
/**
* Rabbit broker administration implementation exposed via JMX annotations.
*
@@ -59,135 +54,97 @@ import com.rabbitmq.client.Channel;
*/
public class RabbitBrokerAdmin implements RabbitBrokerOperations {
+ private static final String DEFAULT_VHOST = "/";
+
+ private static String DEFAULT_HOST;
+
+ private static final String DEFAULT_ENCODING = "UTF-8";
+
/** Logger available to subclasses */
protected final Log logger = LogFactory.getLog(getClass());
- private RabbitTemplate rabbitTemplate;
-
- private RabbitAdmin rabbitAdmin;
-
private ErlangTemplate erlangTemplate;
- private String virtualHost;
+ private String encoding = DEFAULT_ENCODING;
- public RabbitBrokerAdmin(ConnectionFactory connectionFactory) {
- this.virtualHost = connectionFactory.getVirtualHost();
- this.rabbitTemplate = new RabbitTemplate(connectionFactory);
- this.rabbitAdmin = new RabbitAdmin(connectionFactory);
- initializeDefaultErlangTemplate(rabbitTemplate);
+ private long timeout = 0;
+
+ // TODO: extract into field for DI
+ private SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
+
+ private final String hostName;
+
+ // TODO: RABBITMQ_NODE_PORT=5672
+
+ static {
+ try {
+ DEFAULT_HOST = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ DEFAULT_HOST = "localhost";
+ }
}
- // Exchange Operations
+ public RabbitBrokerAdmin() {
+ this(DEFAULT_HOST);
+ }
- public void declareExchange(Exchange exchange) {
- rabbitAdmin.declareExchange(exchange);
+ public RabbitBrokerAdmin(String hostName) {
+ if (Os.isFamily("windows") && !DEFAULT_HOST.equals(hostName)) {
+ hostName = hostName.toUpperCase();
+ }
+ this.hostName = hostName;
+ this.executor.setDaemon(true);
+ initializeDefaultErlangTemplate(hostName);
}
/**
- * Declare an exchange specifying its durability and auto-delete behavior. Explicit arguments are given so as to
- * make this method easily accessible from JMX management consoles. Durable exchanges last until they are deleted,
- * they will survive a server restart. Auto-deleted exchanges last until they are no longer used
- *
- * @param exchangeName the name of the exchange
- * @param exchangeType the exchange type
- * @param durable true if we are declaring a durable exchange (the exchange will survive a server restart)
- * @param autoDelete true if the server should delete the exchange when it is no longer in use
+ * The encoding to use for converting host names to byte arrays (which is needed on the remote side).
+ * @param encoding the encoding to use (default UTF-8)
*/
- @ManagedOperation
- public void declareExchange(final String exchangeName, final String exchangeType, final boolean durable,
- final boolean autoDelete) {
- rabbitTemplate.execute(new ChannelCallback