Skip to main content

[JIRA] Commented: (PORTLETSPEC3-40) Add new javax.portlet.ResourceComparator annotation in order to identify duplicate resources

  • From: "kito75 (JIRA)" < >
  • To:
  • Subject: [JIRA] Commented: (PORTLETSPEC3-40) Add new javax.portlet.ResourceComparator annotation in order to identify duplicate resources
  • Date: Tue, 14 Jan 2014 17:29:49 +0000 (UTC)
  • Auto-submitted: auto-generated


    [ 
https://java.net/jira/browse/PORTLETSPEC3-40?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=372332#action_372332
 ] 

kito75 commented on PORTLETSPEC3-40:
------------------------------------

Sounds good to me. Would we need a default implementation?

> Add new javax.portlet.ResourceComparator annotation in order to identify 
> duplicate resources
> --------------------------------------------------------------------------------------------
>
>                 Key: PORTLETSPEC3-40
>                 URL: https://java.net/jira/browse/PORTLETSPEC3-40
>             Project: portletspec3
>          Issue Type: New Feature
>          Components: Ideas for JSR 362 Extensions
>            Reporter: Neil Griffin
>
> I would like to propose the following annotation, which
> would allow portlet developers (and JSF portlet bridge implementors)
> to provide a way to inform the portlet container of duplicate
> resources. This is a common problem with JSF portlets, since each
> JSF portlet on the portal page needs the "jsf.js" resource:
> {code}
> package javax.portlet;
> /**
> * Annotation for marking a class that compares resource URLs. Such classes 
> are
> * discovered by the portlet container at startup and are required to
> * implement the {@link java.util.Comparator} interface in order to compare
> * resources represented as type {@link java.lang.String}. If the
> * {@link java.util.Comparator#compare(Object, Object)} method returns 0, 
> then
> * the portlet container will consider the resources to be identical and 
> will include
> * only the first resource in the &lt;head/&gt; section of the rendered 
> portal page.
> *
> * @since 3.0
> */
> @Target(ElementType.TYPE)
> @Retention(RetentionPolicy.RUNTIME)
> public @interface ResourceComparator {
> }
> {code}
> Here is an example that a JSF portlet bridge could use in order to prevent 
> duplicate JSF resources:
> {code}
> public interface FacesResource {
>       public enum TYPE {
>               HREF, LINK, SCRIPT
>       }
>       
>       public TYPE getType();
>       
>       public String getName();
>       
>       public String getLibrary();
> }
> {code}
> {code}
> @ResourceComparator
> public class FacesResourceComparator implements Comparator<String> {
>       public int compare(String resourceURL1, String resourceURL2) {
>               if (isFacesResource(resourceURL1) && 
> isFacesResource(resourceURL2)) {
>                               
>                               FacesResource facesResource1 = new 
> FacesResourceImpl(resourceURL1);
>                               FacesResource facesResource2 = new 
> FacesResourceImpl(resourceURL2);
>                               if (facesResource1.equals(facesResource2)) {
>                                       return 0;
>                               }
>                               else {
>                                       return -1;
>                               }
>               }
>               else {
>                       return -1;
>               }
>       }
>       protected boolean isFacesResource(String url) {
>               return ((url != null) && 
> url.contains("javax.faces.resource"));
>       }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[JIRA] Commented: (PORTLETSPEC3-40) Add new javax.portlet.ResourceComparator annotation in order to identify duplicate resources

kito75 (JIRA) 01/14/2014
 
 
Close
loading
Please Confirm
Close