1 23 24 package org.apache.webdav.connector; 25 26 import java.io.IOException ; 27 28 import javax.resource.ResourceException ; 29 import org.apache.webdav.lib.WebdavResource; 30 31 36 public class WebDAVLocalTransaction implements javax.resource.spi.LocalTransaction , javax.resource.cci.LocalTransaction { 37 38 protected WebdavResource webdavResource; 39 protected String owner; 40 protected int timeout; 41 42 public WebDAVLocalTransaction(WebdavResource webdavResource, String owner, int timeout) { 43 this.webdavResource = webdavResource; 44 this.owner = owner; 45 this.timeout = timeout; 46 } 47 48 public void begin() throws ResourceException { 49 try { 50 webdavResource.startTransaction(owner, timeout); 51 } catch (IOException e) { 52 throw new ResourceException ("Could not start transaction", e); 53 } 54 } 55 56 public void commit() throws ResourceException { 57 try { 58 if (!webdavResource.commitTransaction()) { 59 throw new ResourceException ("Could not commit transaction"); 60 } 61 } catch (IOException e) { 62 throw new ResourceException ("Could not commit transaction", e); 63 } 64 } 65 66 public void rollback() throws ResourceException { 67 try { 68 if (!webdavResource.abortTransaction()) { 69 throw new ResourceException ("Could not roll back transaction"); 70 } 71 } catch (IOException e) { 72 throw new ResourceException ("Could not roll back transaction", e); 73 } 74 } 75 76 } 77 | Popular Tags |