You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2010/09/10 06:48:05 UTC

[jira] Updated: (WICKET-1996) Rework PackageResource and ResourceReferences

     [ https://issues.apache.org/jira/browse/WICKET-1996?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg updated WICKET-1996:
----------------------------------

    Fix Version/s: 1.5-M3
                       (was: 1.5-M2)

> Rework PackageResource and ResourceReferences
> ---------------------------------------------
>
>                 Key: WICKET-1996
>                 URL: https://issues.apache.org/jira/browse/WICKET-1996
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>            Reporter: Juergen Donnerstag
>            Assignee: Juergen Donnerstag
>             Fix For: 1.5-M3
>
>         Attachments: wicket-1996.patch
>
>
> while working on wicket-1992 and looking at PackageResource and it subclasses, and ResourceReference and its subclasses I couldn't stop making changes because of code which - I guess - is as it is because of historic reasons. E.g. shared resources must be registered which is not longer valid since shared resources are now lazily loaded. Below is a list of changes, which can not be done to 1.4 since they change behavior and are not fixing bug, but they should make into 1.5
> A)
> 1) PackageResouce.get() creates new PackagedResources if not found in the shared resources cache. We should either change the name or do not create a new resource. Javadoc does not state that a new resource is created.
> 2) Subclasses of PackageResource have copies of the very same method, except that they also register the new resource with the shared resources cash. Which probably is the correct way if we really want to create new resources in a get method.
> 3) There is no way to determine if get() created a new resource or if a new resource was created
> 4) Because there is no way for subclasses to create their own resources, e.g. JavascriptPackageResource, get() was copied.
> 5) bind() is not much different to get() currently except that bind() validates that the new resource exists. If the resource does not exist, an exception is thrown. It is no longer obvious which method get() / bind() should be used when and what there real purpose is
> In my opinion get() should simply check the cache and nothing more. And get() should be made final.
> B)
> I'm not very much in favor of static methods. They carry the risk, if not careful, that more than one wicket application can not be deployed without interfereing with each other. I'm the last one to consider everything at any time. In my opinion we should remove all static methods from PackageResource except get() for convience reasons and move the bind() logic into the constructor. This makes subclassing PackageResource more easy as well. You would simply do 
> resource = PackageResource.get().
> if (resource == null) 
> {
>    resource = new JavascriptPackageResouce(...);
> }
> C)
> I don't think ResouceReference serve any real purpose any more. I would remove them all.
> I'll attach my working copy in case you are interested.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.