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
property.

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)
    {
        if(this.metaDataProviderStorage.containsKey(sourceClass))
        {
            return this.metaDataProviderStorage.get(sourceClass);
        }

        try
        {
            for(Class foundProvider :
processTarget(sourceClass.getPackage().getName()))
            {
                addMetaDataProvider(sourceClass, foundProvider,
this.metaDataProviderStorage);
            }

        }
        catch(Throwable t)
        {
            if(this.logger.isWarnEnabled())
            {
                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.

regards
Rudy

Reply via email to