You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Stefan Funk <st...@daasi.de> on 2012/04/24 16:11:14 UTC

Re: Caching MTOM attachments and working with cached DataHandler

Hi there,

now I am coming back to this. Caching is now working, but do I get a cached
Stream out of my DataHandler then so that I can reset the stream and process
it again?

I just want to process that stream more then once to write it to several
databases and filesystems, and other processes. I tried working with TEE-
and Copy-Streams, but that is not really working nicely...

Thanks a lot for any input on this.
Stefan.

--
View this message in context: http://cxf.547215.n5.nabble.com/Caching-MTOM-attachments-and-working-with-cached-DataHandler-tp5529487p5662127.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Caching MTOM attachments and working with cached DataHandler

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday, April 25, 2012 04:36:46 AM Stefan Funk wrote:
> Found a bug?
> 
> If I do a realease like this:
> 
> void release(DataSource ds) throws IOException {
>   AttachmentDataSource ads = getAttachmentDataSource(ds);
>   if (ads != null) {
>    // tell attachment to hold the temporary file;
>    ads.release();
>   }
>  }
> 
> and the ads.isCached() is false, I get an exception... would that be to
> catch in the AttachmentDataSource class?

I guess a n NPE guard there would be OK.   Feel free to file a bug.  That 
said, the release() call is really meant to only be paired with a hold() 
call that would make sure the cache is there.   If hold() wasn't called, 
then release doesn't really make sense.

Dan


> Stefan.
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Caching-MTOM-attachments-and-working-with
> -cached-DataHandler-tp5529487p5664591.html Sent from the cxf-user mailing
> list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Caching MTOM attachments and working with cached DataHandler

Posted by Stefan Funk <st...@daasi.de>.
Found a bug?

If I do a realease like this:

void release(DataSource ds) throws IOException {
  AttachmentDataSource ads = getAttachmentDataSource(ds);
  if (ads != null) {
   // tell attachment to hold the temporary file;
   ads.release();
  }
 }

and the ads.isCached() is false, I get an exception... would that be to
catch in the AttachmentDataSource class?
Stefan.

--
View this message in context: http://cxf.547215.n5.nabble.com/Caching-MTOM-attachments-and-working-with-cached-DataHandler-tp5529487p5664591.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Caching MTOM attachments and working with cached DataHandler

Posted by Stefan Funk <st...@daasi.de>.
Hi there.

So I am gladly responsing to myself :-) I found the solution just yesterday
in another blog post:

You just have to hold the DataSource (ds) using ds.hold(), to prevent the
CXF to remove the cached file. So you can use the stream over and over again
(without resetting it), and it is deleted from the cache temp dir only after
you released it via ds.release().

Simple! Here the URL to the post I found:
http://ext2xhb.wordpress.com/2011/06/08/using-cxf-attachment-safely/

Thanks!
Stefan.

--
View this message in context: http://cxf.547215.n5.nabble.com/Caching-MTOM-attachments-and-working-with-cached-DataHandler-tp5529487p5664385.html
Sent from the cxf-user mailing list archive at Nabble.com.