myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rudy De Busscher <>
Subject [ExtVal] ExtVal-metadata-provider addon (performance) improvement
Date Wed, 24 Feb 2010 08:23:08 GMT
Hi all,

With the Extval metadata provider addon, the developer has the possibility
to specify the packages that needs to be scanned for the @MetaDataProvider.
However, doing this, results in some performance penalty.

During initialization of the MetaDataProviderStorage class, it stores the
information in the property customMetaDataProviderStorage.  This property is
not consulted (not immediately) when a metadata provider class is requested
from the storage.  And the scanning is performed again in the method
getMetaDataProviderClassFor and now kept in metaDataProviderStorage

As a side effect of keeping 2 properties, the result of the method is a list
that contains twice the metadata provider class. The doubles are handled
correctly in the
MetaDataProviderScanningInterceptor.createAdditionalMetaDataEntries and thus
only processed once (but instantiated twice)

The advanced metadata addon has the same 'defect'.

Possible solutions
1) keep the 2 properties (customMetaDataProviderStorage and
metaDataProviderStorage) but add following code just before the try in the
getMetaDataProviderClassFor method

*        if(this.customMetaDataProviderStorage.containsKey(sourceClass))
            return this.customMetaDataProviderStorage.get(sourceClass);
although rewrite is a better option.

2) remove the 'double' storage property (remove the
customMetaDataProviderStorage) and the getMetaDataProviderClassFor method
could look like this:
   * public List<Class> getMetaDataProviderClassFor(Class sourceClass)
            return this.metaDataProviderStorage.get(sourceClass);

            for(Class foundProvider :
                addMetaDataProvider(sourceClass, foundProvider,

        catch(Throwable t)
                this.logger.warn("unable to setup annotation based metadata
provider for " + sourceClass.getName(), t);

            this.metaDataProviderStorage.put(sourceClass, null);

        return this.metaDataProviderStorage.get(sourceClass);

and use the metaDataProviderStorage in the constructor instead of the
removed property.


View raw message