private Object getPropertyByPath(Object bean, String path) throws Exception { Object value = bean; if (value != null && path != null && !"".equals(path.trim())) { String [] names = path.trim().split("\\."); for (String name : names) { if (value != null) { value = getProperty(value, name); } else { break; } } } return value; }
private Object getProperty(Object bean, String name) throws Exception { PropertyDescriptor descriptor = getPropertyDescriptor(bean, name); if (descriptor == null) { throw new NoSuchMethodException("Unknown property '" + name + "' on class '" + bean.getClass() + "'"); } Method readMethod = descriptor.getReadMethod(); if (readMethod == null) { throw new NoSuchMethodException("Property '" + name + "' has no getter method in class '" + bean.getClass() + "'"); } Object value = readMethod.invoke(bean, EMPTY_OBJECT_ARRAY); return value; }
Object value = getPropertyByPath(bean, servletPathPropertyPath);
pairKeySeparator = PortletConfigUtils.getInitParameter(config, config.getPortletContext(), PAIR_KEY_SEPARATOR, pairKeySeparator); servletPathAttributeNames = splitAndTrimToArray(PortletConfigUtils.getInitParameter(config, config.getPortletContext(), SERVLET_PATH_ATTRIBUTE_NAMES, null), pairSeparator); servletPathPropertyPaths = splitAndTrimToArray(PortletConfigUtils.getInitParameter(config, config.getPortletContext(), SERVLET_PATH_PROPERTY_PATHS, null), pairSeparator); pathInfoAttributeNames = splitAndTrimToArray(PortletConfigUtils.getInitParameter(config, config.getPortletContext(), PATH_INFO_ATTRIBUTE_NAMES, null), pairSeparator); pathInfoPropertyPaths = splitAndTrimToArray(PortletConfigUtils.getInitParameter(config, config.getPortletContext(), PATH_INFO_PROPERTY_PATHS, null), pairSeparator);
pathInfo = (String) getPropertyByPath(bean, pathInfoPropertyPath); } catch (Exception e) { throw new PortletException(e);