1 22 package org.jboss.iiop.rmi; 23 24 import java.rmi.Remote ; 25 import java.rmi.RemoteException ; 26 27 import java.lang.reflect.Method ; 28 29 import java.util.ArrayList ; 30 31 32 41 public class OperationAnalysis 42 extends AbstractAnalysis 43 { 44 46 48 50 private static final org.jboss.logging.Logger logger = 51 org.jboss.logging.Logger.getLogger(OperationAnalysis.class); 52 53 55 OperationAnalysis(Method method) 56 throws RMIIIOPViolationException 57 { 58 super(method.getName()); 59 logger.debug("new OperationAnalysis: " + method.getName()); 60 this.method = method; 61 62 Class retCls = method.getReturnType(); 64 if (retCls.isInterface() && Remote .class.isAssignableFrom(retCls)) 65 Util.isValidRMIIIOP(retCls); 66 67 Class [] ex = method.getExceptionTypes(); 69 boolean gotRemoteException = false; 70 ArrayList a = new ArrayList (); 71 for (int i = 0; i < ex.length; ++i) { 72 if (ex[i].isAssignableFrom(java.rmi.RemoteException .class)) 73 gotRemoteException = true; 74 if (Exception .class.isAssignableFrom(ex[i]) && 75 !RuntimeException .class.isAssignableFrom(ex[i]) && 76 !RemoteException .class.isAssignableFrom(ex[i]) ) 77 a.add(ExceptionAnalysis.getExceptionAnalysis(ex[i])); } 79 if (!gotRemoteException && 80 Remote .class.isAssignableFrom(method.getDeclaringClass())) 81 throw new RMIIIOPViolationException( 82 "All interface methods must throw java.rmi.RemoteException, " + 83 "or a superclass of java.rmi.RemoteException, but method " + 84 getJavaName() + " of interface " + 85 method.getDeclaringClass().getName() + " does not.", "1.2.3"); 86 mappedExceptions = new ExceptionAnalysis[a.size()]; 87 mappedExceptions = (ExceptionAnalysis[])a.toArray(mappedExceptions); 88 89 Class [] params = method.getParameterTypes(); 91 parameters = new ParameterAnalysis[params.length]; 92 for (int i = 0; i < params.length; ++i) { 93 logger.debug("OperationAnalysis: " + method.getName() + 94 " has parameter [" + params[i].getName() + "]"); 95 parameters[i] = new ParameterAnalysis("param" + (i+1), params[i]); 96 } 97 } 98 99 101 104 public Class getReturnType() 105 { 106 return method.getReturnType(); 107 } 108 109 112 public Method getMethod() 113 { 114 return method; 115 } 116 117 120 public ExceptionAnalysis[] getMappedExceptions() 121 { 122 return (ExceptionAnalysis[])mappedExceptions.clone(); 123 } 124 125 128 public ParameterAnalysis[] getParameters() 129 { 130 return (ParameterAnalysis[])parameters.clone(); 131 } 132 133 135 137 140 private Method method; 141 142 145 private ExceptionAnalysis[] mappedExceptions; 146 147 150 private ParameterAnalysis[] parameters; 151 152 } 153 | Popular Tags |