You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Rudy De Busscher <rd...@gmail.com> on 2010/02/24 09:23:08 UTC
[ExtVal] ExtVal-metadata-provider addon (performance) improvement
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
Re: [ExtVal] ExtVal-metadata-provider addon (performance) improvement
Posted by Gerhard Petracek <ge...@gmail.com>.
hi rudy,
thx for providing the improvement.
i'll have a look at it after the jsfdays.
regards,
gerhard
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces
2010/2/24 Rudy De Busscher <rd...@gmail.com>
> 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
>