Hm, possibly easiest would be to create the resource when it is requested only.
What component are you using to integrate the resource in your page?

>Is it possible that it's a bug that the stream gets requested multiple times? Or if it is by design, why?

IMHO ResourceStreamResource#internalGetResourceStream() should check for an already created stream and return that one. The way it is implemented now looks like a bug.

Sven


On 08/17/2012 06:19 PM, Michael M wrote:
Is it possible that it's a bug that the stream gets requested multiple
times? Or if it is by design, why? I can't see a reason for it.

I also cannot only return a new IResourceStream when it's not instantiated
yet in my ResourceStreamResource, because the AttachmentInputStream from
Ektorp is not serializable, I get errors if I try that. As far as my
knowledge goes I see myself with no option left..

2012/8/17 Michael M <generi...@gmail.com>

Thanks for the idea, but I can't do that. That would make my resources
static and all attachments would be loaded at page load. I did that at the
beginning, and of course that's a very flawed concept because I would run
into huge performance and memory-problems even with just one user.

So I need the ResourceStreamResource to be dynamic. I don't get why the *
getResourceStream()* is called multiple times.. the javadoc for that
method says

Lazy or dynamic initialization (...)


How can I get proper dynamic resource then?

2012/8/17 Sven Meier <s...@meiers.net>

Beware that ResourceStreamResource#**getResourceStream() is called
multiple times.

Probably easiest is to create the resource stream in
CouchDbAttachmentStreamResourc**e's constructor and pass it to super.

Sven


On 08/17/2012 05:28 PM, Michael M wrote:

Hi,

I wanted to, but I can't because then I don't have the stream to close
it.
If I don't close the stream returned by the Ektorp getAttachment()
method I
will have memory leaks.

2012/8/17 Sven Meier <s...@meiers.net>

  Without looking to deep into this you should create the InputStream in
CouchDbResourceStream#****getInputStream() instead of the constructor.


Sven


On 08/17/2012 04:25 PM, Michael M wrote:

  Hi, short question this time: I have several ResourceLinks to
ResourceStreamResources on a page. When I click on one of those links,
the
resource streams attachments dynamically out of my database.

That's working quite well now, however the stream (and whatever
happens in
the method returning the streams) is called 2-4 times. E.g. opening an
image results in 4 queries to the CouchDB database. I don't really see
that
happening when I'm playing an mp3 file with a flash-player pointing to
the
URL of the resource.

Does anyone have an idea why? I'm only instantiating the resource once,
for
any link I only use that one resource.

Here's my custom ResourceStreamResource: http://pastebin.com/9BB7LEiV

And here my custom IResouceStream: http://pastebin.com/Z7GvzGja

Thanks!


  ------------------------------****----------------------------**
--**---------
To unsubscribe, e-mail: 
users-unsubscribe@wicket.**apa**che.org<http://apache.org>
<users-unsubscribe@**wicket.apache.org<users-unsubscr...@wicket.apache.org>
For additional commands, e-mail: users-h...@wicket.apache.org



------------------------------**------------------------------**---------
To unsubscribe, e-mail: 
users-unsubscribe@wicket.**apache.org<users-unsubscr...@wicket.apache.org>
For additional commands, e-mail: users-h...@wicket.apache.org




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

Reply via email to