sige 1 year ago
parent
commit
6d4e3e5a28
  1. 2
      pom.xml
  2. 2
      src/main/java/com/iflytop/uf/connection/UfZcancmderWebsocket.java
  3. 16
      src/main/java/com/iflytop/uf/util/UfClassHelper.java

2
pom.xml

@ -10,7 +10,7 @@
</parent>
<groupId>com.iflytop</groupId>
<artifactId>uf</artifactId>
<version>0.0.64</version>
<version>0.0.66</version>
<name>uf</name>
<description>uf</description>
<properties>

2
src/main/java/com/iflytop/uf/connection/UfZcancmderWebsocket.java

@ -87,7 +87,7 @@ public class UfZcancmderWebsocket extends UfConnectionBase {
returnValue = (String) UfClassHelper.invokeMethod(this, methodName, List.of(command));
} catch (NoSuchMethodException e) {
returnValue = this.executeDeviceCommand(command);
} catch (Exception e) {
} catch (Throwable e) {
throw new RuntimeException(e);
}
return returnValue;

16
src/main/java/com/iflytop/uf/util/UfClassHelper.java

@ -40,18 +40,22 @@ public class UfClassHelper {
}
// invoke method
public static Object invokeMethod(Object obj, String methodName, List<Object> args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
public static Object invokeMethod(Object obj, String methodName, List<Object> args) throws Throwable {
Class<?>[] parameterTypes = new Class<?>[args.size()];
for (int i = 0; i < args.size(); i++) {
parameterTypes[i] = args.get(i).getClass();
}
Method method = obj.getClass().getMethod(methodName, parameterTypes);
if ( method.getReturnType().equals(Void.TYPE) ) {
method.invoke(obj, args.toArray());
return null;
} else {
return method.invoke(obj, args.toArray());
try {
if ( method.getReturnType().equals(Void.TYPE) ) {
method.invoke(obj, args.toArray());
return null;
} else {
return method.invoke(obj, args.toArray());
}
} catch ( Exception e ) {
throw e.getCause();
}
}

Loading…
Cancel
Save