44
55import org .apache .commons .logging .Log ;
66import org .apache .commons .logging .LogFactory ;
7- import org .ros .internal .transport .tcp .TcpRosServer ;
87
98/**
109* The remote call mechanism depends on Java reflection to provide access to methods that can be
1312* This class handles reflection of the user requests to call designated methods in the server side classes,
1413* It starts by populating a table of those methods, and at runtime, creates a method call transport for client,
1514* and provides for server-side invocation of those methods.
16- * Option to skip leading arguments for whatever reason is provided.
17- * @author Groff Copyright (C) NeoCoreTechs 1998-2000, 2015
15+ * Option to skip leading arguments for whatever reason is provided.
16+ * @author Groff Copyright (C) NeoCoreTechs 1998-2000, 2015, 2017
1817*/
1918public final class ServerInvokeMethod {
2019 private static final boolean DEBUG = false ;
@@ -30,7 +29,7 @@ public final class ServerInvokeMethod {
3029 * designated class. Reflect hierarchy in reverse (to get proper
3130 * overload) and look for methods
3231 * @param tclass The class name we are targeting
33- * @param skipArgs > 0 if we want to skip first args.
32+ * @param tskipArgs > 0 if we want to skip first args.
3433 */
3534 public ServerInvokeMethod (String tclass , int tskipArgs ) throws ClassNotFoundException {
3635 pkmnap .classClass = Class .forName (tclass );
@@ -41,9 +40,9 @@ public ServerInvokeMethod(String tclass, int tskipArgs) throws ClassNotFoundExce
4140 Method m [];
4241 m = pkmnap .classClass .getMethods ();
4342 for (int i = m .length -1 ; i >= 0 ; i --) {
44- //if( m[i].getName().startsWith("Relatrix_ ") ) {
45- pkmnap .methodNames .add (m [i ].getName ()/*.substring(9 )*/ );
46- log .info ("Method :" +m [i ].getName ()/*.substring(9 )*/ );
43+ //if( m[i].getName().startsWith("Reflect_ ") ) {
44+ pkmnap .methodNames .add (m [i ].getName ()/*.substring(8 )*/ );
45+ log .info ("Method :" +m [i ].getName ()/*.substring(8 )*/ );
4746 //}
4847 }
4948 // create arrays
@@ -54,14 +53,14 @@ public ServerInvokeMethod(String tclass, int tskipArgs) throws ClassNotFoundExce
5453 int methCnt = 0 ;
5554 //
5655 for (int i = m .length -1 ; i >= 0 ; i --) {
57- //if( m[i].getName().startsWith("Relatrix_ ") ) {
56+ //if( m[i].getName().startsWith("Reflect_ ") ) {
5857 pkmnap .methodParams [methCnt ] = m [i ].getParameterTypes ();
5958 pkmnap .methodSigs [methCnt ] = m [i ].toString ();
6059 pkmnap .returnTypes [methCnt ] = m [i ].getReturnType ();
6160 if ( pkmnap .returnTypes [methCnt ] == void .class )
6261 pkmnap .returnTypes [methCnt ] = Void .class ;
63- //int ind1 = pkmnap.methodSigs[methCnt].indexOf("Relatrix_ ");
64- //pkmnap.methodSigs[methCnt] = pkmnap.methodSigs[methCnt].substring(0,ind1)+pkmnap.methodSigs[methCnt].substring(ind1+9 );
62+ //int ind1 = pkmnap.methodSigs[methCnt].indexOf("Reflect_ ");
63+ //pkmnap.methodSigs[methCnt] = pkmnap.methodSigs[methCnt].substring(0,ind1)+pkmnap.methodSigs[methCnt].substring(ind1+8 );
6564 if ( skipArgs > 0 ) {
6665 try {
6766 int ind1 = pkmnap .methodSigs [methCnt ].indexOf ("(" );
@@ -88,18 +87,20 @@ public Object invokeMethod(RemoteRequestInterface tmc) throws Exception {
8887 return invokeMethod (tmc , null );
8988 }
9089 /**
91- * For an incoming RelatrixStatement, verify and invoke the proper
92- * method. We assume there is a table of class names and this and
93- * it has been used to locate this object.
90+ * For an incoming RemoteRequestInterface implementor of a concrete composition, verify and invoke the proper
91+ * method. We assume there is a table of class names and method params properly populated. Compare the
92+ * method signatures in the RemoteRequest to the table, if a match, invoke the method on localObject.
93+ * If skipArgs, a class variable, is not zero, the first number of skipArgs parameters in the method
94+ * described by RemoteRequest will not be compared against table entry, but the values will be passed into
95+ * the method upon invocation.
9496 * @return Object of result of method invocation
9597 */
9698 public Object invokeMethod (RemoteRequestInterface tmc , Object localObject ) throws Exception {
97- //NoSuchMethodException, InvocationTargetException, IllegalAccessException, PowerSpaceException {
99+ //NoSuchMethodException, InvocationTargetException, IllegalAccessException {
98100 String targetMethod = tmc .getMethodName ();
99101 int methodIndex = pkmnap .methodNames .indexOf (targetMethod );
100102 String whyNotFound = "No such method" ;
101103 while ( methodIndex != -1 && methodIndex < pkmnap .methodNames .size ()) {
102- // System.out.println(jj);
103104 Class [] params = tmc .getParams ();
104105 //
105106 //
0 commit comments