@SuppressWarnings("unchecked")
public List<PortletContextImpl> getPortletApplications() {
final PortletRegistryService portletRegistryService = optionalContainerServices.getPortletRegistryService();
List<PortletContextImpl> contexts = new ArrayList<PortletContextImpl>();
for (Iterator iter = portletRegistryService.getRegisteredPortletApplications(); iter.hasNext();) {
PortletContextImpl context = (PortletContextImpl) iter.next();
final List<PortletDD> portlets = context.getPortletApplicationDefinition().getPortlets();
Collections.sort(portlets, new ComparableExtractingComparator<PortletDD, String>(String.CASE_INSENSITIVE_ORDER) {
@Override
protected String getComparable(PortletDD o) {
final List<DisplayNameDD> displayNames = o.getDisplayNames();
if (displayNames != null && displayNames.size() > 0) {