Author: ozeigermann Date: Sat Jul 28 10:01:40 2007 New Revision: 560571 URL: http://svn.apache.org/viewvc?view=rev&rev=560571 Log: Cleaned resource interface
Modified: jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/FileResourceManager.java jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/resource/StreamableResource.java Modified: jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/FileResourceManager.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/FileResourceManager.java?view=diff&rev=560571&r1=560570&r2=560571 ============================================================================== --- jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/FileResourceManager.java (original) +++ jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/file/FileResourceManager.java Sat Jul 28 10:01:40 2007 @@ -52,7 +52,7 @@ protected static class FileResource implements StreamableResource { - protected File file; + private File file; public FileResource(String path) { this.file = new File(path); @@ -99,11 +99,11 @@ } public StreamableResource getParent() throws ResourceException { - // FIXME: Is reasonable, but would require refernce to enclosing class + // FIXME: Is reasonable, but would require reference to enclosing + // class /* - if (getPath().equals(getRootPath())) - return null; - */ + * if (getPath().equals(getRootPath())) return null; + */ File parent = file.getParentFile(); return new FileResource(parent); } @@ -124,19 +124,29 @@ return file.isFile(); } - public void move(String destinationpath) throws ResourceException { - File destination = new File(destinationpath); + public void move(StreamableResource destination) throws ResourceException { + if (!(destination instanceof FileResource)) { + throw new ResourceException( + "Destination must be of created by FileResourceManager only!"); + + } + File to = ((FileResource) destination).getFile(); try { - FileHelper.moveUsingNIO(file, destination); + FileHelper.moveUsingNIO(file, to); } catch (IOException e) { throw new ResourceException(e); } } - public void copy(String destinationpath) throws ResourceException { - File destination = new File(destinationpath); + public void copy(StreamableResource destination) throws ResourceException { + if (!(destination instanceof FileResource)) { + throw new ResourceException( + "Destination must be of created by FileResourceManager only!"); + + } + File to = ((FileResource) destination).getFile(); try { - FileHelper.copyUsingNIO(file, destination); + FileHelper.copyUsingNIO(file, to); } catch (IOException e) { throw new ResourceException(e); } @@ -198,6 +208,10 @@ // XXX no op, only way to lock is using FileChannel#lock() and // FileChannel#tryLock() public void writeLock() { + } + + protected File getFile() { + return file; } } Modified: jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/resource/StreamableResource.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/resource/StreamableResource.java?view=diff&rev=560571&r1=560570&r2=560571 ============================================================================== --- jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/resource/StreamableResource.java (original) +++ jakarta/commons/proper/transaction/branches/TRANSACTION_2/src/java/org/apache/commons/transaction/resource/StreamableResource.java Sat Jul 28 10:01:40 2007 @@ -37,9 +37,9 @@ void delete() throws ResourceException; - void move(String destinationpath) throws ResourceException; + void move(StreamableResource destination) throws ResourceException; - void copy(String destinationpath) throws ResourceException; + void copy(StreamableResource destination) throws ResourceException; boolean exists(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]