diff --git a/build.gradle b/build.gradle index f299512d..a3c56038 100644 --- a/build.gradle +++ b/build.gradle @@ -75,7 +75,6 @@ subprojects { subproject -> ext { cglibVersion = '3.1' commonsIoVersion = '2.4' - erlangOtpVersion = '1.5.6' hamcrestVersion = '1.3' jacksonVersion = '1.9.13' jackson2Version = '2.3.2' @@ -190,26 +189,11 @@ project('spring-amqp') { } -project('spring-erlang') { - description = 'Spring Erlang Support' - dependencies { - - compile "org.springframework:spring-beans:$springVersion" - compile "commons-io:commons-io:$commonsIoVersion" - - compile ("javax.annotation:jsr250-api:1.0", optional) - compile "org.erlang.otp:jinterface:$erlangOtpVersion" - - } - -} - project('spring-rabbit') { description = 'Spring RabbitMQ Support' dependencies { compile project(":spring-amqp") - testCompile project(":spring-erlang") compile "com.rabbitmq:amqp-client:$rabbitmqVersion" compile ("com.rabbitmq:http-client:$rabbitmqHttpClientVersion", optional) diff --git a/settings.gradle b/settings.gradle index f31f626f..ba9b0a34 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,5 @@ rootProject.name = 'spring-amqp-dist' include 'spring-amqp' -include 'spring-erlang' include 'spring-rabbit' diff --git a/spring-erlang/src/main/java/org/springframework/erlang/ErlangBadRpcException.java b/spring-erlang/src/main/java/org/springframework/erlang/ErlangBadRpcException.java deleted file mode 100644 index 19dc0996..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/ErlangBadRpcException.java +++ /dev/null @@ -1,49 +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.erlang; - -import com.ericsson.otp.erlang.OtpErlangTuple; - -/** - * Exception thrown when an 'badrpc' is received from an Erlang RPC call. - * @author Mark Pollack - * - */ -@SuppressWarnings("serial") -public class ErlangBadRpcException extends OtpException { - - private OtpErlangTuple reasonTuple; - - public ErlangBadRpcException(String reason) { - super(reason); - } - - public ErlangBadRpcException(OtpErlangTuple tuple) { - super(tuple.toString()); - this.reasonTuple = tuple; - } - - public OtpErlangTuple getReasonTuple() { - return reasonTuple; - } - - - - - - - -} diff --git a/spring-erlang/src/main/java/org/springframework/erlang/ErlangErrorRpcException.java b/spring-erlang/src/main/java/org/springframework/erlang/ErlangErrorRpcException.java deleted file mode 100644 index 6d32fa4f..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/ErlangErrorRpcException.java +++ /dev/null @@ -1,44 +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.erlang; - -import com.ericsson.otp.erlang.OtpErlangTuple; - -/** - * Exception thrown when an 'error' is received from an Erlang RPC call - * - * @author Mark Pollack - */ -@SuppressWarnings("serial") -public class ErlangErrorRpcException extends OtpException { - - private OtpErlangTuple reasonTuple; - - public ErlangErrorRpcException(String message) { - super(message); - } - - public ErlangErrorRpcException(OtpErlangTuple tuple) { - super(tuple.toString()); - this.reasonTuple = tuple; - } - - public OtpErlangTuple getReasonTuple() { - return reasonTuple; - } - - -} diff --git a/spring-erlang/src/main/java/org/springframework/erlang/OtpAuthException.java b/spring-erlang/src/main/java/org/springframework/erlang/OtpAuthException.java deleted file mode 100644 index 2749a31e..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/OtpAuthException.java +++ /dev/null @@ -1,35 +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.erlang; - -/** - * Runtime exception mirroring the OTP OtpAuthException. - * - * @author Mark Pollack - */ -@SuppressWarnings("serial") -public class OtpAuthException extends OtpException { - - public OtpAuthException(com.ericsson.otp.erlang.OtpAuthException cause) { - super(cause); - } - - public OtpAuthException(String msg, com.ericsson.otp.erlang.OtpAuthException cause) { - super(msg, cause); - } - -} diff --git a/spring-erlang/src/main/java/org/springframework/erlang/OtpException.java b/spring-erlang/src/main/java/org/springframework/erlang/OtpException.java deleted file mode 100644 index f5c42a51..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/OtpException.java +++ /dev/null @@ -1,39 +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.erlang; - -/** - * Base RuntimeException for errors that occur when executing OTP operations. - * - * @author Mark Pollack - */ -@SuppressWarnings("serial") -public class OtpException extends RuntimeException { - - public OtpException(String message) { - super(message); - } - - public OtpException(Throwable cause) { - super(cause); - } - - public OtpException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/spring-erlang/src/main/java/org/springframework/erlang/OtpIOException.java b/spring-erlang/src/main/java/org/springframework/erlang/OtpIOException.java deleted file mode 100644 index 50594d96..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/OtpIOException.java +++ /dev/null @@ -1,39 +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.erlang; - -import java.io.IOException; - -/** - * RuntimeException wrapper for an {@link IOException} which - * can be commonly thrown from OTP operations. - * - * @author Mark Pollack - * @author Mark Fisher - */ -@SuppressWarnings("serial") -public class OtpIOException extends OtpException { - - public OtpIOException(IOException cause) { - super(cause); - } - - public OtpIOException(String message, IOException cause) { - super(message, cause); - } - -} diff --git a/spring-erlang/src/main/java/org/springframework/erlang/UncategorizedOtpException.java b/spring-erlang/src/main/java/org/springframework/erlang/UncategorizedOtpException.java deleted file mode 100644 index deb11a71..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/UncategorizedOtpException.java +++ /dev/null @@ -1,36 +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.erlang; - -/** - * A "catch-all" exception type within the OtpException hierarchy - * when no more specific cause is known. - * - * @author Mark Pollack - */ -@SuppressWarnings("serial") -public class UncategorizedOtpException extends OtpException { - - public UncategorizedOtpException(Throwable cause) { - super(cause); - } - - public UncategorizedOtpException(String message, Throwable cause) { - super(message, cause); - } - -} \ No newline at end of file diff --git a/spring-erlang/src/main/java/org/springframework/erlang/connection/Connection.java b/spring-erlang/src/main/java/org/springframework/erlang/connection/Connection.java deleted file mode 100644 index d4966119..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/connection/Connection.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2002-2015 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.erlang.connection; - -import java.io.IOException; - -import com.ericsson.otp.erlang.OtpAuthException; -import com.ericsson.otp.erlang.OtpErlangExit; -import com.ericsson.otp.erlang.OtpErlangList; -import com.ericsson.otp.erlang.OtpErlangObject; - -/** - * A simple interface that is used to wrap access to the {@code OtpConnection} class - * in order to support caching of {@code OtpConnection}s via method interception. - * - * Note: The surface area of the API is all that is required to implement administrative - * functionality for the Spring AMQP admin project. - * To access the underlying {@code OtpConnection}, use the method {@code getTargetConnection} - * on the interface {@code ConnectionProxy} that is implemented by {@code DefaultConnection}. - * - * @author Mark Pollack - * @author aArtem Bilan - */ -public interface Connection { - - /** - * Close the connection to the remote node. - */ - void close(); - - /** - * Send an RPC request to the remote Erlang node. This convenience function - * creates the following message and sends it to 'rex' on the remote node: - *
- * { self, { call, Mod, Fun, Args, user } }
- *
- * - * Note that this method has unpredictable results if the remote node is not - * an Erlang node. - * @param mod the name of the Erlang module containing the function to be called. - * @param fun the name of the function to call. - * @param args a list of Erlang terms, to be used as arguments to the function. - * @exception java.io.IOException if the connection is not active or a communication - * error occurs. - */ - void sendRPC(final String mod, final String fun, final OtpErlangList args) throws IOException; - - /** - * Receive an RPC reply from the remote Erlang node. This convenience - * function receives a message from the remote node, and expects it to have - * the following format: - *
- * { rex, Term }
- *
- * @return the second element of the tuple if the received message is a
- * two-tuple, otherwise null. No further error checking is
- * performed.
- * @exception java.io.IOException if the connection is not active or a communication
- * error occurs.
- * @exception OtpErlangExit if an exit signal is received from a process on the
- * peer node.
- * @exception OtpAuthException if the remote node sends a message containing an
- * invalid cookie.
- */
- OtpErlangObject receiveRPC() throws IOException, OtpErlangExit, OtpAuthException;
-
- /**
- * Send an RPC request to the remote Erlang node and receive result.
- * The implementation must ensure {@code synchronized} mode of this method since
- * the underlying {@code OtpConnection} isn't thread-safe.
- * @param mod the name of the Erlang module containing the function to be called.
- * @param fun the name of the function to call.
- * @param args a list of Erlang terms, to be used as arguments to the function.
- * @return the second element of the tuple if the received message is a
- * two-tuple, otherwise null. No further error checking is
- * performed.
- * @exception java.io.IOException if the connection is not active or a communication
- * error occurs.
- * @exception OtpErlangExit if an exit signal is received from a process on the
- * peer node.
- * @exception OtpAuthException if the remote node sends a message containing an
- * invalid cookie.
- * @since 1.5
- */
- OtpErlangObject sendAndReceiveRPC(final String mod, final String fun, final OtpErlangList args)
- throws IOException, OtpErlangExit, OtpAuthException;
-
-}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionFactory.java b/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionFactory.java
deleted file mode 100644
index bdda9e5c..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionFactory.java
+++ /dev/null
@@ -1,36 +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.erlang.connection;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-
-import com.ericsson.otp.erlang.OtpAuthException;
-import com.ericsson.otp.erlang.OtpConnection;
-
-/**
- * An interface based ConnectionFactory for creating {@link OtpConnection}s.
- *
- * NOTE: The Rabbit API contains a ConnectionFactory class (same name). - * - * @author Mark Pollack - */ -public interface ConnectionFactory { - - Connection createConnection() throws UnknownHostException, OtpAuthException, IOException; - -} diff --git a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionFactoryUtils.java b/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionFactoryUtils.java deleted file mode 100644 index 498b1cc5..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionFactoryUtils.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2002-2015 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.erlang.connection; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author Mark Pollack - * @author Gary Russell - */ -public class ConnectionFactoryUtils { - - private static final Log logger = LogFactory.getLog(ConnectionFactoryUtils.class); - - - /** - * Release the given Connection by closing it. - * - * @param con The connection. - * @param cf The connection factory. - */ - public static void releaseConnection(Connection con, ConnectionFactory cf) { - if (con == null) { - return; - } - try { - con.close(); - } - catch (Exception ex) { - logger.debug("Could not close Otp Connection", ex); - } - } - -} 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 deleted file mode 100644 index 43e3d226..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionParameters.java +++ /dev/null @@ -1,51 +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.erlang.connection; - -import org.springframework.util.Assert; - -import com.ericsson.otp.erlang.OtpPeer; -import com.ericsson.otp.erlang.OtpSelf; - -/** - * Encapsulate properties to create a OtpConnection - * @author Mark Pollack - * - */ -public class ConnectionParameters { - - private OtpSelf otpSelf; - - private OtpPeer otpPeer; - - public ConnectionParameters(OtpSelf otpSelf, OtpPeer otpPeer) { - Assert.notNull(otpSelf, "OtpSelf must be non-null"); - Assert.notNull(otpPeer, "OtpPeer must be non-null"); - this.otpSelf = otpSelf; - this.otpPeer = otpPeer; - } - - public OtpSelf getOtpSelf() { - return otpSelf; - } - - public OtpPeer getOtpPeer() { - return otpPeer; - } - -} diff --git a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionProxy.java b/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionProxy.java deleted file mode 100644 index 4bd4de15..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/connection/ConnectionProxy.java +++ /dev/null @@ -1,31 +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.erlang.connection; - -import com.ericsson.otp.erlang.OtpConnection; - -/** - * Subinterface of {@link Connection} to be implemented by Connection proxies. - * Allows access to the underlying target Connection - * - * @author Mark Pollack - * - */ -public interface ConnectionProxy extends Connection { - - OtpConnection getTargetConnection(); -} diff --git a/spring-erlang/src/main/java/org/springframework/erlang/connection/DefaultConnection.java b/spring-erlang/src/main/java/org/springframework/erlang/connection/DefaultConnection.java deleted file mode 100644 index 5a6bd6b1..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/connection/DefaultConnection.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2002-2015 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.erlang.connection; - -import java.io.IOException; - -import com.ericsson.otp.erlang.OtpAuthException; -import com.ericsson.otp.erlang.OtpConnection; -import com.ericsson.otp.erlang.OtpErlangExit; -import com.ericsson.otp.erlang.OtpErlangList; -import com.ericsson.otp.erlang.OtpErlangObject; - -/** - * Basic implementation of {@link ConnectionProxy} that delegates - * to an underlying {@link OtpConnection}. - * @author Mark Pollack - * @author Artem Bilan - */ -public class DefaultConnection implements ConnectionProxy { - - private OtpConnection otpConnection; - - - public DefaultConnection(OtpConnection otpConnection) { - this.otpConnection = otpConnection; - } - - @Override - public void close() { - this.otpConnection.close(); - } - - @Override - public void sendRPC(String mod, String fun, OtpErlangList args) throws IOException { - this.otpConnection.sendRPC(mod, fun, args); - } - - @Override - public OtpErlangObject receiveRPC() throws IOException, OtpErlangExit, OtpAuthException { - return this.otpConnection.receiveRPC(); - } - - @Override - public synchronized OtpErlangObject sendAndReceiveRPC(String mod, String fun, OtpErlangList args) - throws IOException, OtpErlangExit, OtpAuthException { - sendRPC(mod, fun, args); - return receiveRPC(); - } - - public OtpConnection getTargetConnection() { - return this.otpConnection; - } - -} 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 deleted file mode 100644 index 1f232483..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/connection/SimpleConnectionFactory.java +++ /dev/null @@ -1,138 +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.erlang.connection; - -import java.io.IOException; -import java.net.UnknownHostException; -import java.util.UUID; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.erlang.OtpIOException; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; - -import com.ericsson.otp.erlang.OtpAuthException; -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. - *
- * - *- * 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. - *
- * @author Mark Pollack - * @author Mark Fisher - * @author Dave Syer - */ -public class SimpleConnectionFactory implements ConnectionFactory, InitializingBean { - - protected final Log logger = LogFactory.getLog(getClass()); - - private boolean uniqueSelfNodeName = true; - - private final String selfNodeName; - - private final String peerNodeName; - - private final String cookie; - - private OtpSelf otpSelf; - - private OtpPeer otpPeer; - - public SimpleConnectionFactory(String selfNodeName, String peerNodeName, String cookie) { - this.selfNodeName = selfNodeName; - this.peerNodeName = peerNodeName; - this.cookie = cookie; - } - - public SimpleConnectionFactory(String selfNodeName, String peerNodeName) { - this(selfNodeName, peerNodeName, null); - } - - 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); - } - } - - public boolean isUniqueSelfNodeName() { - return uniqueSelfNodeName; - } - - public void setUniqueSelfNodeName(boolean uniqueSelfNodeName) { - this.uniqueSelfNodeName = uniqueSelfNodeName; - } - - public void afterPropertiesSet() { - - 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(); - logger.debug("Creating OtpSelf with node name = [" + selfNodeNameToUse + "]"); - } - try { - if (StringUtils.hasText(cookie)) { - this.otpSelf = new OtpSelf(selfNodeNameToUse.trim(), this.cookie); - } else { - this.otpSelf = new OtpSelf(selfNodeNameToUse.trim()); - } - } 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/connection/SingleConnectionFactory.java b/spring-erlang/src/main/java/org/springframework/erlang/connection/SingleConnectionFactory.java deleted file mode 100644 index dbc43207..00000000 --- a/spring-erlang/src/main/java/org/springframework/erlang/connection/SingleConnectionFactory.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright 2002-2015 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.erlang.connection; - -import java.io.IOException; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.erlang.OtpIOException; -import org.springframework.util.Assert; - -import com.ericsson.otp.erlang.OtpAuthException; -import com.ericsson.otp.erlang.OtpPeer; -import com.ericsson.otp.erlang.OtpSelf; - -/** - * A {@link ConnectionFactory} implementation that returns the same Connections from all - * {@link #createConnection()} calls, and ignores calls to {@link Connection#close()}. - * - * 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. - *
- * - *- * 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 - */ -public class SingleConnectionFactory implements ConnectionFactory, - InitializingBean, DisposableBean { - - protected final Log logger = LogFactory.getLog(getClass()); - - private boolean uniqueSelfNodeName = true; - - private final String selfNodeName; - - private String cookie; - - private final String peerNodeName; - - private OtpSelf otpSelf; - - private OtpPeer otpPeer; - - /** Raw JInterface Connection */ - private Connection targetConnection; - - /** Proxy Connection */ - private Connection connection; - - /** Synchronization monitor for the shared Connection */ - private final Object connectionMonitor = new Object(); - - public SingleConnectionFactory(String selfNodeName, String cookie, - String peerNodeName) { - this.selfNodeName = selfNodeName; - this.cookie = cookie; - this.peerNodeName = peerNodeName; - } - - public SingleConnectionFactory(String selfNodeName, String peerNodeName) { - this.selfNodeName = selfNodeName; - this.peerNodeName = peerNodeName; - } - - public boolean isUniqueSelfNodeName() { - return uniqueSelfNodeName; - } - - public void setUniqueSelfNodeName(boolean uniqueSelfNodeName) { - this.uniqueSelfNodeName = uniqueSelfNodeName; - } - - @Override - public Connection createConnection() throws UnknownHostException, - OtpAuthException { - synchronized (this.connectionMonitor) { - if (this.connection == null) { - try { - initConnection(); - } catch (IOException e) { - throw new OtpIOException("failed to connect from '" - + this.selfNodeName + "' to peer node '" - + this.peerNodeName + "'", e); - } - - } - return this.connection; - } - } - - public void initConnection() throws IOException, OtpAuthException { - synchronized (this.connectionMonitor) { - if (this.targetConnection != null) { - closeConnection(this.targetConnection); - } - this.targetConnection = doCreateConnection(); - prepareConnection(this.targetConnection); - if (logger.isInfoEnabled()) { - logger.info("Established shared Rabbit Connection: " - + this.targetConnection); - } - this.connection = getSharedConnectionProxy(this.targetConnection); - } - } - - /** - * Close the underlying shared connection. - * The provider of this ConnectionFactory needs to care for proper shutdown. - *As this bean implements DisposableBean, a bean factory will
- * automatically invoke this on destruction of its cached singletons.
- */
- @Override
- public void destroy() {
- resetConnection();
- }
-
- /**
- * Reset the underlying shared Connection, to be reinitialized on next access.
- */
- public void resetConnection() {
- synchronized (this.connectionMonitor) {
- if (this.targetConnection != null) {
- closeConnection(this.targetConnection);
- }
- this.targetConnection = null;
- this.connection = null;
- }
- }
-
- /**
- * Close the given Connection.
- *
- * @param connection
- * the Connection to close
- */
- protected void closeConnection(Connection connection) {
- if (logger.isDebugEnabled()) {
- logger.debug("Closing shared Rabbit Connection: "
- + this.targetConnection);
- }
- try {
- // TODO there are other close overloads close(int closeCode,
- // java.lang.String closeMessage, int timeout)
- connection.close();
- }
- catch (Exception ex) {
- logger.debug("Could not close shared Rabbit Connection", ex);
- }
- }
-
- /**
- * Create a JInterface Connection via this class's ConnectionFactory.
- *
- * @return the new Otp Connection
- * @throws OtpAuthException Any.
- * @throws IOException Any.
- */
- protected Connection doCreateConnection() throws IOException,
- OtpAuthException {
- return new DefaultConnection(otpSelf.connect(otpPeer));
- }
-
- protected void prepareConnection(Connection con) throws IOException {
- }
-
- /**
- * Wrap the given OtpConnection with a proxy that delegates every method
- * call to it but suppresses close calls. This is useful for allowing
- * application code to handle a special framework Connection just like an
- * ordinary Connection from a Rabbit ConnectionFactory.
- *
- * @param target
- * the original Connection to wrap
- * @return the wrapped Connection
- */
- protected Connection getSharedConnectionProxy(Connection target) {
- List The default implementation delegates to the
- * {@link org.springframework.erlang.support.ErlangUtils#convertOtpAccessException} method.
- * @param ex the original checked {@link Exception} to convert
- * @return the Spring runtime wrapping 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.
- */
- public void setWorkingDirectory(File wd) {
- workingDirectory = wd;
- }
-
- /**
- * Runs a process defined by the command line and returns its exit status.
- *
- * @return the exit status of the subprocess or ex
- * @see org.springframework.erlang.support.ErlangUtils#convertOtpAccessException
- */
- protected OtpException convertOtpAccessException(Exception ex) {
- return ErlangUtils.convertOtpAccessException(ex);
- }
-
-
-
-
-
-
-
-
-
-
-}
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
deleted file mode 100644
index 0dfa95d1..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/core/Node.java
+++ /dev/null
@@ -1,48 +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.
- */
-
-/**
- * Describes an Erlang node.
- */
-package org.springframework.erlang.core;
-
-import java.io.Serializable;
-
-/**
- * Simple description class for an Erlang node.
- *
- * @author Mark Pollack
- *
- */
-@SuppressWarnings("serial")
-public class Node implements Serializable {
-
- private String name;
-
- public Node(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return "Node [name=" + name + "]";
- }
-
-}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/core/package-info.java b/spring-erlang/src/main/java/org/springframework/erlang/core/package-info.java
deleted file mode 100644
index 447c4497..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/core/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides core classes for Spring Erlang.
- */
-package org.springframework.erlang.core;
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/package-info.java b/spring-erlang/src/main/java/org/springframework/erlang/package-info.java
deleted file mode 100644
index 77ec4756..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Base package for Spring Erlang.
- */
-package org.springframework.erlang;
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/support/ErlangAccessor.java b/spring-erlang/src/main/java/org/springframework/erlang/support/ErlangAccessor.java
deleted file mode 100644
index 31685adc..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/support/ErlangAccessor.java
+++ /dev/null
@@ -1,64 +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.erlang.support;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.erlang.OtpException;
-import org.springframework.erlang.connection.Connection;
-import org.springframework.erlang.connection.ConnectionFactory;
-
-import com.ericsson.otp.erlang.OtpAuthException;
-
-/**
- * @author Mark Pollack
- */
-public abstract class ErlangAccessor implements InitializingBean {
-
- /** Logger available to subclasses */
- protected final Log logger = LogFactory.getLog(getClass());
-
- private ConnectionFactory connectionFactory;
-
- protected Connection createConnection() throws UnknownHostException, OtpAuthException, IOException {
- return getConnectionFactory().createConnection();
- }
-
- public void setConnectionFactory(ConnectionFactory connectionFactory) {
- this.connectionFactory = connectionFactory;
- }
-
- public ConnectionFactory getConnectionFactory() {
- return this.connectionFactory;
- }
-
-
- public void afterPropertiesSet() {
- if (getConnectionFactory() == null) {
- throw new IllegalArgumentException("Property 'connectionFactory' is required");
- }
- }
-
- protected OtpException convertOtpAccessException(Exception ex) {
- return ErlangUtils.convertOtpAccessException(ex);
- }
-}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/support/ErlangUtils.java b/spring-erlang/src/main/java/org/springframework/erlang/support/ErlangUtils.java
deleted file mode 100644
index edf2f602..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/support/ErlangUtils.java
+++ /dev/null
@@ -1,57 +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.erlang.support;
-
-import java.io.IOException;
-
-import org.springframework.erlang.OtpException;
-import org.springframework.erlang.OtpIOException;
-import org.springframework.erlang.UncategorizedOtpException;
-import org.springframework.util.Assert;
-
-import com.ericsson.otp.erlang.OtpAuthException;
-import com.ericsson.otp.erlang.OtpConnection;
-
-/**
- * @author Mark Pollack
- */
-public class ErlangUtils {
-
- /**
- * Close the given Connection.
- * @param con the Connection to close if necessary
- * (if this is null, the call will be ignored)
- */
- public static void releaseConnection(OtpConnection con) {
- if (con == null) {
- return;
- }
- con.close();
- }
-
- public static OtpException convertOtpAccessException(Exception ex) {
- Assert.notNull(ex, "Exception must not be null");
- if (ex instanceof IOException) {
- return new OtpIOException((IOException) ex);
- }
- if (ex instanceof OtpAuthException) {
- return new org.springframework.erlang.OtpAuthException((OtpAuthException) ex);
- }
- //fallback
- return new UncategorizedOtpException(ex);
- }
-}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/support/converter/ErlangConversionException.java b/spring-erlang/src/main/java/org/springframework/erlang/support/converter/ErlangConversionException.java
deleted file mode 100644
index 50195eab..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/support/converter/ErlangConversionException.java
+++ /dev/null
@@ -1,35 +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.erlang.support.converter;
-
-import org.springframework.erlang.OtpException;
-
-/**
- * @author Mark Pollack
- */
-@SuppressWarnings("serial")
-public class ErlangConversionException extends OtpException {
-
- public ErlangConversionException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ErlangConversionException(String message) {
- super(message);
- }
-
-}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/support/converter/ErlangConverter.java b/spring-erlang/src/main/java/org/springframework/erlang/support/converter/ErlangConverter.java
deleted file mode 100644
index f493c351..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/support/converter/ErlangConverter.java
+++ /dev/null
@@ -1,45 +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.erlang.support.converter;
-
-import com.ericsson.otp.erlang.OtpErlangObject;
-
-/**
- * Converter between Java and Erlang Types. Additional support for converting results from RPC calls.
- *
- * @author Mark Pollack
- */
-public interface ErlangConverter {
-
- /**
- * Convert a Java object to a Erlang data type.
- * @param object the object to convert
- * @return the Erlang data type
- * @throws ErlangConversionException in case of conversion failure
- */
- OtpErlangObject toErlang(Object object) throws ErlangConversionException;
-
- /**
- * Convert from a Erlang data type to a Java object.
- * @param erlangObject the Elang object to convert
- * @return the converted Java object
- * @throws ErlangConversionException in case of conversion failure
- */
- Object fromErlang(OtpErlangObject erlangObject) throws ErlangConversionException;
-
- Object fromErlangRpc(String module, String function, OtpErlangObject erlangObject) throws ErlangConversionException;
-}
diff --git a/spring-erlang/src/main/java/org/springframework/erlang/support/converter/SimpleErlangConverter.java b/spring-erlang/src/main/java/org/springframework/erlang/support/converter/SimpleErlangConverter.java
deleted file mode 100644
index 178aa768..00000000
--- a/spring-erlang/src/main/java/org/springframework/erlang/support/converter/SimpleErlangConverter.java
+++ /dev/null
@@ -1,158 +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.erlang.support.converter;
-
-import java.util.ArrayList;
-
-import com.ericsson.otp.erlang.OtpErlangAtom;
-import com.ericsson.otp.erlang.OtpErlangBinary;
-import com.ericsson.otp.erlang.OtpErlangBoolean;
-import com.ericsson.otp.erlang.OtpErlangByte;
-import com.ericsson.otp.erlang.OtpErlangChar;
-import com.ericsson.otp.erlang.OtpErlangDouble;
-import com.ericsson.otp.erlang.OtpErlangFloat;
-import com.ericsson.otp.erlang.OtpErlangInt;
-import com.ericsson.otp.erlang.OtpErlangList;
-import com.ericsson.otp.erlang.OtpErlangLong;
-import com.ericsson.otp.erlang.OtpErlangObject;
-import com.ericsson.otp.erlang.OtpErlangPid;
-import com.ericsson.otp.erlang.OtpErlangRangeException;
-import com.ericsson.otp.erlang.OtpErlangShort;
-import com.ericsson.otp.erlang.OtpErlangString;
-
-/**
- * Converter that supports the basic types and arrays.
- * @author Mark Pollack
- *
- */
-public class SimpleErlangConverter implements ErlangConverter {
-
- public Object fromErlang(OtpErlangObject erlangObject)
- throws ErlangConversionException {
- //TODO support arrays.
- return convertErlangToBasicType(erlangObject);
- }
-
- public Object fromErlangRpc(String module, String function,
- OtpErlangObject erlangObject) throws ErlangConversionException {
- return this.fromErlang(erlangObject);
- }
-
- public OtpErlangObject toErlang(Object obj)
- throws ErlangConversionException {
- if (obj instanceof OtpErlangObject) {
- return (OtpErlangObject) obj;
- }
- if (obj instanceof Object[]) {
- Object[] objectsToConvert = (Object[]) obj;
- if (objectsToConvert.length != 0) {
- ArrayListPumpStreamHandler for stream handling.
- */
- public Execute() {
- this(new PumpStreamHandler(), null);
- }
-
- /**
- * Creates a new execute object.
- *
- * @param streamHandler the stream handler used to handle the input and output streams of the subprocess.
- */
- public Execute(ExecuteStreamHandler streamHandler) {
- this(streamHandler, null);
- }
-
- /**
- * 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.
- */
- public Execute(ExecuteStreamHandler streamHandler, ExecuteWatchdog watchdog) {
- this.streamHandler = streamHandler;
- this.watchdog = watchdog;
- }
-
- /**
- * Returns the commandline used to create a subprocess.
- *
- * @return the commandline used to create a subprocess
- */
- public String[] getCommandline() {
- return cmdl;//NOSONAR
- }
-
- public String getCommandLineString() {
- return array2string(getCommandline());
- }
-
- /**
- * Sets the commandline of the subprocess to launch.
- *
- * @param commandline the commandline of the subprocess to launch
- */
- public void setCommandline(String[] commandline) {
- cmdl = Arrays.copyOf(commandline, commandline.length);
- }
-
- /**
- * Set whether to propagate the default environment or not.
- *
- * @param newenv whether to propagate the process environment.
- */
- public void setNewenvironment(boolean newenv) {
- newEnvironment = newenv;
- }
-
- /**
- * Returns the environment used to create a subprocess.
- *
- * @return the environment used to create a subprocess
- */
- public String[] getEnvironment() {
- if (env == null || newEnvironment) {
- return env;//NOSONAR
- }
- return patchEnvironment();
- }
-
- /**
- * 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
- */
- public void setEnvironment(String[] env) {
- this.env = Arrays.copyOf(env, env.length);
- }
-
- /**
- * Sets the working directory of the process to execute.
- *
- * INVALID
- * @throws Exception if launching of the subprocess failed
- */
- public int execute() throws Exception {
- process = Runtime.getRuntime().exec(getCommandline(), getEnvironment(), workingDirectory);
- try {
- streamHandler.setProcessInputStream(process.getOutputStream());
- streamHandler.setProcessOutputStream(process.getInputStream());
- streamHandler.setProcessErrorStream(process.getErrorStream());
- } catch (IOException e) {
- process.destroy();
- throw e;
- }
- streamHandler.start();
-
- if (watchdog != null) {
- watchdog.start(process, Thread.currentThread());
- }
-
- if (log.isTraceEnabled()) {
- log.trace("Waiting process ");
- }
- waitFor(process);
- process = null;
-
- if (log.isTraceEnabled()) {
- log.trace("End waiting, stop threads ");
- }
- if (watchdog != null) {
- watchdog.stop();
- }
- if (log.isTraceEnabled()) {
- log.trace("Watchdog stopped ");
- }
- streamHandler.stop();
- if (log.isTraceEnabled()) {
- log.trace("Stream handler stopped ");
- }
- if (watchdog != null) {
- Exception ex = watchdog.getException();
- if (ex != null) {
- throw ex;
- }
- }
- int exit = getExitValue();
-
- if (log.isDebugEnabled()) {
- log.debug("Done exit=" + exit + " " + getCommandLineString());
- }
- return exit;
- }
-
- public void kill() {
- if (process != null) {
- process.destroy();
- }
- }
-
- private String array2string(String sa[]) {
- if (sa == null) {
- return "null";
- }
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < sa.length; i++) {
- sb.append(sa[i]).append(" ");
- }
- return sb.toString();
- }
-
- protected void waitFor(Process process) {
- try {
- process.waitFor();
- setExitValue(process.exitValue());
- } catch (InterruptedException e) {
- log.info("waitFor() interrupted ");
- Thread.currentThread().interrupt();
- }
- }
-
- protected void setExitValue(int value) {
- exitValue = value;
- }
-
- /**
- * 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
- */
- public int getExitValue() {
- return exitValue;
- }
-
- /**
- * Patch the current environment with the new values from the user.
- *
- * @return the patched environment
- */
- private String[] patchEnvironment() {
- @SuppressWarnings("unchecked")
- VectorExecute to handle input and output stream of
- * subprocesses.
- *
- * @author thomas.haas@softwired-inc.com
- */
-public interface ExecuteStreamHandler {
-
- /**
- * Install a handler for the input stream of the subprocess.
- *
- * @param os output stream to write to the standard input stream of the
- * subprocess
- * @throws IOException Any.
- */
- void setProcessInputStream(OutputStream os) throws IOException;
-
- /**
- * Install a handler for the error stream of the subprocess.
- *
- * @param is input stream to read from the error stream from the subprocess
- * @throws IOException Any.
- */
- void setProcessErrorStream(InputStream is) throws IOException;
-
- /**
- * Install a handler for the output stream of the subprocess.
- *
- * @param is input stream to read from the error stream from the subprocess
- * @throws IOException Any.
- */
- void setProcessOutputStream(InputStream is) throws IOException;
-
- /**
- * Start handling of the streams.
- *
- * @throws IOException Any.
- */
- void start() throws IOException;
-
- /**
- * Stop handling of the streams - will not be restarted.
- */
- void stop();
-}
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
deleted file mode 100644
index bd45c836..00000000
--- a/spring-erlang/src/main/java/org/springframework/util/exec/ExecuteWatchdog.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2002-2015 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.util.exec;
-
-
-/**
- * Destroys a process running for too long.
- * For example:
- *
- * {@code
- * ExecuteWatchdog watchdog = new ExecuteWatchdog(30000);
- * Execute exec = new Execute(myloghandler, watchdog);
- * exec.setCommandLine(mycmdline);
- * int exitvalue = exec.execute();
- * if (exitvalue != SUCCESS && watchdog.killedProcess()){
- * // it was killed on purpose by the watchdog
- * }
- * }
- *
-
- * @author thomas.haas@softwired-inc.com
- * @author Stephane Bailliez
- * @see Execute
- */
-public class ExecuteWatchdog implements Runnable {
-
- /** the process to execute and watch for duration */
- private Process process;
-
- /** timeout duration. Once the process running time exceeds this it should be killed */
- private final int timeout;
-
- /** say whether or not the watchog is currently monitoring a process */
- private boolean watch = false;
-
- /** exception that might be thrown during the process execution */
- private Exception caught = null;
-
- /** say whether or not the process was killed due to running overtime */
- private boolean killedProcess = false;
-
- Thread execThread;
- private boolean dontkill=false;
- /**
- * Creates a new watchdog with a given timeout.
- *
- * @param timeout the timeout for the process in milliseconds. It must be greather than 0.
- */
- public ExecuteWatchdog(int timeout) {
- if (timeout < 1) {
- throw new IllegalArgumentException("timeout lesser than 1.");
- }
- this.timeout = timeout;
- }
-
-
- public void setDontkill( boolean b ) {
- dontkill=b;//NOSONAR
- }
-
- /**
- * Watches the given process and terminates it, if it runs for too long.
- * All information from the previous run are reset.
- * @param process the process to monitor. It cannot be null
- * @param execThread The thread.
- * @throws IllegalStateException thrown if a process is still being monitored.
- */
- public synchronized void start(Process process, Thread execThread) {
- if (process == null) {
- throw new NullPointerException("process is null.");
- }
- if (this.process != null) {
- throw new IllegalStateException("Already running.");
- }
- this.caught = null;
- this.killedProcess = false;
- this.watch = true;
- this.process = process;
- final Thread thread = new Thread(this, "WATCHDOG");
- this.execThread=execThread;
- thread.setDaemon(true);
- thread.start();
- }
-
- /**
- * Stops the watcher. It will notify all threads possibly waiting on this object.
- */
- public synchronized void stop() {
- watch = false;
- notifyAll();
- }
-
-
- /**
- * Watches the process and terminates it, if it runs for too long.
- */
- @Override
- public synchronized void run() {
- try {
- // This isn't a Task, don't have a Project object to log.
- // project.log("ExecuteWatchdog: timeout = "+timeout+" msec", Project.MSG_VERBOSE);
- final long until = System.currentTimeMillis() + timeout;
- long now;
- while (watch && until > (now = System.currentTimeMillis())) {
- try {
- wait(until - now);
- } catch (InterruptedException e) {}
- }
-
- // 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 {
- // We must check if the process was not stopped
- // before being here
- process.exitValue();
- } catch (IllegalThreadStateException e){
- // The process is not terminated, if this is really
- // a timeout and not a manual stop then kill it.
- if (watch){
- killedProcess = true;
- if( ! dontkill ) {
- process.destroy();
- }
- if( execThread != null ) {
- execThread.interrupt();
- }
- }
- }
- } catch(Exception e) {
- caught = e;
- } finally {
- cleanUp();
- }
- }
-
-
- /**
- * reset the monitor flag and the process.
- */
- protected void cleanUp() {
- watch = false;
- process = null;
- }
-
- public Exception getException() {
- return caught;
- }
-
- /**
- * Indicates whether or not the watchdog is still monitoring the process.
- * @return true if the process is still running, otherwise false.
- */
- public boolean isWatching(){
- return watch;
- }
-
- /**
- * Indicates whether the last process run was killed on timeout or not.
- * @return true if the process was killed otherwise false.
- */
- public boolean killedProcess(){
- return killedProcess;
- }
-}
-
diff --git a/spring-erlang/src/main/java/org/springframework/util/exec/Os.java b/spring-erlang/src/main/java/org/springframework/util/exec/Os.java
deleted file mode 100644
index 128a6ec0..00000000
--- a/spring-erlang/src/main/java/org/springframework/util/exec/Os.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 2002-2014 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.util.exec;
-
-import java.util.Locale;
-
-/**
- * Condition that tests the OS type.
- *
- * @author Stefan Bodewig
- * @author Magesh Umasankar
- */
-public class Os {
- private static final String osName =
- System.getProperty("os.name").toLowerCase(Locale.US);
- private static final String osArch =
- System.getProperty("os.arch").toLowerCase(Locale.US);
- private static final String osVersion =
- System.getProperty("os.version").toLowerCase(Locale.US);
- private static final String pathSep = System.getProperty("path.separator");
-
- /**
- * Determines if the OS on which Ant is executing matches the
- * given OS family.
- *
- * @param family The OS family type desired
- * Possible values:
- *
- * @return true if the OS is in the family.
- * @since 1.5
- */
- public static boolean isFamily(String family) {
- return isOs(family, null, null, null);
- }
-
- /**
- * Determines if the OS on which Ant is executing matches the
- * given OS name.
- *
- * @param name The name.
- * @return The result.
- * @since 1.7
- */
- public static boolean isName(String name) {
- return isOs(null, name, null, null);
- }
-
- /**
- * Determines if the OS on which Ant is executing matches the
- * given OS architecture.
- *
- * @param arch The arch.
- * @return The result.
- * @since 1.7
- */
- public static boolean isArch(String arch) {
- return isOs(null, null, arch, null);
- }
-
- /**
- * Determines if the OS on which Ant is executing matches the
- * given OS version.
- *
- * @param version The version.
- * @return The result.
- * @since 1.7
- */
- public static boolean isVersion(String version) {
- return isOs(null, null, null, version);
- }
-
- /**
- * Determines if the OS on which Ant is executing matches the
- * given OS family, name, architecture and version
- *
- * @param family The OS family
- * @param name The OS name
- * @param arch The OS architecture
- * @param version The OS version
- *
- * @return The result.
- * @since 1.7
- */
- public static boolean isOs(String family, String name, String arch,
- String version) {
- boolean retValue = false;
-
- if (family != null || name != null || arch != null
- || version != null) {
-
- boolean isFamily = true;
- boolean isName = true;
- boolean isArch = true;
- boolean isVersion = true;
-
- if (family != null) {
- if (family.equals("windows")) {
- isFamily = osName.indexOf("windows") > -1;
- } else if (family.equals("os/2")) {
- isFamily = osName.indexOf("os/2") > -1;
- } else if (family.equals("netware")) {
- isFamily = osName.indexOf("netware") > -1;
- } else if (family.equals("dos")) {
- isFamily = pathSep.equals(";") && !isFamily("netware");
- } else if (family.equals("mac")) {
- isFamily = osName.indexOf("mac") > -1;
- } else if (family.equals("unix")) {
- isFamily = pathSep.equals(":")
- && (!isFamily("mac") || osName.endsWith("x"));
- } else {
- throw new RuntimeException(
- "Don\'t know how to detect os family \""
- + family + "\"");
- }
- }
- if (name != null) {
- isName = name.equals(osName);
- }
- if (arch != null) {
- isArch = arch.equals(osArch);
- }
- if (version != null) {
- isVersion = version.equals(osVersion);
- }
- retValue = isFamily && isName && isArch && isVersion;
- }
- return retValue;
- }
-}
diff --git a/spring-erlang/src/main/java/org/springframework/util/exec/PumpStreamHandler.java b/spring-erlang/src/main/java/org/springframework/util/exec/PumpStreamHandler.java
deleted file mode 100644
index 36d5b6da..00000000
--- a/spring-erlang/src/main/java/org/springframework/util/exec/PumpStreamHandler.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2002-2014 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.util.exec;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Copies standard output and error of subprocesses to standard output and
- * error of the parent process.
- *
- * TODO: standard input of the subprocess is not implemented.
- *
- * @author thomas.haas@softwired-inc.com
- */
-public class PumpStreamHandler implements ExecuteStreamHandler {
-
- private Thread inputThread;
- private Thread errorThread;
-
- private final OutputStream out, err;
- boolean running=false;
-
- public PumpStreamHandler(OutputStream out, OutputStream err) {
- this.out = out;
- this.err = err;
- }
-
- public PumpStreamHandler(OutputStream outAndErr) {
- this(outAndErr, outAndErr);
- }
-
- public PumpStreamHandler() {
- this(System.out, System.err);
- }
-
- @Override
- public void setProcessOutputStream(InputStream is) {
- createProcessOutputPump(is, out);
- }
-
-
- @Override
- public void setProcessErrorStream(InputStream is) {
- createProcessErrorPump(is, err);
- }
-
-
- @Override
- public void setProcessInputStream(OutputStream os) {
- }
-
-
- @Override
- public void start() {
- inputThread.start();
- errorThread.start();
- running=true;
- }
-
-
- @Override
- public void stop() {
- if( !running ) {
- return;
- }
- try {
- inputThread.join(1000);
- } catch(InterruptedException e) {}
- try {
- errorThread.join(1000);
- } catch(InterruptedException e) {}
- try {
- err.flush();
- } catch (IOException e) {}
- try {
- out.flush();
- } catch (IOException e) {}
- running=false;
- }
-
- protected OutputStream getErr() {
- return err;
- }
-
- protected OutputStream getOut() {
- return out;
- }
-
- protected void createProcessOutputPump(InputStream is, OutputStream os) {
- inputThread = createPump(is, os);
- }
-
- protected void createProcessErrorPump(InputStream is, OutputStream os) {
- errorThread = createPump(is, os);
- }
-
-
- /**
- * Creates a stream pumper to copy the given input stream to the given output stream.
- *
- * @param is The input stream.
- * @param os The output stream.
- * @return The thread.
- */
- protected Thread createPump(InputStream is, OutputStream os) {
- final Thread result = new Thread(new StreamPumper(is, os));
- result.setDaemon(true);
- return result;
- }
-
-}
diff --git a/spring-erlang/src/main/java/org/springframework/util/exec/StreamPumper.java b/spring-erlang/src/main/java/org/springframework/util/exec/StreamPumper.java
deleted file mode 100644
index e84b44cc..00000000
--- a/spring-erlang/src/main/java/org/springframework/util/exec/StreamPumper.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2002-2013 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.util.exec;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Copies all data from an input stream to an output stream.
- *
- * @author thomas.haas@softwired-inc.com
- */
-public class StreamPumper implements Runnable {
-
- // TODO: make SIZE and SLEEP instance variables.
- // TODO: add a status flag to note if an error occured in run.
-
- private static final int SLEEP = 5;
- private static final int SIZE = 128;
- private InputStream is;
- private OutputStream os;
-
-
- /**
- * Create a new stream pumper.
- *
- * @param is input stream to read data from
- * @param os output stream to write data to.
- */
- public StreamPumper(InputStream is, OutputStream os) {
- this.is = is;
- this.os = os;
- }
-
-
- /**
- * Copies data from the input stream to the output stream.
- *
- * Terminates as soon as the input stream is closed or an error occurs.
- */
- public void run() {
- final byte[] buf = new byte[SIZE];
-
- int length;
- try {
- while ((length = is.read(buf)) > 0) {
- os.write(buf, 0, length);
- try {
- Thread.sleep(SLEEP);
- } catch (InterruptedException e) {}
- }
- } catch(IOException e) {}
- }
-}
diff --git a/spring-erlang/src/main/java/org/springframework/util/exec/package-info.java b/spring-erlang/src/main/java/org/springframework/util/exec/package-info.java
deleted file mode 100644
index 7596d870..00000000
--- a/spring-erlang/src/main/java/org/springframework/util/exec/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Provides classes supporting execution.
- */
-package org.springframework.util.exec;
diff --git a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/JInterfaceIntegrationTests.java b/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/JInterfaceIntegrationTests.java
deleted file mode 100755
index 7330557d..00000000
--- a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/JInterfaceIntegrationTests.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright 2002-2015 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.admin;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-import org.springframework.amqp.rabbit.test.BrokerTestUtils;
-import org.springframework.amqp.rabbit.test.EnvironmentAvailable;
-import org.springframework.erlang.connection.SingleConnectionFactory;
-import org.springframework.erlang.core.ErlangTemplate;
-
-import com.ericsson.otp.erlang.OtpConnection;
-import com.ericsson.otp.erlang.OtpErlangBinary;
-import com.ericsson.otp.erlang.OtpErlangList;
-import com.ericsson.otp.erlang.OtpErlangObject;
-import com.ericsson.otp.erlang.OtpPeer;
-import com.ericsson.otp.erlang.OtpSelf;
-
-/**
- * @author Mark Pollack
- * @author Mark Fisher
- * @author Chris Beams
- * @author Dave Syer
- * @author Gary Russell
- * @author Artem Bilan
- */
-public class JInterfaceIntegrationTests {
-
- private static Log logger = LogFactory.getLog(JInterfaceIntegrationTests.class);
-
- private static int counter;
-
- private static final String NODE_NAME = "spring@localhost";
-
- private OtpConnection connection = null;
-
- private RabbitBrokerAdmin brokerAdmin;
-
- @ClassRule
- public static EnvironmentAvailable environment = new EnvironmentAvailable("BROKER_INTEGRATION_TEST");
-
- @Before
- public void init() {
- brokerAdmin = BrokerTestUtils.getRabbitBrokerAdmin(NODE_NAME);
- RabbitStatus status = brokerAdmin.getStatus();
- if (!status.isRunning()) {
- brokerAdmin.startBrokerApplication();
- }
- }
-
- @After
- public void close() {
- if (connection != null) {
- connection.close();
- }
- if (brokerAdmin != null) {
- brokerAdmin.stopNode();
- }
- }
-
- @Test
- public void testRawApi() throws Exception {
-
- OtpSelf self = new OtpSelf("rabbit-monitor");
-
- String hostName = NODE_NAME;
- OtpPeer peer = new OtpPeer(hostName);
- connection = self.connect(peer);
-
- OtpErlangObject[] objectArray = { new OtpErlangBinary("/".getBytes()) };
-
- connection.sendRPC("rabbit_amqqueue", "info_all", new OtpErlangList(objectArray));
-
- OtpErlangObject received = connection.receiveRPC();
- System.out.println(received);
- System.out.println(received.getClass());
-
- }
-
- @Test
- public void otpTemplate() throws UnknownHostException {
-
- String selfNodeName = "rabbit-monitor";
- String peerNodeName = NODE_NAME;
-
- SingleConnectionFactory cf = new SingleConnectionFactory(selfNodeName, peerNodeName);
-
- cf.afterPropertiesSet();
- ErlangTemplate template = new ErlangTemplate(cf);
- template.afterPropertiesSet();
-
- long number = (Long) template.executeAndConvertRpc("erlang", "abs", -161803399);
- Assert.assertEquals(161803399, number);
-
- cf.destroy();
-
- }
-
- @Test
- public void testRawOtpConnect() throws Exception {
- createConnection();
- }
-
- @Test
- public void stressTest() throws Exception {
- String cookie = readCookie();
- logger.info("Cookie: " + cookie);
- OtpConnection con = createConnection();
- boolean recycleConnection = false;
- for (int i = 0; i < 100; i++) {
- executeRpc(con, recycleConnection, "rabbit", "status");
- executeRpc(con, recycleConnection, "rabbit", "stop");
- executeRpc(con, recycleConnection, "rabbit", "status");
- executeRpc(con, recycleConnection, "rabbit", "start");
- executeRpc(con, recycleConnection, "rabbit", "status");
- if (i % 10 == 0) {
- logger.debug("i = " + i);
- }
- }
- }
-
- @Test
- public void testConcurrency() throws Exception {
- SingleConnectionFactory cf = new SingleConnectionFactory("rabbit-monitor", NODE_NAME);
- cf.afterPropertiesSet();
- final ErlangTemplate template = new ErlangTemplate(cf);
- template.afterPropertiesSet();
-
- ExecutorService executorService = Executors.newFixedThreadPool(10);
-
- for (int i = 0; i < 10; i++) {
- final int j = i;
- executorService.execute(new Runnable() {
-
- @Override
- public void run() {
- Assert.assertEquals((long) j, template.executeAndConvertRpc("erlang", "abs", -j));
- }
-
- });
- }
-
- executorService.shutdown();
-
- assertTrue(executorService.awaitTermination(10, TimeUnit.SECONDS));
-
- cf.destroy();
- }
-
- public OtpConnection createConnection() throws Exception {
- OtpSelf self = new OtpSelf("rabbit-monitor-" + counter++);
- OtpPeer peer = new OtpPeer(NODE_NAME);
- return self.connect(peer);
- }
-
- private void executeRpc(OtpConnection con, boolean recycleConnection, String module, String function)
- throws Exception, UnknownHostException {
- con.sendRPC(module, function, new OtpErlangList());
- OtpErlangObject response = con.receiveRPC();
- logger.debug(module + " response received = " + response.toString());
- if (recycleConnection) {
- con.close();
- con = createConnection();
- }
- }
-
- private String readCookie() throws Exception {
- String cookie = null;
- final String dotCookieFilename = System.getProperty("user.home") + File.separator + ".erlang.cookie";
- BufferedReader br = null;
-
- try {
- final File dotCookieFile = new File(dotCookieFilename);
-
- br = new BufferedReader(new FileReader(dotCookieFile));
- cookie = br.readLine().trim();
- return cookie;
- } finally {
- try {
- if (br != null) {
- br.close();
- }
- } catch (final IOException e) {
- }
- }
- }
-
-}
diff --git a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/QueueInfo.java b/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/QueueInfo.java
deleted file mode 100755
index 1ff82671..00000000
--- a/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/admin/QueueInfo.java
+++ /dev/null
@@ -1,176 +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.admin;
-
-
-/**
- * This class represents a Queue that is configured on the RabbitMQ broker
- *
- * @author Mark Pollack
- *
- */
-public class QueueInfo {
- /*{app.stock.request={transactions=0, acks_uncommitted=0,
- * consumers=0, pid=#Pid
- *
- *
- * Depending on your platform, to {@link #startNode() start the broker} you might need to set some environment
- * properties. The most common are available via constructors or setters in this class (e.g.
- * {@link #setRabbitLogBaseDirectory(String) RABBITMQ_LOG_BASE}). All others you can set via the OS (any setting that
- * RabbtMQ allows in its startup script), and some work via System properties as special convenience cases (
- * ERLANG_HOME and RABBITMQ_HOME ).
- *
- * @author Mark Pollack
- * @author Dave Syer
- * @author Helena Edelson
- */
-public class RabbitBrokerAdmin implements RabbitBrokerOperations {
-
- private static final String DEFAULT_VHOST = "/";
-
- private static String DEFAULT_NODE_NAME;
-
- private static final int DEFAULT_PORT = 5672;
-
- private static final String DEFAULT_ENCODING = "UTF-8";
-
- /** Logger available to subclasses */
- protected final Log logger = LogFactory.getLog(getClass());
-
- private ErlangTemplate erlangTemplate;
-
- private String encoding = DEFAULT_ENCODING;
-
- private long timeout = 0;
-
- private AsyncTaskExecutor executor;
-
- private final String nodeName;
-
- private final String cookie;
-
- private final int port;
-
- private String rabbitLogBaseDirectory;
-
- private String rabbitMnesiaBaseDirectory;
-
- private Map@ character, it will be prepended with an alivename rabbit@
- * (interpreting the supplied value as just the hostname).
- *
- * @param nodeName the node name or hostname to use
- * @param port the port number (overriding the default which is 5672)
- * @param cookie the cookie value to use
- */
- public RabbitBrokerAdmin(String nodeName, int port, String cookie) {
-
- if (!nodeName.contains("@")) {
- nodeName = "rabbit@" + nodeName; // it was just the host
- }
-
- String[] parts = nodeName.split("@");
- Assert.state(parts.length == 2, "The node name should be in the form alivename@host, e.g. rabbit@myserver");
- if (Os.isFamily("windows") && !DEFAULT_NODE_NAME.equals(nodeName)) {
- nodeName = parts[0] + "@" + parts[1].toUpperCase();
- }
-
- this.port = port;
- this.cookie = cookie;
- this.nodeName = nodeName;
- SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
- executor.setDaemon(true);
- this.executor = executor;
-
- }
-
- /**
- * An async task executor for launching background processing when starting or stopping the broker.
- *
- * @param executor the executor to set
- */
- public void setExecutor(AsyncTaskExecutor executor) {
- this.executor = executor;
- }
-
- /**
- * The location of RABBITMQ_LOG_BASE to override the system default (which may be owned by another
- * user). Only needed for launching the broker process. Can also be set as a system property.
- *
- * @param rabbitLogBaseDirectory the rabbit log base directory to set
- */
- public void setRabbitLogBaseDirectory(String rabbitLogBaseDirectory) {
- this.rabbitLogBaseDirectory = rabbitLogBaseDirectory;
- }
-
- /**
- * The location of RABBITMQ_MNESIA_BASE to override the system default (which may be owned by another
- * user). Only needed for launching the broker process. Can also be set as a system property.
- *
- * @param rabbitMnesiaBaseDirectory the rabbit Mnesia base directory to set
- */
- public void setRabbitMnesiaBaseDirectory(String rabbitMnesiaBaseDirectory) {
- this.rabbitMnesiaBaseDirectory = rabbitMnesiaBaseDirectory;
- }
-
- /**
- * 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)
- */
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- }
-
- /**
- * Timeout (milliseconds) to wait for the broker to come up. If the provided timeout is greater than zero then we
- * wait for that period for the broker to be ready. If it is not ready after that time the process is stopped.
- * Defaults to 0 (no wait).
- *
- * @param timeout the timeout value to set in milliseconds
- */
- public void setStartupTimeout(long timeout) {
- this.timeout = timeout;
- }
-
- /**
- * Allows users to adapt Erlang RPC (module, function) pairs to older, or different, versions of the
- * broker than the current target. The map is from String to String in the form
- * input_module%input_function -> output_module%output_function (using a % separator).
- *
- * @param moduleAdapter the module adapter to set
- */
- public void setModuleAdapter(Map