You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Ernesto Reinaldo Barreiro <re...@isencia.com> on 2007/01/10 15:23:42 UTC
which is the replacement for CompoundResourceStreamLocator (2.0)
Hi,
In an application we were using CompoundResourceStreamLocator but after
syncronyzing with the 2.0 repository I have found this class simply
dissappeared and I cannot find a replacement for it. I noticed
IResourceStreamLocator was replaced with IResourceStreamFactory but I
couldn't find an implementation of a CompoundResourceStreamFactory. A
possible implementation of such a class could be:
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import wicket.util.resource.IResourceStream;
import wicket.util.resource.locator.IResourceStreamFactory;
public class CompoundResourceStreamFactory implements IResourceStreamFactory
{
List<IResourceStreamFactory> resourceStreamFactories = new
ArrayList<IResourceStreamFactory>();
public IResourceStream locate(Class clazz, String path, String style,
Locale locale, String extension) {
for(IResourceStreamFactory factory: resourceStreamFactories) {
if(factory != null) {
IResourceStream stream = factory.locate(clazz, path, style, locale,
extension);
if(stream != null)
return stream;
}
}
return null;
}
public IResourceStream locate(Class clazz, String path) {
for(IResourceStreamFactory factory: resourceStreamFactories) {
if(factory != null) {
IResourceStream stream = factory.locate(clazz, path);
if(stream != null)
return stream;
}
}
return null;
}
public void addResourceStreamFactory(IResourceStreamFactory factory){
resourceStreamFactories.add(factory);
}
public void removeResourceStreamFactory(IResourceStreamFactory factory){
resourceStreamFactories.remove(factory);
}
}
I also notice that IResourceSettings has a method
void setResourceStreamLocator(IResourceStreamFactory resourceStreamFactory);
shouldn't it be named setResourceStreamFactory?
Best regards,
Ernesto
--
View this message in context: http://www.nabble.com/which-is-the-replacement-for-CompoundResourceStreamLocator-%282.0%29-tf2952690.html#a8258305
Sent from the Wicket - Dev mailing list archive at Nabble.com.
Re: which is the replacement for CompoundResourceStreamLocator
(2.0)
Posted by Ernesto Reinaldo Barreiro <re...@isencia.com>.
Dear Juergen,
Thanks for your answer. I'll have taken a look to the class you mention and
I see you are sub-classing ResourceStreamFactory. But what if you need to
add more the one extension and they are "independent"? Then you will have to
sub-class ResourceStreamFactory twice, or make one sub-class the other?
Meanwhile I have created a CompoundFactory which allows to register other
IResourceStreamFactory and that seems to solve my problem.
Thanks again,
Ernesto
Juergen Donnerstag wrote:
>
> Please see CustomResourceStreamFactory in wicket-examples for an
> example on how to use it.
>
> Juergen
>
> On 1/10/07, Juergen Donnerstag <ju...@gmail.com> wrote:
>> Yes, the setter should be renamed as well. Thanks for pointing out.
>>
>> Juergen
>>
>> On 1/10/07, Juergen Donnerstag <ju...@gmail.com> wrote:
>> > Please extend ResourceStreamFactory.locate(...) and register your
>> > factory with the application.
>> >
>> > Juergen
>> >
>> > On 1/10/07, Ernesto Reinaldo Barreiro <re...@isencia.com> wrote:
>> > >
>> > > Hi,
>> > >
>> > > In an application we were using CompoundResourceStreamLocator but
>> after
>> > > syncronyzing with the 2.0 repository I have found this class simply
>> > > dissappeared and I cannot find a replacement for it. I noticed
>> > > IResourceStreamLocator was replaced with IResourceStreamFactory but I
>> > > couldn't find an implementation of a CompoundResourceStreamFactory.
>> A
>> > > possible implementation of such a class could be:
>> > >
>> > > import java.util.ArrayList;
>> > > import java.util.List;
>> > > import java.util.Locale;
>> > >
>> > > import wicket.util.resource.IResourceStream;
>> > > import wicket.util.resource.locator.IResourceStreamFactory;
>> > >
>> > >
>> > > public class CompoundResourceStreamFactory implements
>> IResourceStreamFactory
>> > > {
>> > >
>> > > List<IResourceStreamFactory> resourceStreamFactories = new
>> > > ArrayList<IResourceStreamFactory>();
>> > >
>> > > public IResourceStream locate(Class clazz, String path,
>> String style,
>> > > Locale locale, String extension) {
>> > > for(IResourceStreamFactory factory:
>> resourceStreamFactories) {
>> > > if(factory != null) {
>> > > IResourceStream stream =
>> factory.locate(clazz, path, style, locale,
>> > > extension);
>> > > if(stream != null)
>> > > return stream;
>> > > }
>> > > }
>> > > return null;
>> > > }
>> > >
>> > > public IResourceStream locate(Class clazz, String path) {
>> > > for(IResourceStreamFactory factory:
>> resourceStreamFactories) {
>> > > if(factory != null) {
>> > > IResourceStream stream =
>> factory.locate(clazz, path);
>> > > if(stream != null)
>> > > return stream;
>> > > }
>> > > }
>> > > return null;
>> > > }
>> > >
>> > > public void addResourceStreamFactory(IResourceStreamFactory
>> factory){
>> > > resourceStreamFactories.add(factory);
>> > > }
>> > >
>> > > public void
>> removeResourceStreamFactory(IResourceStreamFactory factory){
>> > > resourceStreamFactories.remove(factory);
>> > > }
>> > > }
>> > >
>> > > I also notice that IResourceSettings has a method
>> > >
>> > > void setResourceStreamLocator(IResourceStreamFactory
>> resourceStreamFactory);
>> > >
>> > > shouldn't it be named setResourceStreamFactory?
>> > >
>> > > Best regards,
>> > >
>> > > Ernesto
>> > >
>> > >
>> > >
>> > > --
>> > > View this message in context:
>> http://www.nabble.com/which-is-the-replacement-for-CompoundResourceStreamLocator-%282.0%29-tf2952690.html#a8258305
>> > > Sent from the Wicket - Dev mailing list archive at Nabble.com.
>> > >
>> > >
>> >
>>
>
>
--
View this message in context: http://www.nabble.com/which-is-the-replacement-for-CompoundResourceStreamLocator-%282.0%29-tf2952690.html#a8273400
Sent from the Wicket - Dev mailing list archive at Nabble.com.
Re: which is the replacement for CompoundResourceStreamLocator (2.0)
Posted by Juergen Donnerstag <ju...@gmail.com>.
Please see CustomResourceStreamFactory in wicket-examples for an
example on how to use it.
Juergen
On 1/10/07, Juergen Donnerstag <ju...@gmail.com> wrote:
> Yes, the setter should be renamed as well. Thanks for pointing out.
>
> Juergen
>
> On 1/10/07, Juergen Donnerstag <ju...@gmail.com> wrote:
> > Please extend ResourceStreamFactory.locate(...) and register your
> > factory with the application.
> >
> > Juergen
> >
> > On 1/10/07, Ernesto Reinaldo Barreiro <re...@isencia.com> wrote:
> > >
> > > Hi,
> > >
> > > In an application we were using CompoundResourceStreamLocator but after
> > > syncronyzing with the 2.0 repository I have found this class simply
> > > dissappeared and I cannot find a replacement for it. I noticed
> > > IResourceStreamLocator was replaced with IResourceStreamFactory but I
> > > couldn't find an implementation of a CompoundResourceStreamFactory. A
> > > possible implementation of such a class could be:
> > >
> > > import java.util.ArrayList;
> > > import java.util.List;
> > > import java.util.Locale;
> > >
> > > import wicket.util.resource.IResourceStream;
> > > import wicket.util.resource.locator.IResourceStreamFactory;
> > >
> > >
> > > public class CompoundResourceStreamFactory implements IResourceStreamFactory
> > > {
> > >
> > > List<IResourceStreamFactory> resourceStreamFactories = new
> > > ArrayList<IResourceStreamFactory>();
> > >
> > > public IResourceStream locate(Class clazz, String path, String style,
> > > Locale locale, String extension) {
> > > for(IResourceStreamFactory factory: resourceStreamFactories) {
> > > if(factory != null) {
> > > IResourceStream stream = factory.locate(clazz, path, style, locale,
> > > extension);
> > > if(stream != null)
> > > return stream;
> > > }
> > > }
> > > return null;
> > > }
> > >
> > > public IResourceStream locate(Class clazz, String path) {
> > > for(IResourceStreamFactory factory: resourceStreamFactories) {
> > > if(factory != null) {
> > > IResourceStream stream = factory.locate(clazz, path);
> > > if(stream != null)
> > > return stream;
> > > }
> > > }
> > > return null;
> > > }
> > >
> > > public void addResourceStreamFactory(IResourceStreamFactory factory){
> > > resourceStreamFactories.add(factory);
> > > }
> > >
> > > public void removeResourceStreamFactory(IResourceStreamFactory factory){
> > > resourceStreamFactories.remove(factory);
> > > }
> > > }
> > >
> > > I also notice that IResourceSettings has a method
> > >
> > > void setResourceStreamLocator(IResourceStreamFactory resourceStreamFactory);
> > >
> > > shouldn't it be named setResourceStreamFactory?
> > >
> > > Best regards,
> > >
> > > Ernesto
> > >
> > >
> > >
> > > --
> > > View this message in context: http://www.nabble.com/which-is-the-replacement-for-CompoundResourceStreamLocator-%282.0%29-tf2952690.html#a8258305
> > > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> > >
> > >
> >
>
Re: which is the replacement for CompoundResourceStreamLocator (2.0)
Posted by Juergen Donnerstag <ju...@gmail.com>.
Yes, the setter should be renamed as well. Thanks for pointing out.
Juergen
On 1/10/07, Juergen Donnerstag <ju...@gmail.com> wrote:
> Please extend ResourceStreamFactory.locate(...) and register your
> factory with the application.
>
> Juergen
>
> On 1/10/07, Ernesto Reinaldo Barreiro <re...@isencia.com> wrote:
> >
> > Hi,
> >
> > In an application we were using CompoundResourceStreamLocator but after
> > syncronyzing with the 2.0 repository I have found this class simply
> > dissappeared and I cannot find a replacement for it. I noticed
> > IResourceStreamLocator was replaced with IResourceStreamFactory but I
> > couldn't find an implementation of a CompoundResourceStreamFactory. A
> > possible implementation of such a class could be:
> >
> > import java.util.ArrayList;
> > import java.util.List;
> > import java.util.Locale;
> >
> > import wicket.util.resource.IResourceStream;
> > import wicket.util.resource.locator.IResourceStreamFactory;
> >
> >
> > public class CompoundResourceStreamFactory implements IResourceStreamFactory
> > {
> >
> > List<IResourceStreamFactory> resourceStreamFactories = new
> > ArrayList<IResourceStreamFactory>();
> >
> > public IResourceStream locate(Class clazz, String path, String style,
> > Locale locale, String extension) {
> > for(IResourceStreamFactory factory: resourceStreamFactories) {
> > if(factory != null) {
> > IResourceStream stream = factory.locate(clazz, path, style, locale,
> > extension);
> > if(stream != null)
> > return stream;
> > }
> > }
> > return null;
> > }
> >
> > public IResourceStream locate(Class clazz, String path) {
> > for(IResourceStreamFactory factory: resourceStreamFactories) {
> > if(factory != null) {
> > IResourceStream stream = factory.locate(clazz, path);
> > if(stream != null)
> > return stream;
> > }
> > }
> > return null;
> > }
> >
> > public void addResourceStreamFactory(IResourceStreamFactory factory){
> > resourceStreamFactories.add(factory);
> > }
> >
> > public void removeResourceStreamFactory(IResourceStreamFactory factory){
> > resourceStreamFactories.remove(factory);
> > }
> > }
> >
> > I also notice that IResourceSettings has a method
> >
> > void setResourceStreamLocator(IResourceStreamFactory resourceStreamFactory);
> >
> > shouldn't it be named setResourceStreamFactory?
> >
> > Best regards,
> >
> > Ernesto
> >
> >
> >
> > --
> > View this message in context: http://www.nabble.com/which-is-the-replacement-for-CompoundResourceStreamLocator-%282.0%29-tf2952690.html#a8258305
> > Sent from the Wicket - Dev mailing list archive at Nabble.com.
> >
> >
>
Re: which is the replacement for CompoundResourceStreamLocator (2.0)
Posted by Juergen Donnerstag <ju...@gmail.com>.
Please extend ResourceStreamFactory.locate(...) and register your
factory with the application.
Juergen
On 1/10/07, Ernesto Reinaldo Barreiro <re...@isencia.com> wrote:
>
> Hi,
>
> In an application we were using CompoundResourceStreamLocator but after
> syncronyzing with the 2.0 repository I have found this class simply
> dissappeared and I cannot find a replacement for it. I noticed
> IResourceStreamLocator was replaced with IResourceStreamFactory but I
> couldn't find an implementation of a CompoundResourceStreamFactory. A
> possible implementation of such a class could be:
>
> import java.util.ArrayList;
> import java.util.List;
> import java.util.Locale;
>
> import wicket.util.resource.IResourceStream;
> import wicket.util.resource.locator.IResourceStreamFactory;
>
>
> public class CompoundResourceStreamFactory implements IResourceStreamFactory
> {
>
> List<IResourceStreamFactory> resourceStreamFactories = new
> ArrayList<IResourceStreamFactory>();
>
> public IResourceStream locate(Class clazz, String path, String style,
> Locale locale, String extension) {
> for(IResourceStreamFactory factory: resourceStreamFactories) {
> if(factory != null) {
> IResourceStream stream = factory.locate(clazz, path, style, locale,
> extension);
> if(stream != null)
> return stream;
> }
> }
> return null;
> }
>
> public IResourceStream locate(Class clazz, String path) {
> for(IResourceStreamFactory factory: resourceStreamFactories) {
> if(factory != null) {
> IResourceStream stream = factory.locate(clazz, path);
> if(stream != null)
> return stream;
> }
> }
> return null;
> }
>
> public void addResourceStreamFactory(IResourceStreamFactory factory){
> resourceStreamFactories.add(factory);
> }
>
> public void removeResourceStreamFactory(IResourceStreamFactory factory){
> resourceStreamFactories.remove(factory);
> }
> }
>
> I also notice that IResourceSettings has a method
>
> void setResourceStreamLocator(IResourceStreamFactory resourceStreamFactory);
>
> shouldn't it be named setResourceStreamFactory?
>
> Best regards,
>
> Ernesto
>
>
>
> --
> View this message in context: http://www.nabble.com/which-is-the-replacement-for-CompoundResourceStreamLocator-%282.0%29-tf2952690.html#a8258305
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>