1 15 package org.apache.hivemind.lib.pipeline; 16 17 import org.apache.hivemind.service.MethodSignature; 18 19 26 class FilterMethodAnalyzer 27 { 28 private Class _serviceInterface; 29 30 FilterMethodAnalyzer(Class serviceInterface) 31 { 32 _serviceInterface = serviceInterface; 33 } 34 35 public int findServiceInterfacePosition(MethodSignature ms, MethodSignature fms) 36 { 37 if (ms.getReturnType() != fms.getReturnType()) 38 return -1; 39 40 if (!ms.getName().equals(fms.getName())) 41 return -1; 42 43 Class [] filterParameters = fms.getParameterTypes(); 44 int filterParameterCount = filterParameters.length; 45 Class [] serviceParameters = ms.getParameterTypes(); 46 47 if (filterParameterCount != (serviceParameters.length + 1)) 48 return -1; 49 50 52 56 boolean found = false; 57 int result = -1; 58 59 for (int i = 0; i < filterParameterCount; i++) 60 { 61 if (filterParameters[i] == _serviceInterface) 62 { 63 result = i; 64 found = true; 65 break; 66 } 67 } 68 69 if (!found) 70 return -1; 71 72 75 for (int i = 0; i < result; i++) 76 { 77 if (filterParameters[i] != serviceParameters[i]) 78 return -1; 79 } 80 81 for (int i = result + 1; i < filterParameterCount; i++) 82 { 83 if (filterParameters[i] != serviceParameters[i - 1]) 84 return -1; 85 } 86 87 return result; 88 } 89 90 } 91 | Popular Tags |