OW2 Consortium joram

Compare Revisions

Ignore whitespace Rev 6574 → Rev 6575

/trunk/joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/dest/AdminTopic.java
1,6 → 1,6
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2016 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2018 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
27,6 → 27,7
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
1658,6 → 1659,7
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "AdminTopic.invokeStaticMethod(" + prop + ")");
 
boolean async = Boolean.parseBoolean(prop.getProperty(AdminCommandConstant.INVOKE_ASYNC));
String className = prop.getProperty(AdminCommandConstant.INVOKE_CLASS_NAME);
if (className == null) {
throw new IllegalArgumentException("Class name property must be specified to invoke method.");
1670,7 → 1672,7
int i = 0;
String paramType;
List paramClasses = new ArrayList();
List paramValues = new ArrayList();
final List paramValues = new ArrayList();
while ((paramType = prop.getProperty(AdminCommandConstant.INVOKE_METHOD_ARG + i)) != null) {
String paramValue = prop.getProperty(AdminCommandConstant.INVOKE_METHOD_ARG_VALUE + i);
if (paramType.equals(Integer.TYPE.getName())) {
1761,12 → 1763,26
}
 
Class<?> clazz = Class.forName(className);
Method method = clazz.getMethod(methodName,
final Method method = clazz.getMethod(methodName,
(Class[]) paramClasses.toArray(new Class[paramClasses.size()]));
if (! Modifier.isStatic(method.getModifiers()))
throw new IllegalArgumentException("Specified method must be static: " + method);
 
return method.invoke(null, paramValues.toArray());
if (async) {
Thread thread = new Thread() {
public void run() {
try {
method.invoke(null, paramValues.toArray());
} catch (Exception exc) {
logger.log(BasicLevel.WARN, "AdminTopic.invokeStaticMethod: async invocation", exc);
}
}
};
thread.start();
return null;
} else {
return method.invoke(null, paramValues.toArray());
}
}
 
/**
/trunk/joram/joram/client/jms/src/main/java/org/objectweb/joram/client/jms/admin/JoramAdmin.java
1,6 → 1,6
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2005 - 2015 ScalAgent Distributed Technologies
* Copyright (C) 2005 - 2018 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
976,6 → 976,12
return wrapper.invokeStaticServerMethod(serverId, className, methodName, parameterTypes, args);
}
 
public String invokeStaticServerMethod(int serverId, String className,
String methodName, Class<?>[] parameterTypes, Object[] args, boolean async)
throws ConnectException, AdminException {
return wrapper.invokeStaticServerMethod(serverId, className, methodName, parameterTypes, args, async);
}
 
public String addAMQPBridgeConnection(int serverId, String urls)
throws ConnectException, AdminException {
return wrapper.addAMQPBridgeConnection(serverId, urls);
995,4 → 1001,9
throws ConnectException, AdminException {
return wrapper.deleteJMSPBridgeConnection(serverId, names);
}
 
public String deleteJMSPBridgeConnection(int serverId, String names, boolean async)
throws ConnectException, AdminException {
return wrapper.deleteJMSPBridgeConnection(serverId, names, async);
}
}
/trunk/joram/joram/client/jms/src/main/java/org/objectweb/joram/client/jms/admin/AdminWrapper.java
1,6 → 1,6
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2009 - 2015 ScalAgent Distributed Technologies
* Copyright (C) 2009 - 2018 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
1160,6 → 1160,7
* Invokes the specified static method with the specified parameters on the
* chosen server. The parameters types of the invoked method must be java
* primitive types, the java objects wrapping them or String type.
* The method is invoked synchronously by the server and the result is returned.
*
* @param serverId the identifier of the server.
* @param className the name of the class holding the static method
1172,6 → 1173,29
*/
public String invokeStaticServerMethod(int serverId, String className, String methodName,
Class<?>[] parameterTypes, Object[] args) throws ConnectException, AdminException {
return invokeStaticServerMethod(serverId, className, methodName, parameterTypes, args, false);
}
/**
* Invokes the specified static method with the specified parameters on the
* chosen server. The parameters types of the invoked method must be java
* primitive types, the java objects wrapping them or String type.
* The method can be invoked either asynchronously or not by the server depending
* of the parameter async.
*
* @param serverId the identifier of the server.
* @param className the name of the class holding the static method
* @param methodName the name of the invoked method
* @param parameterTypes the list of parameters
* @param args the arguments used for the method call
* @param async if true the method is invoked asynchronously by the server and the result is lost.
* @return the result of the invoked method after applying the toString method
* @throws ConnectException If the connection fails.
* @throws AdminException If the invocation can't be done or fails
*/
public String invokeStaticServerMethod(int serverId, String className, String methodName,
Class<?>[] parameterTypes, Object[] args, boolean async) throws ConnectException, AdminException {
 
if (parameterTypes == null && (args != null && args.length > 0)) {
throw new AdminException("Parameter types array is null while args array is not null or empty.");
1185,6 → 1209,7
Properties props = new Properties();
props.setProperty(AdminCommandConstant.INVOKE_CLASS_NAME, className);
props.setProperty(AdminCommandConstant.INVOKE_METHOD_NAME, methodName);
props.setProperty(AdminCommandConstant.INVOKE_ASYNC, "" + async);
if (parameterTypes != null) {
for (int i = 0; i < parameterTypes.length; i++) {
props.setProperty(AdminCommandConstant.INVOKE_METHOD_ARG + i, parameterTypes[i].getName());
1281,4 → 1306,23
new Class[] { String.class },
new Object[] { names });
}
/**
* Removes the live connection to the specified JMS server.
*
* @param serverId the serverId
* @param names the name identifying the server or list of name separate by space
* @param async invoke asynchronously
* @return the result of the method
* @throws ConnectException If the connection fails.
* @throws AdminException If the invocation can't be done or fails
*/
public String deleteJMSPBridgeConnection(int serverId, String names, boolean async) throws ConnectException, AdminException {
return invokeStaticServerMethod(
serverId,
"org.objectweb.joram.mom.dest.jms.JMSConnectionService",
"deleteServer",
new Class[] { String.class },
new Object[] { names }, async);
}
}
/trunk/joram/joram/client/jms/src/main/java/org/objectweb/joram/client/jms/admin/AdminModule.java
1,6 → 1,6
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2015 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2018 ScalAgent Distributed Technologies
* Copyright (C) 2004 Bull SA
*
* This library is free software; you can redistribute it and/or
1570,6 → 1570,30
 
/**
* Invokes the specified static method with the specified parameters on the
* local server. The parameters types of the invoked method must be java
* primitive types, the java objects wrapping them or String type.
* The method can be invoked either asynchronously or not by the server depending
* of the parameter async.
*
* @param className the name of the class holding the static method
* @param methodName the name of the invoked method
* @param parameterTypes the list of parameters
* @param args the arguments used for the method call
* @param async if true the method is invoked asynchronously by the server and the result is lost.
* @return the result of the invoked method after applying the toString method.
* @throws ConnectException If the connection fails.
* @throws AdminException If the invocation can't be done or fails
*/
public static String invokeStaticServerMethod(String className,
String methodName,
Class<?>[] parameterTypes,
Object[] args,
boolean async) throws ConnectException, AdminException {
return invokeStaticServerMethod(getLocalServerId(), className, methodName, parameterTypes, args, async);
}
 
/**
* Invokes the specified static method with the specified parameters on the
* chosen server. The parameters types of the invoked method must be java
* primitive types, the java objects wrapping them or String type.
*
1590,8 → 1614,37
if (wrapper == null)
throw new ConnectException("Administration connection is closed.");
 
return wrapper.invokeStaticServerMethod(serverId, className, methodName, parameterTypes, args);
return wrapper.invokeStaticServerMethod(serverId, className, methodName, parameterTypes, args);
}
 
/**
* Invokes the specified static method with the specified parameters on the
* chosen server. The parameters types of the invoked method must be java
* primitive types, the java objects wrapping them or String type.
* The method can be invoked either asynchronously or not by the server depending
* of the parameter async.
*
* @param serverId the identifier of the server.
* @param className the name of the class holding the static method
* @param methodName the name of the invoked method
* @param parameterTypes the list of parameters
* @param args the arguments used for the method call
* @param async if true the method is invoked asynchronously by the server and the result is lost.
* @return the result of the invoked method after applying the toString method
* @throws ConnectException If the connection fails.
* @throws AdminException If the invocation can't be done or fails
*/
public static String invokeStaticServerMethod(int serverId,
String className,
String methodName,
Class<?>[] parameterTypes,
Object[] args,
boolean async) throws ConnectException, AdminException {
if (wrapper == null)
throw new ConnectException("Administration connection is closed.");
 
return wrapper.invokeStaticServerMethod(serverId, className, methodName, parameterTypes, args, async);
}
/**
* Adds an AMQP server and starts a live connection with it, accessible via
1660,4 → 1713,20
throw new ConnectException("Administration connection is closed.");
return wrapper.deleteJMSPBridgeConnection(serverId, names);
}
/**
* Removes the live connection to the specified AMQP server.
*
* @param serverId the serverId
* @param names the name identifying the server or list of name separate by space
* @param async invoke asynchronously
* @return the result of the method
* @throws ConnectException If the connection fails.
* @throws AdminException If the invocation can't be done or fails
*/
public static String deleteJMSPBridgeConnection(int serverId, String names, boolean async) throws ConnectException, AdminException {
if (wrapper == null)
throw new ConnectException("Administration connection is closed.");
return wrapper.deleteJMSPBridgeConnection(serverId, names, async);
}
}
/trunk/joram/joram/shared/src/main/java/org/objectweb/joram/shared/admin/AdminCommandConstant.java
1,6 → 1,6
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2010 - 2016 ScalAgent Distributed Technologies
* Copyright (C) 2010 - 2018 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
74,6 → 74,9
public static final String INVOKE_METHOD_NAME = "jms_joram_invoke_method";
 
/** Used by AdminTopic to invoke a static method */
public static final String INVOKE_ASYNC = "jms_joram_invoke_async";
 
/** Used by AdminTopic to invoke a static method */
public static final String INVOKE_METHOD_ARG = "jms_joram_invoke_arg";
 
/** Used by AdminTopic to invoke a static method */