09-11行会根据这个portlet的id来获取这个portlet的model的名字列表,它会调用ResourceActionUtil类的getPortletModelResources方法:
public static List<String> getPortletModelResources(String portletName) { return getResourceActions().getPortletModelResources(portletName); }进而最终调用ResourceActionsImpl的getPortletModelResources方法:
public List<String> getPortletModelResources(String portletName) { portletName = PortletConstants.getRootPortletId(portletName); Set<String> resources = _portletModelResources.get(portletName); if (resources == null) { return new UniqueList<String>(); } else { return Collections.list(Collections.enumeration(resources)); } }从这里我们可以看出,它是从_portletModelResources中获取与portletName对应的Model名字列表,怎么获得呢,见readModelResource方法:
protected void readModelResource( String servletContextName, Element modelResourceElement) { String name = modelResourceElement.elementTextTrim("model-name"); Element portletRefElement = modelResourceElement.element("portlet-ref"); for (Element portletNameElement : portletRefElement.elements("portlet-name")) { String portletName = portletNameElement.getTextTrim(); if (servletContextName != null) { portletName = portletName.concat(PortletConstants.WAR_SEPARATOR).concat( servletContextName); } portletName = portal.getJsSafePortletId(portletName); // Reference for a portlet to child models Set<String> modelResources = _portletModelResources.get( portletName); if (modelResources == null) { modelResources = new HashSet<String>(); _portletModelResources.put(portletName, modelResources); } modelResources.add(name); // Reference for a model to parent portlets Set<String> portletResources = _modelPortletResources.get(name); if (portletResources == null) { portletResources = new HashSet<String>(); _modelPortletResources.put(name, portletResources); } portletResources.add(portletName); } List<String> supportsActions = readSupportsActions( modelResourceElement, _modelResourceActions, name); checkModelActions(supportsActions); setActions(_modelResourceActions, name, supportsActions); readGroupDefaultActions( modelResourceElement, _modelResourceGroupDefaultActions, name); List<String> guestDefaultActions = readGuestDefaultActions( modelResourceElement, _modelResourceGuestDefaultActions, name); readGuestUnsupportedActions( modelResourceElement, _modelResourceGuestUnsupportedActions, name, guestDefaultActions); setActions( _modelResourceGuestDefaultActions, name, guestDefaultActions); readOwnerDefaultActions( modelResourceElement, _modelResourceOwnerDefaultActions, name); }