1 22 package org.jboss.iiop.rmi; 23 24 import java.util.ArrayList ; 25 import java.util.Map ; 26 import java.util.HashMap ; 27 28 29 38 public class InterfaceAnalysis 39 extends ContainerAnalysis 40 { 41 43 45 48 Map operationAnalysisMap; 49 50 52 private static final org.jboss.logging.Logger logger = 53 org.jboss.logging.Logger.getLogger(InterfaceAnalysis.class); 54 55 private static WorkCacheManager cache 56 = new WorkCacheManager(InterfaceAnalysis.class); 57 58 public static InterfaceAnalysis getInterfaceAnalysis(Class cls) 59 throws RMIIIOPViolationException 60 { 61 return (InterfaceAnalysis)cache.getAnalysis(cls); 62 } 63 64 66 protected InterfaceAnalysis(Class cls) 67 { 68 super(cls); 69 logger.debug("new InterfaceAnalysis: " + cls.getName()); 70 } 71 72 protected void doAnalyze() 73 throws RMIIIOPViolationException 74 { 75 super.doAnalyze(); 76 77 calculateOperationAnalysisMap(); 78 fixupCaseNames(); 79 } 80 81 83 public boolean isAbstractInterface() 84 { 85 return abstractInterface; 86 } 87 88 public boolean isRmiIdlRemoteInterface() 89 { 90 return (!abstractInterface); 91 } 92 93 public String [] getAllTypeIds() 94 { 95 if (allTypeIds == null) 96 logger.debug(cls + " null allTypeIds"); 97 return (String [])allTypeIds.clone(); 98 } 99 100 102 108 protected ArrayList getContainedEntries() 109 { 110 ArrayList ret = new ArrayList (constants.length + 111 attributes.length + 112 operations.length); 113 114 for (int i = 0; i < constants.length; ++i) 115 ret.add(constants[i]); 116 for (int i = 0; i < attributes.length; ++i) 117 ret.add(attributes[i]); 118 for (int i = 0; i < operations.length; ++i) 119 ret.add(operations[i]); 120 121 return ret; 122 } 123 124 128 protected void analyzeOperations() 129 throws RMIIIOPViolationException 130 { 131 logger.debug(cls + " analyzeOperations"); 132 133 if (!cls.isInterface()) 134 throw new IllegalArgumentException ("Class \"" + cls.getName() + 135 "\" is not an interface."); 136 137 abstractInterface = RmiIdlUtil.isAbstractInterface(cls); 138 calculateAllTypeIds(); 139 140 int operationCount = 0; 141 for (int i = 0; i < methods.length; ++i) 142 if ((m_flags[i] & (M_READ|M_WRITE|M_READONLY)) == 0) 143 ++operationCount; 144 operations = new OperationAnalysis[operationCount]; 145 operationCount = 0; 146 for (int i = 0; i < methods.length; ++i) { 147 if ((m_flags[i] & (M_READ|M_WRITE|M_READONLY)) == 0) { 148 operations[operationCount] = new OperationAnalysis(methods[i]); 149 ++operationCount; 150 } 151 } 152 153 logger.debug(cls + " analyzeOperations operations=" + operations.length); 154 } 155 156 161 protected void calculateOperationAnalysisMap() 162 { 163 operationAnalysisMap = new HashMap (); 164 OperationAnalysis oa; 165 166 for (int i = 0; i < operations.length; ++i) { 168 oa = operations[i]; 169 operationAnalysisMap.put(oa.getIDLName(), oa); 170 } 171 172 for (int i = 0; i < attributes.length; ++i) { 174 AttributeAnalysis attr = attributes[i]; 175 176 oa = attr.getAccessorAnalysis(); 177 178 if (oa != null) { 181 operationAnalysisMap.put(oa.getIDLName(), oa); 182 183 oa = attr.getMutatorAnalysis(); 184 if (oa != null) 185 operationAnalysisMap.put(oa.getIDLName(), oa); 186 } 187 } 188 } 189 190 195 protected void calculateAllTypeIds() 196 { 197 if (!isRmiIdlRemoteInterface()) { 198 allTypeIds = new String [0]; 199 } 200 else { 201 ArrayList a = new ArrayList (); 202 InterfaceAnalysis[] intfs = getInterfaces(); 203 for (int i = 0; i < intfs.length; ++i) { 204 String [] ss = intfs[i].getAllTypeIds(); 205 206 for (int j = 0; j < ss.length; ++j) 207 if (!a.contains(ss[j])) 208 a.add(ss[j]); 209 } 210 allTypeIds = new String [a.size() + 1]; 211 allTypeIds[0] = getRepositoryId(); 212 for (int i = 1; i <= a.size(); ++i) 213 allTypeIds[i] = (String )a.get(a.size()-i); 214 } 215 } 216 217 219 private boolean abstractInterface; 220 221 private String [] allTypeIds; 222 } 223 224 | Popular Tags |