[JAVASERVERFACES_SPEC_PUBLIC-1038] Provide annotation for declaring Facelets ResourceResolver Created: 06/Oct/11  Updated: 15/May/12  Resolved: 20/Oct/11

Status: Closed
Project: javaserverfaces-spec-public
Component/s: Facelets/VDL
Affects Version/s: 2.0
Fix Version/s: 2.2

Type: New Feature Priority: Trivial
Reporter: Ed Burns Assignee: Ed Burns
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 1 day
Time Spent: Not Specified
Original Estimate: 1 day

Attachments: Text File changebundle.txt     Text File diffs.patch    
Issue Links:
Related
is related to JAVASERVERFACES_SPEC_PUBLIC-599 Application.createComponent(): compco... Closed

 Description   

We need a way to declare a ResourceResolver without XML.



 Comments   
Comment by Ed Burns [ 06/Oct/11 ]

Adding jsf-api/src/main/java/javax/faces/view/facelets/FaceletsResourceResolver.java
Transmitting file data .
Committed revision 9400.

Still need to implement

Comment by Ed Burns [ 06/Oct/11 ]

Fix in progress. Incomplete.

Comment by Ed Burns [ 07/Oct/11 ]

in progress, need test before commit

Comment by Ed Burns [ 12/Oct/11 ]

Sending jsf-ri/src/main/java/com/sun/faces/application/ApplicationAssociate.java
Sending jsf-ri/src/main/java/com/sun/faces/config/AnnotationScanner.java
Sending jsf-ri/src/main/java/com/sun/faces/facelets/util/ReflectionUtil.java
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/build.xml
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/pom.xml
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/java
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/java/com
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/java/com/sun
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/java/com/sun/faces
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/java/com/sun/faces/regression
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/java/com/sun/faces/regression/i_spec_1038_war
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/java/com/sun/faces/regression/i_spec_1038_war/AnnotationDeclaredResourceResolver.java
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/webapp
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/webapp/WEB-INF
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/webapp/WEB-INF/beans.xml
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/webapp/WEB-INF/web.xml
Adding jsf-test/JAVASERVERFACES_SPEC_PUBLIC-1038/i_spec_1038_war/src/main/webapp/i_spec_1038_war.xhtml
Transmitting file data .........
Committed revision 9401.

Comment by arjan tijms [ 19/Oct/11 ]

I have a question about the implementation. Currently it's:

ApplicationAssociate#createFaceletFactory
Set<? extends Class> resourceResolvers = 
    ConfigManager.getAnnotatedClasses(ctx).get(FaceletsResourceResolver.class);
if ((null != resourceResolvers) && !resourceResolvers.isEmpty()) {
    Class resolverClass = resourceResolvers.iterator().next();
    if (1 < resourceResolvers.size()) {
        if (LOGGER.isLoggable(Level.SEVERE)) {
            LOGGER.log(Level.SEVERE, "Found more than one class " + 
                "annotated with FaceletsResourceResolver.  Will " + 
                "use {0} and ignore the others", resolverClass);
        }
    }
    resolver = (ResourceResolver) 
        ReflectionUtil.decorateInstance(resolverClass,
        ResourceResolver.class,
        resolver);
} else {
    String resolverName = webConfig.getOptionValue(FaceletsResourceResolver);
    if (resolverName != null && resolverName.length() > 0) {
        resolver = (ResourceResolver) 
                ReflectionUtil.decorateInstance(resolverName,
                ResourceResolver.class,
                resolver);
    }
}

So if the @FaceletsResourceResolver annotation is present, it's used. Otherwise the XML is consulted.

Should this perhaps not be the other way around? In Java EE it seems to be the convention that XML can be used to override annotations. Is there a hard rule for this somewhere?

A small other thing; I noticed that in com.sun.faces.config.AnnotationScanner the Javadoc on top of the class has not been updated for the newly added annotation.

Comment by Ed Burns [ 19/Oct/11 ]

Good questions by arjan tims have prompted me to reopen this.

Comment by Ed Burns [ 20/Oct/11 ]

Spec changes.

Sending preface.fm
Sending usingFacesInWebapps.fm
Transmitting file data ..
Committed revision 1041.

Sending jsf-ri/src/main/java/com/sun/faces/application/ApplicationAssociate.java
Sending jsf-ri/src/main/java/com/sun/faces/config/AnnotationScanner.java
Transmitting file data ..
Committed revision 9407.

Comment by Ed Burns [ 20/Oct/11 ]

I don't know what the difference between "close" and "resolve" is so I am doing both.

Comment by arjan tijms [ 15/May/12 ]

Per commit 9755 and issues JAVASERVERFACES_SPEC_PUBLIC-719 and JAVASERVERFACES_SPEC_PUBLIC-809, ResourceResolver has been deprecated.

Perhaps it's a little confusing if a new annotation is introduced for something that is simultaneously deprecated?

Generated at Tue Jun 30 17:39:53 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.