AMQP-278 White Space Violations
Remove trailing white spaces from all java, xml and 1.1 xsd files.
git log -p -b
shows no changes other than white space removal.
This commit is contained in:
@@ -26,11 +26,11 @@ import com.ericsson.otp.erlang.OtpErlangTuple;
|
||||
public class ErlangBadRpcException extends OtpException {
|
||||
|
||||
private OtpErlangTuple reasonTuple;
|
||||
|
||||
|
||||
public ErlangBadRpcException(String reason) {
|
||||
super(reason);
|
||||
}
|
||||
|
||||
|
||||
public ErlangBadRpcException(OtpErlangTuple tuple) {
|
||||
super(tuple.toString());
|
||||
this.reasonTuple = tuple;
|
||||
@@ -40,10 +40,10 @@ public class ErlangBadRpcException extends OtpException {
|
||||
return reasonTuple;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ import com.ericsson.otp.erlang.OtpErlangTuple;
|
||||
public class ErlangErrorRpcException extends OtpException {
|
||||
|
||||
private OtpErlangTuple reasonTuple;
|
||||
|
||||
|
||||
public ErlangErrorRpcException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
public ErlangErrorRpcException(OtpErlangTuple tuple) {
|
||||
super(tuple.toString());
|
||||
this.reasonTuple = tuple;
|
||||
@@ -40,5 +40,5 @@ public class ErlangErrorRpcException extends OtpException {
|
||||
return reasonTuple;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.erlang;
|
||||
|
||||
/**
|
||||
* Runtime exception mirroring the OTP OtpAuthException.
|
||||
*
|
||||
*
|
||||
* @author Mark Pollack
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.erlang;
|
||||
|
||||
/**
|
||||
* Base RuntimeException for errors that occur when executing OTP operations.
|
||||
*
|
||||
*
|
||||
* @author Mark Pollack
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.IOException;
|
||||
/**
|
||||
* RuntimeException wrapper for an {@link IOException} which
|
||||
* can be commonly thrown from OTP operations.
|
||||
*
|
||||
*
|
||||
* @author Mark Pollack
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,7 @@ 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")
|
||||
|
||||
@@ -26,11 +26,11 @@ import com.ericsson.otp.erlang.OtpErlangObject;
|
||||
/**
|
||||
* A simple interface that is used to wrap access to the OtpConnection class in order to support
|
||||
* caching of OptConnections 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 OtpConnection, use the method getTargetConnection
|
||||
* on the interface ConnectionProxy that is implemented by DefaultConnection.
|
||||
*
|
||||
*
|
||||
* @author Mark Pollack
|
||||
*
|
||||
*/
|
||||
@@ -40,20 +40,20 @@ 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:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* { self, { call, Mod, Fun, Args, user } }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Note that this method has unpredicatble results if the remote node is not
|
||||
* an Erlang node.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param mod
|
||||
* the name of the Erlang module containing the function to
|
||||
* be called.
|
||||
@@ -62,38 +62,38 @@ public interface Connection {
|
||||
* @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:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* { rex, Term }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ import com.ericsson.otp.erlang.OtpConnection;
|
||||
|
||||
/**
|
||||
* An interface based ConnectionFactory for creating {@link OtpConnection}s.
|
||||
*
|
||||
*
|
||||
* <p>NOTE: The Rabbit API contains a ConnectionFactory class (same name).
|
||||
*
|
||||
*
|
||||
* @author Mark Pollack
|
||||
*/
|
||||
public interface ConnectionFactory {
|
||||
|
||||
Connection createConnection() throws UnknownHostException, OtpAuthException, IOException;
|
||||
Connection createConnection() throws UnknownHostException, OtpAuthException, IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -42,5 +42,5 @@ public class ConnectionFactoryUtils {
|
||||
logger.debug("Could not close Otp Connection", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ import com.ericsson.otp.erlang.OtpSelf;
|
||||
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");
|
||||
Assert.notNull(otpPeer, "OtpPeer must be non-null");
|
||||
this.otpSelf = otpSelf;
|
||||
this.otpPeer = otpPeer;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ 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
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -31,20 +31,20 @@ import com.ericsson.otp.erlang.OtpErlangObject;
|
||||
public class DefaultConnection implements ConnectionProxy {
|
||||
|
||||
private OtpConnection otpConnection;
|
||||
|
||||
|
||||
|
||||
|
||||
public DefaultConnection(OtpConnection otpConnection) {
|
||||
this.otpConnection = otpConnection;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
otpConnection.close();
|
||||
otpConnection.close();
|
||||
}
|
||||
|
||||
public void sendRPC(String mod, String fun, OtpErlangList args)
|
||||
throws IOException {
|
||||
otpConnection.sendRPC(mod, fun, args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public OtpErlangObject receiveRPC() throws IOException, OtpErlangExit,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -51,14 +51,14 @@ import com.ericsson.otp.erlang.OtpSelf;
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
@@ -81,7 +81,7 @@ public class SimpleConnectionFactory implements ConnectionFactory, InitializingB
|
||||
private final String peerNodeName;
|
||||
|
||||
private final String cookie;
|
||||
|
||||
|
||||
private OtpSelf otpSelf;
|
||||
|
||||
private OtpPeer otpPeer;
|
||||
|
||||
@@ -40,10 +40,10 @@ 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.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
@@ -58,7 +58,7 @@ import com.ericsson.otp.erlang.OtpSelf;
|
||||
* however Jinterface makes no distinction. See the Erlang documentation for
|
||||
* more information about nodenames.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
@@ -66,7 +66,7 @@ import com.ericsson.otp.erlang.OtpSelf;
|
||||
* host will be appended, resulting in a shortname. Nodenames longer than 255
|
||||
* characters will be truncated without warning.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
@@ -76,14 +76,14 @@ import com.ericsson.otp.erlang.OtpSelf;
|
||||
* using the system property "user.home", which may not be automatically set on
|
||||
* all platforms.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Mark Pollack
|
||||
*/
|
||||
public class SingleConnectionFactory implements ConnectionFactory,
|
||||
InitializingBean, DisposableBean {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
|
||||
private boolean uniqueSelfNodeName = true;
|
||||
|
||||
private String selfNodeName;
|
||||
@@ -116,7 +116,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
this.selfNodeName = selfNodeName;
|
||||
this.peerNodeName = peerNodeName;
|
||||
}
|
||||
|
||||
|
||||
public boolean isUniqueSelfNodeName() {
|
||||
return uniqueSelfNodeName;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
this.connection = getSharedConnectionProxy(this.targetConnection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close the underlying shared connection.
|
||||
* The provider of this ConnectionFactory needs to care for proper shutdown.
|
||||
@@ -166,7 +166,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
public void destroy() {
|
||||
resetConnection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the underlying shared Connection, to be reinitialized on next access.
|
||||
*/
|
||||
@@ -182,7 +182,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
|
||||
/**
|
||||
* Close the given Connection.
|
||||
*
|
||||
*
|
||||
* @param connection
|
||||
* the Connection to close
|
||||
*/
|
||||
@@ -202,7 +202,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
|
||||
/**
|
||||
* Create a JInterface Connection via this class's ConnectionFactory.
|
||||
*
|
||||
*
|
||||
* @return the new Otp Connection
|
||||
* @throws OtpAuthException
|
||||
*/
|
||||
@@ -219,7 +219,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
* 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
|
||||
@@ -235,7 +235,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see
|
||||
* org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
@@ -246,7 +246,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
if (isUniqueSelfNodeName()) {
|
||||
selfNodeNameToUse = this.selfNodeName + "-" + UUID.randomUUID().toString();
|
||||
logger.debug("Creating OtpSelf with node name = [" + selfNodeNameToUse + "]");
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (this.cookie == null) {
|
||||
this.otpSelf = new OtpSelf(selfNodeNameToUse.trim());
|
||||
@@ -256,7 +256,7 @@ public class SingleConnectionFactory implements ConnectionFactory,
|
||||
} catch (IOException e) {
|
||||
throw new OtpIOException(e);
|
||||
}
|
||||
this.otpPeer = new OtpPeer(this.peerNodeName.trim());
|
||||
this.otpPeer = new OtpPeer(this.peerNodeName.trim());
|
||||
}
|
||||
|
||||
private class SharedConnectionInvocationHandler implements
|
||||
|
||||
@@ -21,9 +21,9 @@ 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.
|
||||
*
|
||||
*
|
||||
* See http://www.erlang.org/doc/man/app.html for full details
|
||||
*
|
||||
*
|
||||
* @author Mark Pollack
|
||||
*
|
||||
*/
|
||||
@@ -31,9 +31,9 @@ import java.io.Serializable;
|
||||
public class Application implements Serializable {
|
||||
|
||||
private String description;
|
||||
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
private String version;
|
||||
|
||||
public Application(String description, String id, String version) {
|
||||
@@ -63,5 +63,5 @@ public class Application implements Serializable {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.erlang.connection.Connection;
|
||||
public interface ConnectionCallback<T> {
|
||||
|
||||
/**
|
||||
* Execute any number of operations against the supplied OTP connection,
|
||||
* Execute any number of operations against the supplied OTP connection,
|
||||
* possibly returning a result.
|
||||
*/
|
||||
T doInConnection(Connection connection) throws Exception; //Not sure everything it throws
|
||||
|
||||
@@ -31,16 +31,16 @@ import com.ericsson.otp.erlang.OtpErlangObject;
|
||||
public interface ErlangOperations {
|
||||
|
||||
<T> T execute(ConnectionCallback<T> action) throws OtpException;
|
||||
|
||||
|
||||
OtpErlangObject executeErlangRpc(String module, String function, OtpErlangList args) throws OtpException;
|
||||
|
||||
|
||||
|
||||
|
||||
OtpErlangObject executeErlangRpc(String module, String function, OtpErlangObject... args) throws OtpException;
|
||||
|
||||
|
||||
|
||||
|
||||
OtpErlangObject executeRpc(String module, String function, Object... args) throws OtpException;
|
||||
|
||||
|
||||
Object executeAndConvertRpc(String module, String function, ErlangConverter converterToUse, Object... args) throws OtpException;
|
||||
|
||||
|
||||
Object executeAndConvertRpc(String module, String function, Object... args) throws OtpException;
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ public class ErlangTemplate extends ErlangAccessor implements ErlangOperations {
|
||||
setConnectionFactory(connectionFactory);
|
||||
afterPropertiesSet();
|
||||
}
|
||||
|
||||
|
||||
public OtpErlangObject executeErlangRpc(final String module, final String function, final OtpErlangList args) {
|
||||
return execute(new ConnectionCallback<OtpErlangObject>() {
|
||||
public OtpErlangObject doInConnection(Connection connection) throws Exception {
|
||||
public OtpErlangObject doInConnection(Connection connection) throws Exception {
|
||||
logger.debug("Sending RPC for module [" + module + "] function [" + function + "] args [" + args);
|
||||
connection.sendRPC(module, function, args);
|
||||
connection.sendRPC(module, function, args);
|
||||
//TODO consider dedicated response object.
|
||||
OtpErlangObject response = connection.receiveRPC();
|
||||
logger.debug("Response received = " + response.toString());
|
||||
@@ -56,7 +56,7 @@ public class ErlangTemplate extends ErlangAccessor implements ErlangOperations {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void handleResponseError(String module, String function, OtpErlangObject result) {
|
||||
//{badrpc,{'EXIT',{undef,[{rabbit_access_control,list_users,[[]]},{rpc,'-handle_call/3-fun-0-',5}]}}}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ErlangTemplate extends ErlangAccessor implements ErlangOperations {
|
||||
{
|
||||
OtpErlangAtom responseAtom = (OtpErlangAtom)msg.elementAt(0);
|
||||
//TODO consider error handler strategy.
|
||||
if (responseAtom.atomValue().equals("badrpc")) {
|
||||
if (responseAtom.atomValue().equals("badrpc")) {
|
||||
if (msg.elementAt(1) instanceof OtpErlangTuple) {
|
||||
throw new ErlangBadRpcException( (OtpErlangTuple)msg.elementAt(1));
|
||||
} else {
|
||||
@@ -82,23 +82,23 @@ public class ErlangTemplate extends ErlangAccessor implements ErlangOperations {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public OtpErlangObject executeErlangRpc(String module, String function, OtpErlangObject... args) {
|
||||
return executeRpc(module, function, new OtpErlangList(args));
|
||||
}
|
||||
|
||||
|
||||
public OtpErlangObject executeRpc(String module, String function, Object... args) {
|
||||
return executeErlangRpc(module, function, (OtpErlangList) erlangConverter.toErlang(args));
|
||||
}
|
||||
|
||||
|
||||
public Object executeAndConvertRpc(String module, String function, ErlangConverter converterToUse, Object... args) {
|
||||
return converterToUse.fromErlang(executeRpc(module, function, converterToUse.toErlang(args)));
|
||||
}
|
||||
|
||||
public Object executeAndConvertRpc(String module, String function, Object... args) {
|
||||
|
||||
public Object executeAndConvertRpc(String module, String function, Object... args) {
|
||||
return erlangConverter.fromErlangRpc(module, function, executeErlangRpc(module, function, (OtpErlangList)erlangConverter.toErlang(args)));
|
||||
}
|
||||
|
||||
|
||||
public ErlangConverter getErlangConverter() {
|
||||
return erlangConverter;
|
||||
}
|
||||
@@ -111,23 +111,23 @@ public class ErlangTemplate extends ErlangAccessor implements ErlangOperations {
|
||||
|
||||
Assert.notNull(action, "Callback object must not be null");
|
||||
Connection con = null;
|
||||
try {
|
||||
try {
|
||||
con = createConnection();
|
||||
return action.doInConnection(con);
|
||||
}
|
||||
}
|
||||
catch (OtpException ex) {
|
||||
throw ex;
|
||||
throw ex;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw convertOtpAccessException(ex);
|
||||
throw convertOtpAccessException(ex);
|
||||
}
|
||||
finally {
|
||||
org.springframework.erlang.connection.ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory());
|
||||
finally {
|
||||
org.springframework.erlang.connection.ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory());
|
||||
}
|
||||
// TODO: physically close and reopen the connection if there is an exception
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert the specified checked exception to
|
||||
* a Spring runtime exception equivalent.
|
||||
@@ -144,10 +144,10 @@ public class ErlangTemplate extends ErlangAccessor implements ErlangOperations {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Describes an Erlang node.
|
||||
* Describes an Erlang node.
|
||||
*/
|
||||
package org.springframework.erlang.core;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Simple description class for an Erlang node.
|
||||
*
|
||||
*
|
||||
* @author Mark Pollack
|
||||
*
|
||||
*/
|
||||
@@ -44,5 +44,5 @@ public class Node implements Serializable {
|
||||
public String toString() {
|
||||
return "Node [name=" + name + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,26 +38,26 @@ public abstract class ErlangAccessor implements InitializingBean {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -40,17 +40,17 @@ public class ErlangUtils {
|
||||
if (con == null) {
|
||||
return;
|
||||
}
|
||||
con.close();
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ 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.
|
||||
*
|
||||
* Converter between Java and Erlang Types. Additional support for converting results from RPC calls.
|
||||
*
|
||||
* @author Mark Pollack
|
||||
*/
|
||||
public interface ErlangConverter {
|
||||
@@ -40,6 +40,6 @@ public interface ErlangConverter {
|
||||
* @throws ErlangConversionException in case of conversion failure
|
||||
*/
|
||||
Object fromErlang(OtpErlangObject erlangObject) throws ErlangConversionException;
|
||||
|
||||
|
||||
Object fromErlangRpc(String module, String function, OtpErlangObject erlangObject) throws ErlangConversionException;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.ericsson.otp.erlang.OtpErlangString;
|
||||
/**
|
||||
* Converter that supports the basic types and arrays.
|
||||
* @author Mark Pollack
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SimpleErlangConverter implements ErlangConverter {
|
||||
|
||||
@@ -129,9 +129,9 @@ public class SimpleErlangConverter implements ErlangConverter {
|
||||
} else if (erlangObject instanceof OtpErlangShort) {
|
||||
return ((OtpErlangShort) erlangObject).shortValue();
|
||||
} else if (erlangObject instanceof OtpErlangString) {
|
||||
return ((OtpErlangString) erlangObject).stringValue();
|
||||
return ((OtpErlangString) erlangObject).stringValue();
|
||||
} else if (erlangObject instanceof OtpErlangPid) {
|
||||
return ((OtpErlangPid) erlangObject).toString();
|
||||
return ((OtpErlangPid) erlangObject).toString();
|
||||
} else {
|
||||
throw new ErlangConversionException(
|
||||
"Could not convert Erlang object ["
|
||||
@@ -147,7 +147,7 @@ public class SimpleErlangConverter implements ErlangConverter {
|
||||
public static boolean extractBoolean(OtpErlangObject erlangObject) {
|
||||
return ((OtpErlangBoolean) erlangObject).booleanValue();
|
||||
}
|
||||
|
||||
|
||||
public static String extractPid(OtpErlangObject value) {
|
||||
return ((OtpErlangPid)value).toString();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Class to execute processes in the background. These processes
|
||||
* will not exit once the controlling Java process exits.
|
||||
* will not exit once the controlling Java process exits.
|
||||
*/
|
||||
public class Background {
|
||||
/**
|
||||
@@ -33,9 +33,9 @@ public class Background {
|
||||
throws IOException
|
||||
{
|
||||
File devNull;
|
||||
if(Os.isFamily("unix"))
|
||||
if(Os.isFamily("unix"))
|
||||
devNull = new File("/dev/null");
|
||||
else if (Os.isFamily("windows"))
|
||||
else if (Os.isFamily("windows"))
|
||||
devNull = new File("NUL");
|
||||
else
|
||||
throw new IllegalStateException("Unhandled Java environment");
|
||||
@@ -49,10 +49,10 @@ public class Background {
|
||||
* @param appendOut If true, append the file with standard out,
|
||||
* else truncate or create a new file
|
||||
* @param errFile File to send standard err from the process to
|
||||
* @param appendErr If true, append the file with standard error,
|
||||
* @param appendErr If true, append the file with standard error,
|
||||
* else truncate or create a new file
|
||||
*/
|
||||
public static void exec(String[] cmd,
|
||||
public static void exec(String[] cmd,
|
||||
File outFile, boolean appendOut,
|
||||
File errFile, boolean appendErr)
|
||||
throws IOException
|
||||
@@ -65,8 +65,8 @@ public class Background {
|
||||
throw new IllegalStateException("Unhandled Java environment");
|
||||
}
|
||||
|
||||
private static void execUnix(String[] cmd,
|
||||
File outFile, boolean appendOut,
|
||||
private static void execUnix(String[] cmd,
|
||||
File outFile, boolean appendOut,
|
||||
File errFile, boolean appendErr)
|
||||
throws IOException
|
||||
{
|
||||
@@ -82,11 +82,11 @@ public class Background {
|
||||
execCmd = new String[] {
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
escaped.toString() +
|
||||
(appendOut == true ? ">>" : ">") +
|
||||
escaped.toString() +
|
||||
(appendOut == true ? ">>" : ">") +
|
||||
Escape.escape(outFile.getAbsolutePath()) +
|
||||
" 2" + (appendErr == true ? ">>" : " >") +
|
||||
Escape.escape(errFile.getAbsolutePath()) +
|
||||
Escape.escape(errFile.getAbsolutePath()) +
|
||||
" </dev/null &"
|
||||
};
|
||||
|
||||
@@ -99,8 +99,8 @@ public class Background {
|
||||
}
|
||||
}
|
||||
|
||||
private static void execWin(String[] cmd,
|
||||
File outFile, boolean appendOut,
|
||||
private static void execWin(String[] cmd,
|
||||
File outFile, boolean appendOut,
|
||||
File errFile, boolean appendErr)
|
||||
throws IOException
|
||||
{
|
||||
@@ -115,11 +115,11 @@ public class Background {
|
||||
for(int i=0; i<cmd.length; i++){
|
||||
tmpCmd.add(cmd[i]);
|
||||
}
|
||||
tmpCmd.add((appendOut == true ? ">>" : ">") +
|
||||
tmpCmd.add((appendOut == true ? ">>" : ">") +
|
||||
Escape.escape(outFile.getAbsolutePath()));
|
||||
tmpCmd.add((outFile.equals(errFile) ? " 2&" : " 2") +
|
||||
tmpCmd.add((outFile.equals(errFile) ? " 2&" : " 2") +
|
||||
(appendErr == true ? ">>" : " >") +
|
||||
Escape.escape(errFile.getAbsolutePath()));
|
||||
Escape.escape(errFile.getAbsolutePath()));
|
||||
|
||||
Runtime.getRuntime().exec(tmpCmd.toArray(cmd));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Escape {
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string by quoting the magical elements
|
||||
* Escape a string by quoting the magical elements
|
||||
* (such as whitespace, quotes, slashes, etc.)
|
||||
*/
|
||||
public static String escape(String in){
|
||||
@@ -42,7 +42,7 @@ public class Escape {
|
||||
if(outChars.length - numOut < 5){
|
||||
outChars = enlargeArray(outChars);
|
||||
}
|
||||
|
||||
|
||||
if(Character.isWhitespace(inChars[i]) ||
|
||||
inChars[i] == '\\' ||
|
||||
inChars[i] == '\'' ||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -28,8 +28,8 @@ import org.apache.commons.logging.LogFactory;
|
||||
* 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
|
||||
*/
|
||||
@@ -133,7 +133,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.
|
||||
*/
|
||||
public Execute(ExecuteStreamHandler streamHandler) {
|
||||
@@ -142,7 +142,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 watchdog a watchdog for the subprocess or <code>null</code> to to disable a timeout for the subprocess.
|
||||
*/
|
||||
@@ -153,7 +153,7 @@ public class Execute {
|
||||
|
||||
/**
|
||||
* Returns the commandline used to create a subprocess.
|
||||
*
|
||||
*
|
||||
* @return the commandline used to create a subprocess
|
||||
*/
|
||||
public String[] getCommandline() {
|
||||
@@ -166,7 +166,7 @@ public class Execute {
|
||||
|
||||
/**
|
||||
* Sets the commandline of the subprocess to launch.
|
||||
*
|
||||
*
|
||||
* @param commandline the commandline of the subprocess to launch
|
||||
*/
|
||||
public void setCommandline(String[] commandline) {
|
||||
@@ -175,7 +175,7 @@ public class Execute {
|
||||
|
||||
/**
|
||||
* Set whether to propagate the default environment or not.
|
||||
*
|
||||
*
|
||||
* @param newenv whether to propagate the process environment.
|
||||
*/
|
||||
public void setNewenvironment(boolean newenv) {
|
||||
@@ -184,7 +184,7 @@ public class Execute {
|
||||
|
||||
/**
|
||||
* Returns the environment used to create a subprocess.
|
||||
*
|
||||
*
|
||||
* @return the environment used to create a subprocess
|
||||
*/
|
||||
public String[] getEnvironment() {
|
||||
@@ -195,7 +195,7 @@ 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
|
||||
* <em>key=value</em>
|
||||
*/
|
||||
@@ -205,10 +205,10 @@ public class Execute {
|
||||
|
||||
/**
|
||||
* Sets the working directory of the process to execute.
|
||||
*
|
||||
*
|
||||
* <p> 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) {
|
||||
@@ -217,7 +217,7 @@ public class Execute {
|
||||
|
||||
/**
|
||||
* Runs a process defined by the command line and returns its exit status.
|
||||
*
|
||||
*
|
||||
* @return the exit status of the subprocess or <code>INVALID</code>
|
||||
* @throws Exception if launching of the subprocess failed
|
||||
*/
|
||||
@@ -300,7 +300,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
|
||||
*/
|
||||
public int getExitValue() {
|
||||
@@ -309,7 +309,7 @@ public class Execute {
|
||||
|
||||
/**
|
||||
* Patch the current environment with the new values from the user.
|
||||
*
|
||||
*
|
||||
* @return the patched environment
|
||||
*/
|
||||
private String[] patchEnvironment() {
|
||||
@@ -349,7 +349,7 @@ public class Execute {
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
||||
@@ -29,13 +29,13 @@ package org.springframework.util.exec;
|
||||
* // it was killed on purpose by the watchdog
|
||||
* }
|
||||
* </pre>
|
||||
|
||||
|
||||
* @author thomas.haas@softwired-inc.com
|
||||
* @author <a href="mailto:sbailliez@imediation.com">Stephane Bailliez</a>
|
||||
* @see Execute
|
||||
*/
|
||||
public class ExecuteWatchdog implements Runnable {
|
||||
|
||||
|
||||
/** the process to execute and watch for duration */
|
||||
private Process process;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ExecuteWatchdog implements Runnable {
|
||||
|
||||
/** 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;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ExecuteWatchdog implements Runnable {
|
||||
public void setDontkill( boolean b ) {
|
||||
dontkill=b;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Watches the given process and terminates it, if it runs for too long.
|
||||
* All information from the previous run are reset.
|
||||
@@ -143,7 +143,7 @@ public class ExecuteWatchdog implements Runnable {
|
||||
cleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* reset the monitor flag and the process.
|
||||
|
||||
Reference in New Issue
Block a user