[
https://issues.apache.org/jira/browse/MYFACES-2860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12897117#action_12897117
]
Leonardo Uribe commented on MYFACES-2860:
-----------------------------------------
I have attached a new proposal for AnnotationConfigurator, with some
documentation describing how it works. I also attached the deployer and related
jboss-myfaces project:
/**
* This interface provide a way to override myfaces annotation scanning
algorithm that
* needs to be found at startup:
*
* <ul>
* <li>{...@link javax.faces.bean.ManagedBean}</li>
* <li>{...@link javax.faces.component.FacesComponent}</li>
* <li>{...@link javax.faces.component.behavior.FacesBehavior}</li>
* <li>{...@link javax.faces.convert.FacesConverter}</li>
* <li>{...@link javax.faces.event.NamedEvent}</li>
* <li>{...@link javax.faces.render.FacesRenderer}</li>
* <li>{...@link javax.faces.render.FacesBehaviorRenderer}</li>
* <li>{...@link javax.faces.validator.FacesValidator}</li>
* </ul>
*
* <p>This is provided to allow application containers solve the following
points</p>
* <ul>
* <li>It is common application containers to have its own protocols to handle
files. It is
* not the same to scan annotation inside a jar than look on a directory.</li>
* <li>If the application container has some optimization related to annotation
scanning or
* it already did that task, it is better to reuse that information instead do
the same
* thing twice.</li>
* </ul>
*
* <p>To override this class, create a file on a jar file with the following
entry name:
* /META-INF/services/org.apache.myfaces.spi.AnnotationProvider and put the
desired class name of
* the class that will override or extend the default AnnotationProvider.
* </p>
*
* <p>To wrap the default AnnotationProvider, use a constructor like
* CustomAnnotationProvider(AnnotationProvider ap)</p>
*
* @since 2.0.2
* @author Leonardo Uribe
*/
public abstract class AnnotationProvider implements
FacesWrapper<AnnotationProvider>
{
/**
* Retrieve a map containing the classes that contains annotations used by
jsf implementation at
* startup.
* <p>The default implementation must comply with JSF 2.0 spec section
11.5.1 Requirements for scanning of
* classes for annotations.
* </p>
* <p>This method could call getBaseUrls() to obtain a list of URL that
could be used to indicate jar files of
* annotations in the classpath.
* </p>
* <p>If the <faces-config> element in the WEB-INF/faces-config.xml file
contains metadata-complete attribute
* whose value is "true", this method should not be called.
* </p>
*
* @param ctx The current ExternalContext
* @param urls A set of URL pointing to faces-config.xml files that could
be used to retrieve annotations from
* the classpath.
* @return A map with all classes that could contain annotations.
*/
public abstract Map<Class<? extends Annotation>,Set<Class<?>>>
getAnnotatedClasses(ExternalContext ctx);
/**
* <p>The returned Set<URL> urls are calculated in this way ( see JSF
2.0 spec section 11.4.2 for definitions )
* </p>
* <ol>
* <li>All resources that match either "META-INF/faces-config.xml" or end
with ".facesconfig.xml" directly in
* the "META-INF" directory (considered
<code>applicationConfigurationResources)<code></li>
* </ol>
*
* @return
*/
public abstract Set<URL> getBaseUrls() throws IOException;
public AnnotationProvider getWrapped()
{
return null;
}
}
Additionally there is a proposal for FacesConfigResourceProvider and
FaceletConfigResourceProvider, to solve the problem of override scanning
configuration resources.
Suggestions are welcome.
> Provide AnnotationScanner interface
> -----------------------------------
>
> Key: MYFACES-2860
> URL: https://issues.apache.org/jira/browse/MYFACES-2860
> Project: MyFaces Core
> Issue Type: Improvement
> Components: JSR-314
> Affects Versions: 2.0.1
> Reporter: Leonardo Uribe
> Assignee: Leonardo Uribe
> Attachments: jboss-myfaces-2.zip, jboss-myfaces.zip,
> Myfaces-2.0-jsf.deployer-2.zip, Myfaces-2.0-jsf.deployer.zip,
> MYFACES-2860-1.patch, MYFACES-2860-2.patch
>
>
> Looking integration of myfaces with JBoss AS6, it was notice myfaces does not
> have a way to override the annotation configurator.
> Ri has a class called AnnotationProvider with this methods:
> public AnnotationProvider(ServletContext sc)
> abstract public Map<?> getAnnotatedClasses(Set<URL> urls)
> the documentation says it is possible to override using this type of
> constructor.
> public AnnotationProvider(ServletContext sc, AnnotationProvider parent)
> We should provide something similar (let's call it AnnotationScanner because
> its objective is scan for annotations).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.