Issue Details (XML | Word | Printable)

Key: JAVASERVERFACES_SPEC_PUBLIC-1038
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Ed Burns
Reporter: Ed Burns
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
javaserverfaces-spec-public

Provide annotation for declaring Facelets ResourceResolver

Created: 06/Oct/11 05:17 PM   Updated: 15/May/12 02:02 PM   Resolved: 20/Oct/11 05:29 AM
Component/s: Facelets/VDL
Affects Version/s: 2.0
Fix Version/s: 2.2

Time Tracking:
Original Estimate: 1 day
Original Estimate - 1 day
Remaining Estimate: 1 day
Remaining Estimate - 1 day
Time Spent: Not Specified
Time Spent - Not Specified

File Attachments: 1. Text File changebundle.txt (10 kB) 07/Oct/11 06:30 AM - Ed Burns
2. Text File diffs.patch (2 kB) 06/Oct/11 05:23 PM - Ed Burns

Issue Links:
Related
 

Tags:
Participants: arjan tijms and Ed Burns


 Description  « Hide

We need a way to declare a ResourceResolver without XML.



Ed Burns added a comment - 06/Oct/11 05:22 PM

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

Still need to implement


Ed Burns added a comment - 06/Oct/11 05:23 PM

Fix in progress. Incomplete.


Ed Burns added a comment - 07/Oct/11 06:30 AM

in progress, need test before commit


Ed Burns added a comment - 12/Oct/11 05:56 PM

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.


arjan tijms added a comment - 19/Oct/11 12:34 PM

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.


Ed Burns added a comment - 19/Oct/11 03:38 PM

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


Ed Burns added a comment - 20/Oct/11 05:29 AM

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.


Ed Burns added a comment - 20/Oct/11 05:29 AM

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


arjan tijms added a comment - 15/May/12 02:02 PM

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?