You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by st...@apache.org on 2011/10/25 16:59:53 UTC
svn commit: r1188686 [1/2] - in
/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces: component/visit/
config/ config/annotation/ config/element/
Author: struberg
Date: Tue Oct 25 14:59:52 2011
New Revision: 1188686
URL: http://svn.apache.org/viewvc?rev=1188686&view=rev
Log:
MYFACES-3368 checkstyle fixes
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/component/visit/VisitContextFactoryImpl.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationMerger.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultLifecycleProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/LifecycleProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/LifecycleProvider2.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/LifecycleProviderFactory.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/NoAnnotationLifecyleProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/NoInjectionAnnotationLifecycleProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/TomcatAnnotationLifecycleProvider.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/FacesConfigData.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ManagedBean.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/ManagedProperty.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/NavigationCase.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Ordering.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Property.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/element/Renderer.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/component/visit/VisitContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/component/visit/VisitContextFactoryImpl.java?rev=1188686&r1=1188685&r2=1188686&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/component/visit/VisitContextFactoryImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/component/visit/VisitContextFactoryImpl.java Tue Oct 25 14:59:52 2011
@@ -30,17 +30,22 @@ import javax.faces.context.FacesContext;
* @version $Rev$ $Date$
* Implementation of the VisitContextFactory!
*/
-public class VisitContextFactoryImpl extends VisitContextFactory {
+public class VisitContextFactoryImpl extends VisitContextFactory
+{
public VisitContextFactoryImpl()
{
}
@Override
- public VisitContext getVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints) {
- if (ids == null || ids.isEmpty()) {
+ public VisitContext getVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints)
+ {
+ if (ids == null || ids.isEmpty())
+ {
return new FullVisitContext(context, hints);
- } else {
+ }
+ else
+ {
return new PartialVisitContext(context, ids, hints);
}
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java?rev=1188686&r1=1188685&r2=1188686&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/ConfigFilesXmlValidationUtils.java Tue Oct 25 14:59:52 2011
@@ -154,26 +154,32 @@ public class ConfigFilesXmlValidationUti
{
if ("http://www.w3.org/TR/REC-xml".equals(type) && "datatypes.dtd".equals(systemId))
{
- return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/datatypes.dtd"));
+ return new LSInputImpl(publicId, systemId, baseURI,
+ ClassUtils.getResourceAsStream("org/apache/myfaces/resource/datatypes.dtd"));
}
if ("-//W3C//DTD XMLSCHEMA 200102//EN".equals(publicId) && "XMLSchema.dtd".equals(systemId))
{
- return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/XMLSchema.dtd"));
+ return new LSInputImpl(publicId, systemId, baseURI,
+ ClassUtils.getResourceAsStream("org/apache/myfaces/resource/XMLSchema.dtd"));
}
if ("http://java.sun.com/xml/ns/javaee".equals(namespaceURI))
{
if ("javaee_5.xsd".equals(systemId))
{
- return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/javaee_5.xsd"));
+ return new LSInputImpl(publicId, systemId, baseURI,
+ ClassUtils.getResourceAsStream("org/apache/myfaces/resource/javaee_5.xsd"));
}
else if ("javaee_web_services_client_1_2.xsd".equals(systemId))
{
- return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/javaee_web_services_client_1_2.xsd"));
+ return new LSInputImpl(publicId, systemId, baseURI,
+ ClassUtils.getResourceAsStream(
+ "org/apache/myfaces/resource/javaee_web_services_client_1_2.xsd"));
}
}
if ("http://www.w3.org/XML/1998/namespace".equals(namespaceURI))
{
- return new LSInputImpl(publicId, systemId, baseURI, ClassUtils.getResourceAsStream("org/apache/myfaces/resource/xml.xsd"));
+ return new LSInputImpl(publicId, systemId, baseURI,
+ ClassUtils.getResourceAsStream("org/apache/myfaces/resource/xml.xsd"));
}
return null;
}
@@ -226,7 +232,9 @@ public class ConfigFilesXmlValidationUti
private static Source getFacesConfigSchemaFileAsSource(ExternalContext externalContext, String version)
{
- String xmlSchema = "1.2".equals(version) ? FACES_CONFIG_SCHEMA_PATH_12 : ("2.0".equals(version) ? FACES_CONFIG_SCHEMA_PATH_20 : FACES_CONFIG_SCHEMA_PATH_21) ;
+ String xmlSchema = "1.2".equals(version)
+ ? FACES_CONFIG_SCHEMA_PATH_12
+ : ("2.0".equals(version) ? FACES_CONFIG_SCHEMA_PATH_20 : FACES_CONFIG_SCHEMA_PATH_21);
InputStream stream = ClassUtils.getResourceAsStream(xmlSchema);
@@ -235,7 +243,8 @@ public class ConfigFilesXmlValidationUti
stream = externalContext.getResourceAsStream(xmlSchema);
}
- if (stream == null) {
+ if (stream == null)
+ {
return null;
}
@@ -396,7 +405,8 @@ public class ConfigFilesXmlValidationUti
stream = externalContext.getResourceAsStream(FACES_TAGLIB_SCHEMA_PATH);
}
- if (stream == null) {
+ if (stream == null)
+ {
return null;
}
@@ -501,7 +511,9 @@ public class ConfigFilesXmlValidationUti
for (int i = 0; i < length; i++)
{
String attrName = attributes.getLocalName(i);
- attrName = (attrName != null) ? ( (attrName.length() > 0) ? attrName : attributes.getQName(i)) : attributes.getQName(i);
+ attrName = (attrName != null)
+ ? ( (attrName.length() > 0) ? attrName : attributes.getQName(i))
+ : attributes.getQName(i);
if (attrName.equals ("version"))
{
// This document has a "version" attribute in the <facelet-taglib> element, so
@@ -513,7 +525,7 @@ public class ConfigFilesXmlValidationUti
// Throw a dummy parsing exception to terminate parsing as there really isn't any need to go any
// further.
- // -= Leonardo Uribe =- THIS IS NOT GOOD PRACTICE! It is better to let the checker continue that
+ // -= Leonardo Uribe =- THIS IS NOT GOOD PRACTICE! It is better to let the checker continue that
// throw an exception, and run this one only when project stage != production.
//throw new SAXException();
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationMerger.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationMerger.java?rev=1188686&r1=1188685&r2=1188686&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationMerger.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationMerger.java Tue Oct 25 14:59:52 2011
@@ -137,9 +137,12 @@ public class DefaultFacesConfigurationMe
List<OrderSlot> slots = webAppConfig.getAbsoluteOrdering().getOrderList();
for (FacesConfig resource : appConfigResources)
{
- // First condition: if faces-config.xml does not have name it is 1) pre-JSF-2.0 or 2) has no <name> element,
+ // First condition: if faces-config.xml does not have name it is
+ // 1) pre-JSF-2.0 or
+ // 2) has no <name> element,
// -> in both cases cannot be ordered
- // Second condition : faces-config.xml has a name but <ordering> element does not have slot with that name
+ // Second condition : faces-config.xml has a name but <ordering>
+ // element does not have slot with that name
// -> resource can be ordered, but will fit into <others /> element
if ((resource.getName() == null) ||
(resource.getName() != null && !containsResourceInSlot(slots, resource.getName())))
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java?rev=1188686&r1=1188685&r2=1188686&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java Tue Oct 25 14:59:52 2011
@@ -366,7 +366,8 @@ public class DefaultFacesConfigurationPr
return connection.getInputStream();
}
- private List<String> getConfigFilesList(ExternalContext ectx) {
+ private List<String> getConfigFilesList(ExternalContext ectx)
+ {
String configFiles = ectx.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
List<String> configFilesList = new ArrayList<String>();
if (configFiles != null)
@@ -380,7 +381,8 @@ public class DefaultFacesConfigurationPr
{
if (log.isLoggable(Level.WARNING))
{
- log.warning(DEFAULT_FACES_CONFIG + " has been specified in the " + FacesServlet.CONFIG_FILES_ATTR
+ log.warning(DEFAULT_FACES_CONFIG + " has been specified in the "
+ + FacesServlet.CONFIG_FILES_ATTR
+ " context parameter of "
+ "the deployment descriptor. This will automatically be removed, "
+ "if we wouldn't do this, it would be loaded twice. See JSF spec 1.1, 10.3.2");
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java?rev=1188686&r1=1188685&r2=1188686&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigDispenser.java Tue Oct 25 14:59:52 2011
@@ -18,20 +18,8 @@
*/
package org.apache.myfaces.config;
-import java.util.Collection;
-
-import javax.el.ELResolver;
-
-import org.apache.myfaces.config.element.Behavior;
-import org.apache.myfaces.config.element.ClientBehaviorRenderer;
import org.apache.myfaces.config.element.FacesConfigData;
-import org.apache.myfaces.config.element.ManagedBean;
-import org.apache.myfaces.config.element.NavigationRule;
-import org.apache.myfaces.config.element.Renderer;
-import org.apache.myfaces.config.element.Converter;
-import org.apache.myfaces.config.element.NamedEvent;
-import org.apache.myfaces.config.element.ResourceBundle;
-import org.apache.myfaces.config.element.SystemEventListener;
+
/**
* Subsumes several unmarshalled faces config objects and presents a simple interface
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java?rev=1188686&r1=1188685&r2=1188686&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/FacesConfigurator.java Tue Oct 25 14:59:52 2011
@@ -114,7 +114,7 @@ import org.apache.myfaces.webapp.Managed
/**
* Configures everything for a given context. The FacesConfigurator is independent of the concrete implementations that
* lie behind FacesConfigUnmarshaller and FacesConfigDispenser.
- *
+ *
* @author Manfred Geiler (latest modification by $Author$)
* @version $Revision$ $Date$
*/
@@ -132,7 +132,8 @@ public class FacesConfigurator
private static final String DEFAULT_RENDER_KIT_FACTORY = RenderKitFactoryImpl.class.getName();
private static final String DEFAULT_PARTIAL_VIEW_CONTEXT_FACTORY = PartialViewContextFactoryImpl.class.getName();
private static final String DEFAULT_VISIT_CONTEXT_FACTORY = VisitContextFactoryImpl.class.getName();
- private static final String DEFAULT_VIEW_DECLARATION_LANGUAGE_FACTORY = ViewDeclarationLanguageFactoryImpl.class.getName();
+ private static final String DEFAULT_VIEW_DECLARATION_LANGUAGE_FACTORY
+ = ViewDeclarationLanguageFactoryImpl.class.getName();
private static final String DEFAULT_EXCEPTION_HANDLER_FACTORY = ExceptionHandlerFactoryImpl.class.getName();
private static final String DEFAULT_TAG_HANDLER_DELEGATE_FACTORY = TagHandlerDelegateFactoryImpl.class.getName();
private static final String DEFAULT_FACELET_CACHE_FACTORY = FaceletCacheFactoryImpl.class.getName();
@@ -200,12 +201,12 @@ public class FacesConfigurator
return _dispenser;
}
-
+
public void setAnnotationConfigurator(AnnotationConfigurator configurator)
{
_annotationConfigurator = configurator;
}
-
+
protected AnnotationConfigurator getAnnotationConfigurator()
{
if (_annotationConfigurator == null)
@@ -217,9 +218,9 @@ public class FacesConfigurator
private long getResourceLastModified(String resource)
{
- try
+ try
{
- URL url = _externalContext.getResource(resource);
+ URL url = _externalContext.getResource(resource);
if (url != null)
{
return getResourceLastModified(url);
@@ -290,8 +291,8 @@ public class FacesConfigurator
}
return modified;
- }
-
+ }
+
private long getLastModifiedTime()
{
long lastModified = 0;
@@ -355,13 +356,14 @@ public class FacesConfigurator
log.severe("Error during configuration clean-up" + e.getMessage());
}
configure();
-
+
// JSF 2.0 Publish PostConstructApplicationEvent after all configuration resources
// has been parsed and processed
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
-
- application.publishEvent(facesContext, PostConstructApplicationEvent.class, Application.class, application);
+
+ application.publishEvent(facesContext, PostConstructApplicationEvent.class,
+ Application.class, application);
}
}
}
@@ -377,13 +379,16 @@ public class FacesConfigurator
// Check that we have access to all of the necessary purge methods before purging anything
//
- ApplicationFactory applicationFactory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ ApplicationFactory applicationFactory
+ = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
appFactoryPurgeMethod = applicationFactory.getClass().getMethod("purgeApplication", NO_PARAMETER_TYPES);
- RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKitFactory renderKitFactory
+ = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
renderKitPurgeMethod = renderKitFactory.getClass().getMethod("purgeRenderKit", NO_PARAMETER_TYPES);
-
- LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+
+ LifecycleFactory lifecycleFactory
+ = (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
lifecyclePurgeMethod = lifecycleFactory.getClass().getMethod("purgeLifecycle", NO_PARAMETER_TYPES);
// If there was no exception so far, now we can purge
@@ -408,13 +413,13 @@ public class FacesConfigurator
configureFactories();
configureApplication();
configureRenderKits();
-
- //Now we can configure annotations
+
+ //Now we can configure annotations
//getAnnotationConfigurator().configure(
// ((ApplicationFactory) FactoryFinder.getFactory(
// FactoryFinder.APPLICATION_FACTORY)).getApplication(),
// getDispenser(), metadataComplete);
-
+
configureRuntimeConfig();
configureLifecycle();
handleSerialFactory();
@@ -424,7 +429,8 @@ public class FacesConfigurator
lastUpdate = System.currentTimeMillis();
}
- private List<String> getConfigFilesList() {
+ private List<String> getConfigFilesList()
+ {
String configFiles = _externalContext.getInitParameter(FacesServlet.CONFIG_FILES_ATTR);
List<String> configFilesList = new ArrayList<String>();
if (configFiles != null)
@@ -438,7 +444,8 @@ public class FacesConfigurator
{
if (log.isLoggable(Level.WARNING))
{
- log.warning(DEFAULT_FACES_CONFIG + " has been specified in the " + FacesServlet.CONFIG_FILES_ATTR
+ log.warning(DEFAULT_FACES_CONFIG + " has been specified in the "
+ + FacesServlet.CONFIG_FILES_ATTR
+ " context parameter of "
+ "the deployment descriptor. This will automatically be removed, "
+ "if we wouldn't do this, it would be loaded twice. See JSF spec 1.1, 10.3.2");
@@ -452,32 +459,33 @@ public class FacesConfigurator
}
return configFilesList;
}
-
+
private void configureFactories()
{
FacesConfigData dispenser = getDispenser();
setFactories(FactoryFinder.APPLICATION_FACTORY, dispenser.getApplicationFactoryIterator(),
- DEFAULT_APPLICATION_FACTORY);
+ DEFAULT_APPLICATION_FACTORY);
setFactories(FactoryFinder.EXCEPTION_HANDLER_FACTORY, dispenser.getExceptionHandlerFactoryIterator(),
- DEFAULT_EXCEPTION_HANDLER_FACTORY);
+ DEFAULT_EXCEPTION_HANDLER_FACTORY);
setFactories(FactoryFinder.EXTERNAL_CONTEXT_FACTORY, dispenser.getExternalContextFactoryIterator(),
- DEFAULT_EXTERNAL_CONTEXT_FACTORY);
+ DEFAULT_EXTERNAL_CONTEXT_FACTORY);
setFactories(FactoryFinder.FACES_CONTEXT_FACTORY, dispenser.getFacesContextFactoryIterator(),
- DEFAULT_FACES_CONTEXT_FACTORY);
+ DEFAULT_FACES_CONTEXT_FACTORY);
setFactories(FactoryFinder.LIFECYCLE_FACTORY, dispenser.getLifecycleFactoryIterator(),
- DEFAULT_LIFECYCLE_FACTORY);
+ DEFAULT_LIFECYCLE_FACTORY);
setFactories(FactoryFinder.RENDER_KIT_FACTORY, dispenser.getRenderKitFactoryIterator(),
- DEFAULT_RENDER_KIT_FACTORY);
+ DEFAULT_RENDER_KIT_FACTORY);
setFactories(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY, dispenser.getTagHandlerDelegateFactoryIterator(),
- DEFAULT_TAG_HANDLER_DELEGATE_FACTORY);
+ DEFAULT_TAG_HANDLER_DELEGATE_FACTORY);
setFactories(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY, dispenser.getPartialViewContextFactoryIterator(),
- DEFAULT_PARTIAL_VIEW_CONTEXT_FACTORY);
+ DEFAULT_PARTIAL_VIEW_CONTEXT_FACTORY);
setFactories(FactoryFinder.VISIT_CONTEXT_FACTORY, dispenser.getVisitContextFactoryIterator(),
- DEFAULT_VISIT_CONTEXT_FACTORY);
- setFactories(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY, dispenser.getViewDeclarationLanguageFactoryIterator(),
- DEFAULT_VIEW_DECLARATION_LANGUAGE_FACTORY);
+ DEFAULT_VISIT_CONTEXT_FACTORY);
+ setFactories(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY,
+ dispenser.getViewDeclarationLanguageFactoryIterator(),
+ DEFAULT_VIEW_DECLARATION_LANGUAGE_FACTORY);
setFactories(FactoryFinder.FACELET_CACHE_FACTORY, dispenser.getFaceletCacheFactoryIterator(),
- DEFAULT_FACELET_CACHE_FACTORY);
+ DEFAULT_FACELET_CACHE_FACTORY);
}
private void setFactories(String factoryName, Collection<String> factories, String defaultFactory)
@@ -491,14 +499,15 @@ public class FacesConfigurator
}
}
}
-
+
private void configureApplication()
{
- Application application = ((ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+ Application application = ((ApplicationFactory)
+ FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
FacesConfigData dispenser = getDispenser();
application.setActionListener(ClassUtils.buildApplicationObject(ActionListener.class,
- dispenser.getActionListenerIterator(), null));
+ dispenser.getActionListenerIterator(), null));
if (dispenser.getDefaultLocale() != null)
{
@@ -516,18 +525,18 @@ public class FacesConfigurator
}
application.setNavigationHandler(ClassUtils.buildApplicationObject(NavigationHandler.class,
- ConfigurableNavigationHandler.class,
- BackwardsCompatibleNavigationHandlerWrapper.class,
- dispenser.getNavigationHandlerIterator(),
- application.getNavigationHandler()));
+ ConfigurableNavigationHandler.class,
+ BackwardsCompatibleNavigationHandlerWrapper.class,
+ dispenser.getNavigationHandlerIterator(),
+ application.getNavigationHandler()));
application.setStateManager(ClassUtils.buildApplicationObject(StateManager.class,
- dispenser.getStateManagerIterator(),
- application.getStateManager()));
+ dispenser.getStateManagerIterator(),
+ application.getStateManager()));
application.setResourceHandler(ClassUtils.buildApplicationObject(ResourceHandler.class,
- dispenser.getResourceHandlerIterator(),
- application.getResourceHandler()));
+ dispenser.getResourceHandlerIterator(),
+ application.getResourceHandler()));
List<Locale> locales = new ArrayList<Locale>();
for (String locale : dispenser.getSupportedLocalesIterator())
@@ -538,40 +547,44 @@ public class FacesConfigurator
application.setSupportedLocales(locales);
application.setViewHandler(ClassUtils.buildApplicationObject(ViewHandler.class,
- dispenser.getViewHandlerIterator(),
- application.getViewHandler()));
+ dispenser.getViewHandlerIterator(),
+ application.getViewHandler()));
for (SystemEventListener systemEventListener : dispenser.getSystemEventListeners())
{
- try {
+ try
+ {
//note here used to be an instantiation to deal with the explicit source type in the registration,
// that cannot work because all system events need to have the source being passed in the constructor
//instead we now rely on the standard system event types and map them to their appropriate constructor types
- Class eventClass = ClassUtils.classForName((systemEventListener.getSystemEventClass() != null) ? systemEventListener.getSystemEventClass():SystemEvent.class.getName());
- //application.subscribeToEvent(
- // (Class<? extends SystemEvent>)eventClass ,
- // (Class<?>)ClassUtils.classForName((systemEventListener.getSourceClass() != null) ? systemEventListener.getSourceClass(): getDefaultSourcClassForSystemEvent(eventClass) ), //Application.class???
- // (javax.faces.event.SystemEventListener)ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
-
+ Class eventClass = ClassUtils.classForName((systemEventListener.getSystemEventClass() != null)
+ ? systemEventListener.getSystemEventClass()
+ : SystemEvent.class.getName());
+
if (systemEventListener.getSourceClass() != null && systemEventListener.getSourceClass().length() > 0)
{
application.subscribeToEvent(
- (Class<? extends SystemEvent>)eventClass , ClassUtils.classForName(systemEventListener.getSourceClass()),
- (javax.faces.event.SystemEventListener)ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
+ (Class<? extends SystemEvent>) eventClass,
+ ClassUtils.classForName(systemEventListener.getSourceClass()),
+ (javax.faces.event.SystemEventListener)
+ ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
}
else
{
application.subscribeToEvent(
- (Class<? extends SystemEvent>)eventClass ,
- (javax.faces.event.SystemEventListener)ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
+ (Class<? extends SystemEvent>) eventClass,
+ (javax.faces.event.SystemEventListener)
+ ClassUtils.newInstance(systemEventListener.getSystemEventListenerClass()));
}
- } catch (ClassNotFoundException e) {
- log.log(Level.SEVERE, "System event listener could not be initialized, reason:",e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.log(Level.SEVERE, "System event listener could not be initialized, reason:", e);
}
}
-
+
for (String componentType : dispenser.getComponentTypes())
{
application.addComponent(componentType, dispenser.getComponentClass(componentType));
@@ -587,7 +600,7 @@ public class FacesConfigurator
try
{
application.addConverter(ClassUtils.simpleClassForName(converterClass),
- dispenser.getConverterClassByClass(converterClass));
+ dispenser.getConverterClassByClass(converterClass));
}
catch (Exception ex)
{
@@ -605,7 +618,7 @@ public class FacesConfigurator
// - bean validation is available in the classpath
String beanValidatorDisabled = _externalContext.getInitParameter(
BeanValidator.DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME);
- final boolean defaultBeanValidatorDisabled = (beanValidatorDisabled != null
+ final boolean defaultBeanValidatorDisabled = (beanValidatorDisabled != null
&& beanValidatorDisabled.toLowerCase().equals("true"));
boolean beanValidatorInstalledProgrammatically = false;
if (!defaultBeanValidatorDisabled
@@ -621,12 +634,12 @@ public class FacesConfigurator
{
application.addDefaultValidatorId(validatorId);
}
-
+
// do some checks if the BeanValidator was not installed as a
// default-validator programmatically, but via a config file.
- if (!beanValidatorInstalledProgrammatically
+ if (!beanValidatorInstalledProgrammatically
&& application.getDefaultValidatorInfo()
- .containsKey(BeanValidator.VALIDATOR_ID))
+ .containsKey(BeanValidator.VALIDATOR_ID))
{
if (!ExternalSpecifications.isBeanValidationAvailable())
{
@@ -644,26 +657,27 @@ public class FacesConfigurator
// (section 11.1.3: "though manual installation is still possible")
// --> inform the user about this scenario
log.log(Level.INFO, "The BeanValidator was disabled as a " +
- "default-validator via the config parameter " +
+ "default-validator via the config parameter " +
BeanValidator.DISABLE_DEFAULT_BEAN_VALIDATOR_PARAM_NAME +
" in web.xml, but a faces-config file added it, " +
"thus it actually was installed as a default-validator.");
}
}
- for (Behavior behavior : dispenser.getBehaviors()) {
+ for (Behavior behavior : dispenser.getBehaviors())
+ {
application.addBehavior(behavior.getBehaviorId(), behavior.getBehaviorClass());
}
-
+
RuntimeConfig runtimeConfig = getRuntimeConfig();
runtimeConfig.setPropertyResolverChainHead(ClassUtils.buildApplicationObject(PropertyResolver.class,
- dispenser.getPropertyResolverIterator(),
- new DefaultPropertyResolver()));
+ dispenser.getPropertyResolverIterator(),
+ new DefaultPropertyResolver()));
runtimeConfig.setVariableResolverChainHead(ClassUtils.buildApplicationObject(VariableResolver.class,
- dispenser.getVariableResolverIterator(),
- new VariableResolverImpl()));
+ dispenser.getVariableResolverIterator(),
+ new VariableResolverImpl()));
}
/**
@@ -678,16 +692,19 @@ public class FacesConfigurator
String getDefaultSourcClassForSystemEvent(Class systemEventClass)
{
Constructor[] constructors = systemEventClass.getConstructors();
- for(Constructor constr: constructors) {
- Class [] parms = constr.getParameterTypes();
- if(parms == null || parms.length != 1)
+ for (Constructor constr : constructors)
+ {
+ Class[] parms = constr.getParameterTypes();
+ if (parms == null || parms.length != 1)
{
//for standard types we have only one parameter representing the type
continue;
}
return parms[0].getName();
}
- log.warning("The SystemEvent source type for "+systemEventClass.getName() + " could not be detected, either register it manually or use a constructor argument for auto detection, defaulting now to java.lang.Object");
+ log.warning("The SystemEvent source type for " + systemEventClass.getName()
+ + " could not be detected, either register it manually or use a constructor argument "
+ + "for auto detection, defaulting now to java.lang.Object");
return "java.lang.Object";
}
@@ -733,7 +750,7 @@ public class FacesConfigurator
for (String converterClassName : dispenser.getConverterConfigurationByClassName())
{
runtimeConfig.addConverterConfiguration(converterClassName,
- _dispenser.getConverterConfiguration(converterClassName));
+ _dispenser.getConverterConfiguration(converterClassName));
}
for (ResourceBundle bundle : dispenser.getResourceBundles())
@@ -743,70 +760,78 @@ public class FacesConfigurator
for (String className : dispenser.getElResolvers())
{
- runtimeConfig.addFacesConfigElResolver((ELResolver)ClassUtils.newInstance(className, ELResolver.class));
+ runtimeConfig.addFacesConfigElResolver((ELResolver) ClassUtils.newInstance(className, ELResolver.class));
}
-
- runtimeConfig.setFacesVersion (dispenser.getFacesVersion());
-
+
+ runtimeConfig.setFacesVersion(dispenser.getFacesVersion());
+
runtimeConfig.setNamedEventManager(new NamedEventManager());
-
+
for (NamedEvent event : dispenser.getNamedEvents())
{
try
{
Class<? extends ComponentSystemEvent> clazz = ClassUtils.classForName(event.getEventClass());
- runtimeConfig.getNamedEventManager().addNamedEvent(event.getShortName(), clazz);
- } catch (ClassNotFoundException e) {
- log.log(Level.SEVERE, "Named event could not be initialized, reason:",e);
+ runtimeConfig.getNamedEventManager().addNamedEvent(event.getShortName(), clazz);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.log(Level.SEVERE, "Named event could not be initialized, reason:", e);
}
}
String comparatorClass = _externalContext.getInitParameter(ResolverBuilderBase.EL_RESOLVER_COMPARATOR);
-
+
if (comparatorClass != null && !"".equals(comparatorClass))
{
// get the comparator class
Class<Comparator<ELResolver>> clazz;
- try {
+ try
+ {
clazz = (Class<Comparator<ELResolver>>) ClassUtils.classForName(comparatorClass);
// create the instance
Comparator<ELResolver> comparator = ClassUtils.newInstance(clazz);
-
+
runtimeConfig.setELResolverComparator(comparator);
- } catch (Exception e)
+ }
+ catch (Exception e)
{
if (log.isLoggable(Level.SEVERE))
{
- log.log(Level.SEVERE, "Cannot instantiate EL Resolver Comparator "+ comparatorClass+
- " . Check org.apache.myfaces.EL_RESOLVER_COMPARATOR web config param. Initialization continues with no comparator used.", e);
+ log.log(Level.SEVERE, "Cannot instantiate EL Resolver Comparator " + comparatorClass
+ + " . Check org.apache.myfaces.EL_RESOLVER_COMPARATOR web config param. "
+ + "Initialization continues with no comparator used.", e);
}
- }
+ }
}
else
{
runtimeConfig.setELResolverComparator(null);
}
-
+
String elResolverPredicateClass = _externalContext.getInitParameter(ResolverBuilderBase.EL_RESOLVER_PREDICATE);
-
+
if (elResolverPredicateClass != null && !"".equals(elResolverPredicateClass))
{
// get the comparator class
Class<Predicate> clazz;
- try {
+ try
+ {
clazz = (Class<Predicate>) ClassUtils.classForName(elResolverPredicateClass);
// create the instance
Predicate elResolverPredicate = ClassUtils.newInstance(clazz);
-
+
runtimeConfig.setELResolverPredicate(elResolverPredicate);
- } catch (Exception e)
+ }
+ catch (Exception e)
{
if (log.isLoggable(Level.SEVERE))
{
- log.log(Level.SEVERE, "Cannot instantiate EL Resolver Comparator "+ comparatorClass+
- " . Check org.apache.myfaces.EL_RESOLVER_COMPARATOR web config param. Initialization continues with no comparator used.", e);
+ log.log(Level.SEVERE, "Cannot instantiate EL Resolver Comparator " + comparatorClass
+ + " . Check org.apache.myfaces.EL_RESOLVER_COMPARATOR web config param. "
+ + "Initialization continues with no comparator used.", e);
}
- }
+ }
}
else
{
@@ -840,13 +865,14 @@ public class FacesConfigurator
}
}
}
-
+
runtimeConfig.resetManagedBeansNotReaddedAfterPurge();
}
private void configureRenderKits()
{
- RenderKitFactory renderKitFactory = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKitFactory renderKitFactory
+ = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
FacesConfigData dispenser = getDispenser();
for (String renderKitId : dispenser.getRenderKitIds())
@@ -865,8 +891,9 @@ public class FacesConfigurator
for (Renderer element : dispenser.getRenderers(renderKitId))
{
javax.faces.render.Renderer renderer;
- Collection<ClientBehaviorRenderer> clientBehaviorRenderers = dispenser.getClientBehaviorRenderers (renderKitId);
-
+ Collection<ClientBehaviorRenderer> clientBehaviorRenderers
+ = dispenser.getClientBehaviorRenderers(renderKitId);
+
try
{
renderer = (javax.faces.render.Renderer) ClassUtils.newInstance(element.getRendererClass());
@@ -879,23 +906,28 @@ public class FacesConfigurator
}
renderKit.addRenderer(element.getComponentFamily(), element.getRendererType(), renderer);
-
+
// Add in client behavior renderers.
-
- for (ClientBehaviorRenderer clientBehaviorRenderer : clientBehaviorRenderers) {
- try {
- javax.faces.render.ClientBehaviorRenderer behaviorRenderer = (javax.faces.render.ClientBehaviorRenderer)
- ClassUtils.newInstance (clientBehaviorRenderer.getRendererClass());
-
+
+ for (ClientBehaviorRenderer clientBehaviorRenderer : clientBehaviorRenderers)
+ {
+ try
+ {
+ javax.faces.render.ClientBehaviorRenderer behaviorRenderer
+ = (javax.faces.render.ClientBehaviorRenderer)
+ ClassUtils.newInstance(clientBehaviorRenderer.getRendererClass());
+
renderKit.addClientBehaviorRenderer(clientBehaviorRenderer.getRendererType(), behaviorRenderer);
}
-
- catch (Throwable e) {
+
+ catch (Throwable e)
+ {
// Ignore.
-
- if (log.isLoggable(Level.SEVERE)) {
+
+ if (log.isLoggable(Level.SEVERE))
+ {
log.log(Level.SEVERE, "failed to configure client behavior renderer class " +
- clientBehaviorRenderer.getRendererClass(), e);
+ clientBehaviorRenderer.getRendererClass(), e);
}
}
}
@@ -923,11 +955,11 @@ public class FacesConfigurator
log.severe("Class " + listenerClassName + " does not implement PhaseListener");
}
}
-
+
// if ProjectStage is Development, install the DebugPhaseListener
FacesContext facesContext = FacesContext.getCurrentInstance();
- if (facesContext.isProjectStage(ProjectStage.Development) &&
- MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isDebugPhaseListenerEnabled())
+ if (facesContext.isProjectStage(ProjectStage.Development) &&
+ MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isDebugPhaseListenerEnabled())
{
lifecycle.addPhaseListener(new DebugPhaseListener());
}
@@ -968,7 +1000,7 @@ public class FacesConfigurator
}
catch (Exception e)
{
- log.log(Level.SEVERE,"", e);
+ log.log(Level.SEVERE, "", e);
}
finally
{
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java?rev=1188686&r1=1188685&r2=1188686&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/AnnotationConfigurator.java Tue Oct 25 14:59:52 2011
@@ -54,7 +54,7 @@ import org.apache.myfaces.spi.Annotation
/**
* Configure all annotations that needs to be defined at startup.
- *
+ *
* <ul>
* <li>{@link javax.faces.component.FacesComponent}</li>
* <li>{@link javax.faces.convert.FacesConverter}</li>
@@ -67,7 +67,7 @@ import org.apache.myfaces.spi.Annotation
* <p>
* Some parts copied from org.apache.shale.tiger.view.faces.LifecycleListener2
* </p>
- *
+ *
* @since 2.0
* @author Leonardo Uribe (latest modification by $Author$)
* @version $Revision$ $Date$
@@ -86,32 +86,24 @@ public class AnnotationConfigurator
{
}
- public FacesConfig createFacesConfig(ExternalContext _externalContext, boolean metadataComplete)
+ public FacesConfig createFacesConfig(ExternalContext externalcontext, boolean metadataComplete)
{
if (!metadataComplete)
{
- AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(_externalContext).getAnnotationProvider(_externalContext);
- Map<Class<? extends Annotation>,Set<Class<?>>> map = provider.getAnnotatedClasses(_externalContext);
+ AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(externalcontext).
+ getAnnotationProvider(externalcontext);
+ Map<Class<? extends Annotation>, Set<Class<?>>> map = provider.getAnnotatedClasses(externalcontext);
return createFacesConfig(map);
}
return null;
}
- /*
- public void configure(final Application application,
- final FacesConfigDispenser<FacesConfig> dispenser,
- boolean metadataComplete) throws FacesException
- {
- AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(_externalContext).createAnnotationProvider(_externalContext);
- Map<Class<? extends Annotation>,Set<Class<?>>> map = provider.getAnnotatedClasses(_externalContext);
- configureClasses(application, dispenser, map);
- }*/
-
- protected FacesConfig createFacesConfig(Map< Class<? extends Annotation>, Set<Class<?>> > map)
+
+ protected FacesConfig createFacesConfig(Map<Class<? extends Annotation>, Set<Class<?>>> map)
{
FacesConfig facesConfig = new FacesConfig();
-
+
Set<Class<?>> classes = map.get(FacesComponent.class);
-
+
if (classes != null && !classes.isEmpty())
{
for (Class<?> clazz : classes)
@@ -125,12 +117,12 @@ public class AnnotationConfigurator
log.finest("addComponent(" + comp.value() + ","
+ clazz.getName() + ")");
}
-
+
facesConfig.addComponent(comp.value(), clazz.getName());
}
}
}
-
+
classes = map.get(FacesConverter.class);
if (classes != null && !classes.isEmpty())
{
@@ -156,28 +148,30 @@ public class AnnotationConfigurator
{
converter.setForClass(conv.forClass().getName());
}
- if (hasValue) {
+ if (hasValue)
+ {
converter.setConverterId(conv.value());
}
converter.setConverterClass(clazz.getName());
facesConfig.addConverter(converter);
}
else
- {
+ {
// TODO MartinKoci MYFACES-3053
- throw new FacesException("@FacesConverter must have value, forClass or both. Check annotation @FacesConverter on class: " + clazz.getName());
+ throw new FacesException("@FacesConverter must have value, forClass or both. Check annotation "
+ + "@FacesConverter on class: " + clazz.getName());
}
- }
+ }
}
}
-
+
classes = map.get(FacesValidator.class);
if (classes != null && !classes.isEmpty())
{
for (Class<?> clazz : classes)
{
FacesValidator val = (FacesValidator) clazz
- .getAnnotation(FacesValidator.class);
+ .getAnnotation(FacesValidator.class);
if (val != null)
{
if (log.isLoggable(Level.FINEST))
@@ -189,7 +183,7 @@ public class AnnotationConfigurator
if (val.isDefault())
{
Application app = null;
- if(facesConfig.getApplications().isEmpty())
+ if (facesConfig.getApplications().isEmpty())
{
app = new Application();
}
@@ -209,7 +203,7 @@ public class AnnotationConfigurator
for (Class<?> clazz : classes)
{
FacesRenderer rend = (FacesRenderer) clazz
- .getAnnotation(FacesRenderer.class);
+ .getAnnotation(FacesRenderer.class);
if (rend != null)
{
String renderKitId = rend.renderKitId();
@@ -223,22 +217,23 @@ public class AnnotationConfigurator
+ rend.componentFamily() + ", " + rend.rendererType()
+ ", " + clazz.getName() + ")");
}
-
+
org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
- (org.apache.myfaces.config.impl.digester.elements.RenderKit) facesConfig.getRenderKit(renderKitId);
+ (org.apache.myfaces.config.impl.digester.elements.RenderKit)
+ facesConfig.getRenderKit(renderKitId);
if (renderKit == null)
{
renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
facesConfig.addRenderKit(renderKit);
}
-
+
org.apache.myfaces.config.impl.digester.elements.Renderer renderer =
- new org.apache.myfaces.config.impl.digester.elements.Renderer();
+ new org.apache.myfaces.config.impl.digester.elements.Renderer();
renderer.setComponentFamily(rend.componentFamily());
renderer.setRendererClass(clazz.getName());
renderer.setRendererType(rend.rendererType());
renderKit.addRenderer(renderer);
- }
+ }
}
}
@@ -247,47 +242,49 @@ public class AnnotationConfigurator
{
for (Class<?> clazz : classes)
{
- javax.faces.bean.ManagedBean bean =
- (javax.faces.bean.ManagedBean) clazz.getAnnotation(javax.faces.bean.ManagedBean.class);
-
+ javax.faces.bean.ManagedBean bean =
+ (javax.faces.bean.ManagedBean) clazz.getAnnotation(javax.faces.bean.ManagedBean.class);
+
if (bean != null)
{
if (log.isLoggable(Level.FINE))
{
log.fine("Class '" + clazz.getName() + "' has an @ManagedBean annotation");
}
-
+
org.apache.myfaces.config.impl.digester.elements.ManagedBean mbc =
- new org.apache.myfaces.config.impl.digester.elements.ManagedBean();
+ new org.apache.myfaces.config.impl.digester.elements.ManagedBean();
String beanName = bean.name();
-
- if ((beanName == null) || beanName.equals ("")) {
+
+ if ((beanName == null) || beanName.equals(""))
+ {
int index;
-
+
// Missing name attribute algorithm: take the unqualified name and make the
// first character lowercase.
-
+
beanName = clazz.getName();
- index = beanName.lastIndexOf (".");
-
- if (index != -1) {
- beanName = beanName.substring (index + 1);
- }
-
- beanName = Character.toLowerCase (beanName.charAt (0)) +
- beanName.substring (1);
+ index = beanName.lastIndexOf(".");
+
+ if (index != -1)
+ {
+ beanName = beanName.substring(index + 1);
+ }
+
+ beanName = Character.toLowerCase(beanName.charAt(0)) +
+ beanName.substring(1);
}
-
+
mbc.setName(beanName);
mbc.setEager(Boolean.toString(bean.eager()));
mbc.setBeanClass(clazz.getName());
-
+
ApplicationScoped appScoped = (ApplicationScoped) clazz.getAnnotation(ApplicationScoped.class);
if (appScoped != null)
{
mbc.setScope("application");
}
-
+
else
{
NoneScoped noneScoped = (NoneScoped) clazz.getAnnotation(NoneScoped.class);
@@ -295,7 +292,7 @@ public class AnnotationConfigurator
{
mbc.setScope("none");
}
-
+
else
{
RequestScoped requestScoped = (RequestScoped) clazz.getAnnotation(RequestScoped.class);
@@ -303,7 +300,7 @@ public class AnnotationConfigurator
{
mbc.setScope("request");
}
-
+
else
{
SessionScoped sessionScoped = (SessionScoped) clazz.getAnnotation(SessionScoped.class);
@@ -311,7 +308,7 @@ public class AnnotationConfigurator
{
mbc.setScope("session");
}
-
+
else
{
ViewScoped viewScoped = (ViewScoped) clazz.getAnnotation(ViewScoped.class);
@@ -319,26 +316,28 @@ public class AnnotationConfigurator
{
mbc.setScope("view");
}
-
- else {
- CustomScoped customScoped = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
+
+ else
+ {
+ CustomScoped customScoped
+ = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
if (customScoped != null)
{
mbc.setScope(customScoped.value());
}
-
+
else
{
// No scope annotation means default of "request".
-
- mbc.setScope ("request");
+
+ mbc.setScope("request");
}
}
}
}
}
}
-
+
Field[] fields = fields(clazz);
for (Field field : fields)
{
@@ -355,8 +354,8 @@ public class AnnotationConfigurator
log.fine(" Field '" + field.getName()
+ "' has a @ManagedProperty annotation");
}
- org.apache.myfaces.config.impl.digester.elements.ManagedProperty mpc =
- new org.apache.myfaces.config.impl.digester.elements.ManagedProperty();
+ org.apache.myfaces.config.impl.digester.elements.ManagedProperty mpc =
+ new org.apache.myfaces.config.impl.digester.elements.ManagedProperty();
String name = property.name();
if ((name == null) || "".equals(name))
{
@@ -370,7 +369,7 @@ public class AnnotationConfigurator
}
}
facesConfig.addManagedBean(mbc);
- }
+ }
}
}
@@ -379,89 +378,102 @@ public class AnnotationConfigurator
{
for (Class<?> clazz : classes)
{
- NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation (NamedEvent.class);
-
- if (namedEvent != null) {
+ NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation(NamedEvent.class);
+
+ if (namedEvent != null)
+ {
// Can only apply @NamedEvent to ComponentSystemEvent subclasses.
-
- if (!ComponentSystemEvent.class.isAssignableFrom (clazz)) {
+
+ if (!ComponentSystemEvent.class.isAssignableFrom(clazz))
+ {
// Just log this. We'll catch it later in the runtime.
-
- if (log.isLoggable(Level.WARNING)) {
- log.warning (clazz.getName() + " is annotated with @javax.faces.event.NamedEvent, but does " +
- "not extend javax.faces.event.ComponentSystemEvent");
+
+ if (log.isLoggable(Level.WARNING))
+ {
+ log.warning(clazz.getName() + " is annotated with @javax.faces.event.NamedEvent, but does "
+ + "not extend javax.faces.event.ComponentSystemEvent");
}
}
// Have to register @NamedEvent annotations with the NamedEventManager class since
// we need to get access to this info later and can't from the dispenser (it's not a
// singleton).
- org.apache.myfaces.config.impl.digester.elements.NamedEvent namedEventConfig =
- new org.apache.myfaces.config.impl.digester.elements.NamedEvent();
+ org.apache.myfaces.config.impl.digester.elements.NamedEvent namedEventConfig =
+ new org.apache.myfaces.config.impl.digester.elements.NamedEvent();
namedEventConfig.setEventClass(clazz.getName());
namedEventConfig.setShortName(namedEvent.shortName());
facesConfig.addNamedEvent(namedEventConfig);
}
}
}
-
+
classes = map.get(FacesBehavior.class);
if (classes != null && !classes.isEmpty())
{
for (Class<?> clazz : classes)
{
- FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation (FacesBehavior.class);
-
- if (facesBehavior != null) {
+ FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation(FacesBehavior.class);
+
+ if (facesBehavior != null)
+ {
// Can only apply @FacesBehavior to Behavior implementors.
-
- if (!javax.faces.component.behavior.Behavior.class.isAssignableFrom (clazz)) {
+
+ if (!javax.faces.component.behavior.Behavior.class.isAssignableFrom(clazz))
+ {
// Just log this. We'll catch it later in the runtime.
-
- if (log.isLoggable(Level.WARNING)) {
- log.warning (clazz.getName() + " is annotated with @javax.faces.component.behavior.FacesBehavior, " +
- "but does not implement javax.faces.component.behavior.Behavior");
+
+ if (log.isLoggable(Level.WARNING))
+ {
+ log.warning(clazz.getName()
+ + " is annotated with @javax.faces.component.behavior.FacesBehavior, "
+ + "but does not implement javax.faces.component.behavior.Behavior");
}
}
-
- if (log.isLoggable(Level.FINEST)) {
- log.finest ("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ")");
+
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ")");
}
-
+
Behavior behavior = new Behavior();
behavior.setBehaviorId(facesBehavior.value());
behavior.setBehaviorClass(clazz.getName());
facesConfig.addBehavior(behavior);
}
-
+
}
}
-
+
classes = map.get(FacesBehaviorRenderer.class);
if (classes != null && !classes.isEmpty())
{
for (Class<?> clazz : classes)
{
- FacesBehaviorRenderer facesBehaviorRenderer = (FacesBehaviorRenderer) clazz.getAnnotation (FacesBehaviorRenderer.class);
-
- if (facesBehaviorRenderer != null) {
+ FacesBehaviorRenderer facesBehaviorRenderer
+ = (FacesBehaviorRenderer) clazz.getAnnotation(FacesBehaviorRenderer.class);
+
+ if (facesBehaviorRenderer != null)
+ {
String renderKitId = facesBehaviorRenderer.renderKitId();
//RenderKit renderKit;
-
- if (log.isLoggable(Level.FINEST)) {
- log.finest ("addClientBehaviorRenderer(" + renderKitId + ", " + facesBehaviorRenderer.rendererType() + ", " +
- clazz.getName() + ")");
+
+ if (log.isLoggable(Level.FINEST))
+ {
+ log.finest("addClientBehaviorRenderer(" + renderKitId + ", "
+ + facesBehaviorRenderer.rendererType() + ", "
+ + clazz.getName() + ")");
}
-
+
org.apache.myfaces.config.impl.digester.elements.RenderKit renderKit =
- (org.apache.myfaces.config.impl.digester.elements.RenderKit) facesConfig.getRenderKit(renderKitId);
+ (org.apache.myfaces.config.impl.digester.elements.RenderKit)
+ facesConfig.getRenderKit(renderKitId);
if (renderKit == null)
{
renderKit = new org.apache.myfaces.config.impl.digester.elements.RenderKit();
facesConfig.addRenderKit(renderKit);
}
-
- org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer cbr =
- new org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer();
+
+ org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer cbr =
+ new org.apache.myfaces.config.impl.digester.elements.ClientBehaviorRenderer();
cbr.setRendererType(facesBehaviorRenderer.rendererType());
cbr.setRendererClass(clazz.getName());
renderKit.addClientBehaviorRenderer(cbr);
@@ -470,383 +482,6 @@ public class AnnotationConfigurator
}
return facesConfig;
}
-
- /*
- protected void configureClasses( Application application,
- FacesConfigDispenser<FacesConfig> dispenser,
- Map< Class<? extends Annotation>, Set<Class<?>> > map)
- {
- Set<Class<?>> classes = map.get(FacesComponent.class);
-
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesComponent comp = (FacesComponent) clazz
- .getAnnotation(FacesComponent.class);
- if (comp != null)
- {
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addComponent(" + comp.value() + ","
- + clazz.getName() + ")");
- }
-
- //If there is a previous entry on Application Configuration Resources,
- //the entry there takes precedence
- if (dispenser.getComponentClass(comp.value()) == null)
- {
- application.addComponent(comp.value(), clazz.getName());
- }
- }
- }
- }
-
- classes = map.get(FacesConverter.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesConverter conv = (FacesConverter) clazz
- .getAnnotation(FacesConverter.class);
- if (conv != null)
- {
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addConverter(" + conv.value() + ","
- + clazz.getName() + ")");
- }
- //If there is a previous entry on Application Configuration Resources,
- //the entry there takes precedence
- if (!Object.class.equals(conv.forClass()))
- {
- application.addConverter(conv.forClass(), clazz.getName());
- }
- if (dispenser.getConverterClassById(conv.value()) == null &&
- conv.value() != null && !"".equals(conv.value()))
- {
- application.addConverter(conv.value(), clazz.getName());
- }
- }
- }
- }
-
- classes = map.get(FacesValidator.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesValidator val = (FacesValidator) clazz
- .getAnnotation(FacesValidator.class);
- if (val != null)
- {
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addValidator(" + val.value() + "," + clazz.getName()
- + ")");
- }
- //If there is a previous entry on Application Configuration Resources,
- //the entry there takes precedence
- if (dispenser.getValidatorClass(val.value()) == null)
- {
- application.addValidator(val.value(), clazz.getName());
- if (val.isDefault())
- {
- application.addDefaultValidatorId(val.value());
- }
- }
- }
- }
- }
-
- classes = map.get(FacesRenderer.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesRenderer rend = (FacesRenderer) clazz
- .getAnnotation(FacesRenderer.class);
- if (rend != null)
- {
- String renderKitId = rend.renderKitId();
- if (renderKitId == null)
- {
- renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
- if (log.isLoggable(Level.FINEST))
- {
- log.finest("addRenderer(" + renderKitId + ", "
- + rend.componentFamily() + ", " + rend.rendererType()
- + ", " + clazz.getName() + ")");
- }
- try
- {
- RenderKit rk = renderKitFactory().getRenderKit(null,
- renderKitId);
- if (rk == null)
- {
- if (log.isLoggable(Level.SEVERE))
- {
- log.severe("RenderKit "+renderKitId+" not found when adding @FacesRenderer annotation");
- }
- throw new FacesException("RenderKit "+renderKitId+" not found when adding @FacesRenderer annotation");
- }
- rk.addRenderer(rend.componentFamily(), rend.rendererType(),
- (Renderer) clazz.newInstance());
- }
- catch (Exception e)
- {
- throw new FacesException(e);
- }
- }
- }
- }
-
- classes = map.get(ManagedBean.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- javax.faces.bean.ManagedBean bean =
- (javax.faces.bean.ManagedBean) clazz.getAnnotation(javax.faces.bean.ManagedBean.class);
-
- if (bean != null)
- {
- if (log.isLoggable(Level.FINE))
- {
- log.fine("Class '" + clazz.getName() + "' has an @ManagedBean annotation");
- }
- RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(_externalContext);
- org.apache.myfaces.config.impl.digester.elements.ManagedBean mbc =
- new org.apache.myfaces.config.impl.digester.elements.ManagedBean();
- String beanName = bean.name();
-
- if ((beanName == null) || beanName.equals ("")) {
- int index;
-
- // Missing name attribute algorithm: take the unqualified name and make the
- // first character lowercase.
-
- beanName = clazz.getName();
- index = beanName.lastIndexOf (".");
-
- if (index != -1) {
- beanName = beanName.substring (index + 1);
- }
-
- beanName = Character.toLowerCase (beanName.charAt (0)) +
- beanName.substring (1);
- }
-
- mbc.setName(beanName);
- mbc.setEager(Boolean.toString(bean.eager()));
- mbc.setBeanClass(clazz.getName());
-
- ApplicationScoped appScoped = (ApplicationScoped) clazz.getAnnotation(ApplicationScoped.class);
- if (appScoped != null)
- {
- mbc.setScope("application");
- }
-
- else
- {
- NoneScoped noneScoped = (NoneScoped) clazz.getAnnotation(NoneScoped.class);
- if (noneScoped != null)
- {
- mbc.setScope("none");
- }
-
- else
- {
- RequestScoped requestScoped = (RequestScoped) clazz.getAnnotation(RequestScoped.class);
- if (requestScoped != null)
- {
- mbc.setScope("request");
- }
-
- else
- {
- SessionScoped sessionScoped = (SessionScoped) clazz.getAnnotation(SessionScoped.class);
- if (sessionScoped != null)
- {
- mbc.setScope("session");
- }
-
- else
- {
- ViewScoped viewScoped = (ViewScoped) clazz.getAnnotation(ViewScoped.class);
- if (viewScoped != null)
- {
- mbc.setScope("view");
- }
-
- else {
- CustomScoped customScoped = (CustomScoped) clazz.getAnnotation(CustomScoped.class);
- if (customScoped != null)
- {
- mbc.setScope(customScoped.value());
- }
-
- else
- {
- // No scope annotation means default of "request".
-
- mbc.setScope ("request");
- }
- }
- }
- }
- }
- }
-
- Field[] fields = fields(clazz);
- for (Field field : fields)
- {
- if (log.isLoggable(Level.FINEST))
- {
- log.finest(" Scanning field '" + field.getName() + "'");
- }
- javax.faces.bean.ManagedProperty property = (javax.faces.bean.ManagedProperty) field
- .getAnnotation(javax.faces.bean.ManagedProperty.class);
- if (property != null)
- {
- if (log.isLoggable(Level.FINE))
- {
- log.fine(" Field '" + field.getName()
- + "' has a @ManagedProperty annotation");
- }
- org.apache.myfaces.config.impl.digester.elements.ManagedProperty mpc =
- new org.apache.myfaces.config.impl.digester.elements.ManagedProperty();
- String name = property.name();
- if ((name == null) || "".equals(name))
- {
- name = field.getName();
- }
- mpc.setPropertyName(name);
- mpc.setPropertyClass(field.getType().getName()); // FIXME - primitives, arrays, etc.
- mpc.setValue(property.value());
- mbc.addProperty(mpc);
- continue;
- }
- }
- runtimeConfig.addManagedBean(mbc.getManagedBeanName(), mbc);
- }
- }
- }
-
- classes = map.get(NamedEvent.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- NamedEvent namedEvent = (NamedEvent) clazz.getAnnotation (NamedEvent.class);
-
- if (namedEvent != null) {
- // Can only apply @NamedEvent to ComponentSystemEvent subclasses.
-
- if (!ComponentSystemEvent.class.isAssignableFrom (clazz)) {
- // Just log this. We'll catch it later in the runtime.
-
- if (log.isLoggable(Level.WARNING)) {
- log.warning (clazz.getName() + " is annotated with @javax.faces.event.NamedEvent, but does " +
- "not extend javax.faces.event.ComponentSystemEvent");
- }
-
- return;
- }
-
- // Have to register @NamedEvent annotations with the NamedEventManager class since
- // we need to get access to this info later and can't from the dispenser (it's not a
- // singleton).
-
- NamedEventManager.getInstance().addNamedEvent (namedEvent.shortName(),
- (Class<? extends ComponentSystemEvent>) clazz);
- }
- }
- }
-
- classes = map.get(FacesBehavior.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesBehavior facesBehavior = (FacesBehavior) clazz.getAnnotation (FacesBehavior.class);
-
- if (facesBehavior != null) {
- // Can only apply @FacesBehavior to Behavior implementors.
-
- if (!Behavior.class.isAssignableFrom (clazz)) {
- // Just log this. We'll catch it later in the runtime.
-
- if (log.isLoggable(Level.WARNING)) {
- log.warning (clazz.getName() + " is annotated with @javax.faces.component.behavior.FacesBehavior, " +
- "but does not implement javax.faces.component.behavior.Behavior");
- }
- }
-
- if (log.isLoggable(Level.FINEST)) {
- log.finest ("addBehavior(" + facesBehavior.value() + ", " + clazz.getName() + ")");
- }
-
- application.addBehavior (facesBehavior.value(), clazz.getName());
- }
-
- }
- }
-
- classes = map.get(FacesBehaviorRenderer.class);
- if (classes != null && !classes.isEmpty())
- {
- for (Class<?> clazz : classes)
- {
- FacesBehaviorRenderer facesBehaviorRenderer = (FacesBehaviorRenderer) clazz.getAnnotation (FacesBehaviorRenderer.class);
-
- if (facesBehaviorRenderer != null) {
- String renderKitId = facesBehaviorRenderer.renderKitId();
- RenderKit renderKit;
-
- if (log.isLoggable(Level.FINEST)) {
- log.finest ("addClientBehaviorRenderer(" + renderKitId + ", " + facesBehaviorRenderer.rendererType() + ", " +
- clazz.getName() + ")");
- }
-
- try {
- ClientBehaviorRenderer clientBehaviorRenderer;
-
- renderKit = renderKitFactory().getRenderKit (null, renderKitId);
-
- clientBehaviorRenderer = (ClientBehaviorRenderer) clazz.newInstance();
-
- renderKit.addClientBehaviorRenderer(facesBehaviorRenderer.rendererType(), clientBehaviorRenderer);
- }
-
- catch (Throwable e) {
- throw new FacesException (e);
- }
- }
- }
- }
- */
- /*
- ListenerFor listenerFor = (ListenerFor) clazz.getAnnotation(ListenerFor.class);
- if (listenerFor != null)
- {
- processListenerFor(application, clazz, listenerFor);
- }
-
- ListenersFor listenersFor = (ListenersFor) clazz.getAnnotation(ListenersFor.class);
- if (listenersFor != null)
- {
- for (ListenerFor item : listenersFor.value())
- {
- processListenerFor(application, clazz, item);
- }
- }*/
-
- // TODO: All annotations scanned at startup must be configured here!
- /*
- }
- */
/**
* <p>Return an array of all <code>Field</code>s reflecting declared
@@ -855,33 +490,23 @@ public class AnnotationConfigurator
*
* @param clazz Class to be analyzed
*/
- private Field[] fields(Class<?> clazz) {
+ private Field[] fields(Class<?> clazz)
+ {
- Map<String,Field> fields = new HashMap<String,Field>();
- do {
- for (Field field : clazz.getDeclaredFields()) {
- if (!fields.containsKey(field.getName())) {
+ Map<String, Field> fields = new HashMap<String, Field>();
+ do
+ {
+ for (Field field : clazz.getDeclaredFields())
+ {
+ if (!fields.containsKey(field.getName()))
+ {
fields.put(field.getName(), field);
}
}
- } while ((clazz = clazz.getSuperclass()) != Object.class);
+ }
+ while ((clazz = clazz.getSuperclass()) != Object.class);
+
return (Field[]) fields.values().toArray(new Field[fields.size()]);
}
-
- /**
- * <p>Return the <code>RenderKitFactory</code> for this application.</p>
- */
- /*
- private RenderKitFactory renderKitFactory()
- {
-
- if (rkFactory == null)
- {
- rkFactory = (RenderKitFactory) FactoryFinder
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- }
- return rkFactory;
-
- }*/
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java?rev=1188686&r1=1188685&r2=1188686&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/config/annotation/DefaultAnnotationProvider.java Tue Oct 25 14:59:52 2011
@@ -120,7 +120,7 @@ public class DefaultAnnotationProvider e
byteCodeAnnotationsNames = Collections.unmodifiableSet(bcan);
}
- private static Set<Class<? extends Annotation>> JSF_ANNOTATION_CLASSES;
+ private static final Set<Class<? extends Annotation>> JSF_ANNOTATION_CLASSES;
static
{
@@ -166,7 +166,8 @@ public class DefaultAnnotationProvider e
//2. Scan for annotations on classpath
try
{
- AnnotationProvider provider = AnnotationProviderFactory.getAnnotationProviderFactory(ctx).getAnnotationProvider(ctx);
+ AnnotationProvider provider
+ = AnnotationProviderFactory.getAnnotationProviderFactory(ctx).getAnnotationProvider(ctx);
classes = getAnnotatedMetaInfClasses(ctx, provider.getBaseUrls());
}
catch (IOException e)
@@ -417,11 +418,11 @@ public class DefaultAnnotationProvider e
}
catch (NoClassDefFoundError e)
{
- ; // Skip this class - we cannot analyze classes we cannot load
+ // Skip this class - we cannot analyze classes we cannot load
}
catch (Exception e)
{
- ; // Skip this class - we cannot analyze classes we cannot load
+ // Skip this class - we cannot analyze classes we cannot load
}
if (clazz != null)
{
@@ -559,11 +560,11 @@ public class DefaultAnnotationProvider e
}
catch (NoClassDefFoundError e)
{
- ; // Skip this class - we cannot analyze classes we cannot load
+ // Skip this class - we cannot analyze classes we cannot load
}
catch (Exception e)
{
- ; // Skip this class - we cannot analyze classes we cannot load
+ // Skip this class - we cannot analyze classes we cannot load
}
if (clazz != null)
{