Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public class AllegatiReader implements ResourceAwareItemReaderItemStream<Allegato> {
  2.  
  3. @PersistenceContext
  4. protected EntityManager em;
  5.  
  6. private Resource resource;
  7.  
  8. @Override
  9. public void close() throws ItemStreamException {
  10.  
  11. }
  12.  
  13. @Override
  14. public void open(ExecutionContext arg0) throws ItemStreamException {
  15.  
  16. }
  17.  
  18. @Override
  19. public void update(ExecutionContext arg0) throws ItemStreamException {
  20.  
  21. }
  22.  
  23. @Override
  24. public Allegato read() throws Exception, UnexpectedInputException,
  25. ParseException, NonTransientResourceException {
  26.  
  27. // DO SOMETHING ...
  28.  
  29. byte[] fileContent = new byte[(int) resource.getFile().length()];
  30.  
  31. resource.getInputStream().read(fileContent);
  32. resource.getInputStream().close();
  33.  
  34. allegato.getFile().setFile(fileContent);
  35.  
  36. return allegato;
  37. }
  38.  
  39. @Override
  40. public void setResource(Resource arg0) {
  41. this.resource = arg0;
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement