You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kent Tong <ke...@cpttm.org.mo> on 2007/08/05 15:13:58 UTC

resource reference vs resource

Hi,

I'm having some doubts about why the concept of resource reference is 
needed; it seems resource already suffices. As I understand the purpose
of resource reference is to reduce the memory used and the need to
replicate changes in a cluster. However, a resource can also generate
or load the data on demand. In fact, most important resource classes
in Wicket are already doing that (PackageResource, DynamicWebResource
and etc). So a resource typically only takes just as little memory as
a resource reference.

It's true that a resource has some extra features like 
onResourceRequested() that are not needed by users of resource
reference. However, I really doubt that this is the real reason for 
creating the concept of resource references.

Thanks for any info!



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: resource reference vs resource

Posted by Matej Knopp <ma...@gmail.com>.
I think it has more to do with the resource URL generation. The
ResourceReference registers itself with application (using the Scope
and name parameters). Then the application uses those information to
generate resource reference url and looks up the resource reference on
request.

While regular resources (without using resource reference) are bound
to the component so the component path is used to generate resource
URL.

I don't say current approach is the best one or most transparent, but
we need to have a way to generate unique URL for shared Resources (as
now we do with help of ResourceReference) and be able to lookup the
Resource instance on request.

-Matej

On 8/8/07, Kent Tong <ke...@cpttm.org.mo> wrote:
> Matej Knopp <matej.knopp <at> gmail.com> writes:
>
> > Yeah, ResourceReference is like global resource factory. That is for
> > resources that don't belong to any component/page (they can't touch
> > any component instance while they are served).
>
> However, I don't understand why we should not just use static class
> members like:
>
> class Foo {
>   static Resource MY_JS = ...;
> }
>
> class Bar {
>   void g() {
>     Resource r = Foo.MY_JS;
>     ...
>   }
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: resource reference vs resource

Posted by Kent Tong <ke...@cpttm.org.mo>.
Matej Knopp <matej.knopp <at> gmail.com> writes:

> Yeah, ResourceReference is like global resource factory. That is for
> resources that don't belong to any component/page (they can't touch
> any component instance while they are served).

However, I don't understand why we should not just use static class
members like:

class Foo {
  static Resource MY_JS = ...;
}

class Bar {
  void g() {
    Resource r = Foo.MY_JS;
    ...
  }
}



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: resource reference vs resource

Posted by Matej Knopp <ma...@gmail.com>.
Yeah, ResourceReference is like global resource factory. That is for
resources that don't belong to any component/page (they can't touch
any component instance while they are served).

-Matej

On 8/8/07, Kent Tong <ke...@cpttm.org.mo> wrote:
> Matej Knopp <matej.knopp <at> gmail.com> writes:
>
> > basically, there are two kinds of resources in wicket. One is
> > application-scope resources, that don't need the context of a page
> > (javascriptps, css...) and the other is component resources, which
> > kind of belong to a component - so they have access to component,
> > page, etc (chart generation).
>
> Thanks for the informative reply. So Resource Reference is a registration
> and lookup mechanism for global and static resources while Resource is
> a resource for a certain component and could be dynamic.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: resource reference vs resource

Posted by Kent Tong <ke...@cpttm.org.mo>.
Matej Knopp <matej.knopp <at> gmail.com> writes:

> basically, there are two kinds of resources in wicket. One is
> application-scope resources, that don't need the context of a page
> (javascriptps, css...) and the other is component resources, which
> kind of belong to a component - so they have access to component,
> page, etc (chart generation).

Thanks for the informative reply. So Resource Reference is a registration
and lookup mechanism for global and static resources while Resource is 
a resource for a certain component and could be dynamic.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: resource reference vs resource

Posted by Matej Knopp <ma...@gmail.com>.
Hi,

basically, there are two kinds of resources in wicket. One is
application-scope resources, that don't need the context of a page
(javascriptps, css...) and the other is component resources, which
kind of belong to a component - so they have access to component,
page, etc (chart generation).

ResourceReferences are needed for the global kind of resources. They
know how to register with application and how to initially create the
global resources.

We should probably cleanup this a bit in future wicket release (to
late to do that for 1.3), so that it's much more explicit what's the
purpose of resource reference is, also the resources should easily
support the "push" mode (which is kinda tricky right now because the
onresourcerequested method is final, so you have to provide the
IResourceStream, which can be rather cumbersome for some kind of
resources).

-Matej




On 8/5/07, Kent Tong <ke...@cpttm.org.mo> wrote:
> Hi,
>
> I'm having some doubts about why the concept of resource reference is
> needed; it seems resource already suffices. As I understand the purpose
> of resource reference is to reduce the memory used and the need to
> replicate changes in a cluster. However, a resource can also generate
> or load the data on demand. In fact, most important resource classes
> in Wicket are already doing that (PackageResource, DynamicWebResource
> and etc). So a resource typically only takes just as little memory as
> a resource reference.
>
> It's true that a resource has some extra features like
> onResourceRequested() that are not needed by users of resource
> reference. However, I really doubt that this is the real reason for
> creating the concept of resource references.
>
> Thanks for any info!
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org