private static void processKeyExpression( Class<?> clz, String keyExpr, CachableValueAccessor accessorCache) throws ServiceException { if (keyExpr == null || keyExpr.isEmpty()) throw new ServiceException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_CACHE_POLICY_INVALID_KEY, ErrorConstants.ERRORDOMAIN, new Object[] {keyExpr})); StringTokenizer st = new StringTokenizer(keyExpr, "."); StringBuffer currentPath = new StringBuffer(); Class<?> curClz = clz; CachableValueAccessor curLevelAccessor = accessorCache; while (st.hasMoreElements()) { String xmlElement = (String) st.nextElement(); CachableValueAccessor childLevelAccessor = null; Method m = null; if (currentPath.length() != 0) currentPath.append(".").append(xmlElement); else currentPath.append(xmlElement); if (curLevelAccessor.m_elementAccessors.get(xmlElement) != null) { // found. No need to create method childLevelAccessor = curLevelAccessor.m_elementAccessors.get(xmlElement); m = childLevelAccessor.m_accessor; } else { // find the matching java method m = ReflectionUtils.findMatchingJavaMethod(curClz, xmlElement); if (m == null) { // System.out.println("Method not found: class=" + curClz.getName() + ", xmlElement=" + // xmlElement); throw new ServiceException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_CACHE_POLICY_INVALID_KEY, ErrorConstants.ERRORDOMAIN, new Object[] {keyExpr})); } childLevelAccessor = new CachableValueAccessor(xmlElement, m, currentPath.toString()); // insert to the current level of the accessorCache curLevelAccessor.m_elementAccessors.put(xmlElement, childLevelAccessor); } // advance the iteration to use the childLevelAccessor curLevelAccessor = childLevelAccessor; curClz = m.getReturnType(); } if (!KeyExpressionValidator.validateReturnType(curClz)) throw new ServiceException( ErrorDataFactory.createErrorData( ErrorConstants.SVC_CACHE_POLICY_INVALID_KEY, ErrorConstants.ERRORDOMAIN, new Object[] {keyExpr})); }