Пример #1
0
  /**
   * Returns an ordered set of all JSF resource identifiers for the given RichFaces resource library
   * resources.
   *
   * @param id The resource identifier of the RichFaces resource library (e.g.
   *     org.richfaces:ajax.reslib).
   * @return An ordered set of all JSF resource identifiers for the given RichFaces resource library
   *     resources.
   */
  @SuppressWarnings("rawtypes")
  public static Set<ResourceIdentifier> getRichFacesResourceLibraryResources(
      final ResourceIdentifier id) {
    final Object resourceFactory = Hacks.createInstance(Hacks.RICHFACES_RLF_CLASS_NAME);
    final String name = id.getName().split("\\.")[0];
    final Object resourceLibrary =
        Hacks.invokeMethod(resourceFactory, "getResourceLibrary", name, id.getLibrary());
    final Iterable resources = Hacks.invokeMethod(resourceLibrary, "getResources");
    final Set<ResourceIdentifier> resourceIdentifiers = new LinkedHashSet<ResourceIdentifier>();

    for (final Object resource : resources) {
      final String libraryName = Hacks.invokeMethod(resource, "getLibraryName");
      final String resourceName = Hacks.invokeMethod(resource, "getResourceName");
      resourceIdentifiers.add(new ResourceIdentifier(libraryName, resourceName));
    }

    return resourceIdentifiers;
  }