Java Doc for Symlink.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » unix » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.taskdefs.optional.unix 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.tools.ant.dispatch.DispatchTask
   org.apache.tools.ant.taskdefs.optional.unix.Symlink

Symlink
public class Symlink extends DispatchTask (Code)
Creates, Deletes, Records and Restores Symlinks.

This task performs several related operations. In the most trivial and default usage, it creates a link specified in the link attribute to a resource specified in the resource attribute. The second usage of this task is to traverse a directory structure specified by a fileset, and write a properties file in each included directory describing the links found in that directory. The third usage is to traverse a directory structure specified by a fileset, looking for properties files (also specified as included in the fileset) and recreate the links that have been previously recorded for each directory. Finally, it can be used to remove a symlink without deleting the associated resource.

Usage examples:

Make a link named "foo" to a resource named "bar.foo" in subdir:

 <symlink link="${dir.top}/foo" resource="${dir.top}/subdir/bar.foo"/>
 

Record all links in subdir and its descendants in files named "dir.links":

 <symlink action="record" linkfilename="dir.links">
 <fileset dir="${dir.top}" includes="subdir/**" />
 </symlink>
 

Recreate the links recorded in the previous example:

 <symlink action="recreate">
 <fileset dir="${dir.top}" includes="subdir/**/dir.links" />
 </symlink>
 

Delete a link named "foo" to a resource named "bar.foo" in subdir:

 <symlink action="delete" link="${dir.top}/foo"/>
 

LIMITATIONS: Because Java has no direct support for handling symlinks this task divines them by comparing canonical and absolute paths. On non-unix systems this may cause false positives. Furthermore, any operating system on which the command ln -s link resource is not a valid command on the command line will not be able to use action="delete", action="single" or action="recreate", but action="record" should still work. Finally, the lack of support for symlinks in Java means that all links are recorded as links to the canonical resource name. Therefore the link: link --> subdir/dir/../foo.bar will be recorded as link=subdir/foo.bar and restored as link --> subdir/foo.bar.





Method Summary
public  voidaddFileset(FileSet set)
     Add a fileset to this task.
public  voiddelete()
     Delete a symlink.
public static  voiddeleteSymlink(String path)
     Delete a symlink (without deleting the associated resource).
public static  voiddeleteSymlink(File linkfil)
     Delete a symlink (without deleting the associated resource).

This is a utility method that removes a unix symlink without removing the resource that the symlink points to.

public synchronized  voidexecute()
     The standard method for executing any task.
public  voidinit()
     Initialize the task.
public  voidrecord()
     Record symlinks.
public  voidrecreate()
     Restore symlinks.
public  voidsetAction(String action)
     Set the action to be performed.
public  voidsetFailOnError(boolean foe)
     Set failonerror mode.
public  voidsetLink(String lnk)
     Set the name of the link.
public  voidsetLinkfilename(String lf)
     Set the name of the file to which links will be written.
public  voidsetOverwrite(boolean owrite)
     Set overwrite mode.
public  voidsetResource(String src)
     Set the name of the resource to which a link should be created.
public  voidsingle()
     Create a symlink.



Method Detail
addFileset
public void addFileset(FileSet set)(Code)
Add a fileset to this task.
Parameters:
  set - The fileset to add.



delete
public void delete() throws BuildException(Code)
Delete a symlink.
throws:
  BuildException - on error.
since:
   Ant 1.7



deleteSymlink
public static void deleteSymlink(String path) throws IOException, FileNotFoundException(Code)
Delete a symlink (without deleting the associated resource).

This is a convenience method that simply invokes deleteSymlink(java.io.File).
Parameters:
  path - A string containing the path of the symlink to delete.
throws:
  FileNotFoundException - When the path results in aFile that doesn't exist.
throws:
  IOException - If calls to File.renameor File.delete fail.




deleteSymlink
public static void deleteSymlink(File linkfil) throws IOException, FileNotFoundException(Code)
Delete a symlink (without deleting the associated resource).

This is a utility method that removes a unix symlink without removing the resource that the symlink points to. If it is accidentally invoked on a real file, the real file will not be harmed, but an exception will be thrown when the deletion is attempted. This method works by getting the canonical path of the link, using the canonical path to rename the resource (breaking the link) and then deleting the link. The resource is then returned to its original name inside a finally block to ensure that the resource is unharmed even in the event of an exception.
Parameters:
  linkfil - A File object of the symlink to delete.
throws:
  FileNotFoundException - When the path results in aFile that doesn't exist.
throws:
  IOException - If calls to File.rename,File.delete orFile.getCanonicalPathfail.




execute
public synchronized void execute() throws BuildException(Code)
The standard method for executing any task.
throws:
  BuildException - on error.



init
public void init() throws BuildException(Code)
Initialize the task.
throws:
  BuildException - on error.



record
public void record() throws BuildException(Code)
Record symlinks.
throws:
  BuildException - on error.
since:
   Ant 1.7



recreate
public void recreate() throws BuildException(Code)
Restore symlinks.
throws:
  BuildException - on error.
since:
   Ant 1.7



setAction
public void setAction(String action)(Code)
Set the action to be performed. May be "single", "delete", "recreate" or "record".
Parameters:
  action - The action to perform.



setFailOnError
public void setFailOnError(boolean foe)(Code)
Set failonerror mode. If set to true (default) the entire build fails upon error; otherwise the error is logged and the build will continue.
Parameters:
  foe - If true throw BuildException on error, else log it.



setLink
public void setLink(String lnk)(Code)
Set the name of the link. Used when action = "single".
Parameters:
  lnk - The name for the link.



setLinkfilename
public void setLinkfilename(String lf)(Code)
Set the name of the file to which links will be written. Used when action = "record".
Parameters:
  lf - The name of the file to write links to.



setOverwrite
public void setOverwrite(boolean owrite)(Code)
Set overwrite mode. If set to false (default) the task will not overwrite existing links, and may stop the build if a link already exists depending on the setting of failonerror.
Parameters:
  owrite - If true overwrite existing links.



setResource
public void setResource(String src)(Code)
Set the name of the resource to which a link should be created. Used when action = "single".
Parameters:
  src - The resource to be linked.



single
public void single() throws BuildException(Code)
Create a symlink.
throws:
  BuildException - on error.
since:
   Ant 1.7



Methods inherited from org.apache.tools.ant.dispatch.DispatchTask
public String getAction()(Code)(Java Doc)
public String getActionParameterName()(Code)(Java Doc)
public void setAction(String action)(Code)(Java Doc)

w__w_w_.___ja__v___a___2__s__.___c__o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.