Rio Project 4.2 API Documentation



org.rioproject.exec
Class Util

java.lang.Object
  extended by org.rioproject.exec.Util

public class Util
extends Object

Helpful utilities

Author:
Dennis Reedy

Field Summary
static String COMPONENT
           
static String RESOURCE_ROOT
           
 
Constructor Summary
Util()
           
 
Method Summary
static void chmod(File file, String perms)
          Run chmod
static void chmodX(File file)
          Apply execute permissions for a file
static void close(Closeable c)
           
static ExecDescriptor extendCommandLine(String root, ExecDescriptor exec)
          Extend command line, inserting the root directory in front of the command line of the extension
static URL getResource(String resource)
          Get a resource using the current context classloader
static String replace(String str, String pattern, String replace)
          Search and Replace
static int runShellScript(File shellScript)
          Run (exec) a shell script
static int runShellScript(File shellScript, boolean sync)
          Run (exec) a shell script
static void writeFile(String contents, File file)
          Write contents to a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT

public static final String COMPONENT

RESOURCE_ROOT

public static final String RESOURCE_ROOT
Constructor Detail

Util

public Util()
Method Detail

getResource

public static URL getResource(String resource)
                       throws IOException
Get a resource using the current context classloader

Parameters:
resource - The resource name
Returns:
The URL of the loaded resource
Throws:
IOException - If the resource cannot be loaded

chmod

public static void chmod(File file,
                         String perms)
                  throws IOException
Run chmod

Parameters:
file - The file to chmod
perms - The permissions to chmod
Throws:
IOException - If the command does not execute

chmodX

public static void chmodX(File file)
                   throws IOException
Apply execute permissions for a file

Parameters:
file - The file to apply execute permissions on
Throws:
IOException - If the command does not execute

close

public static void close(Closeable c)

writeFile

public static void writeFile(String contents,
                             File file)
                      throws IOException
Write contents to a file

Parameters:
contents - The contents to write
file - The file to write to
Throws:
IOException - If the file cannot be wrriten to

runShellScript

public static int runShellScript(File shellScript)
                          throws IOException
Run (exec) a shell script

Parameters:
shellScript - The shell script file to exec
Returns:
The exit value of the exec'ed process
Throws:
IOException - If the process cannot be created

runShellScript

public static int runShellScript(File shellScript,
                                 boolean sync)
                          throws IOException
Run (exec) a shell script

Parameters:
shellScript - The shell script file to exec
sync - If true wait for the process to complete
Returns:
The exit value of the exec'ed process
Throws:
IOException - If the process cannot be created

extendCommandLine

public static ExecDescriptor extendCommandLine(String root,
                                               ExecDescriptor exec)
Extend command line, inserting the root directory in front of the command line of the extension

Parameters:
root - The root directory name
exec - The ExecDescriptor
Returns:
A modified ExecDescriptor

replace

public static String replace(String str,
                             String pattern,
                             String replace)
Search and Replace

Parameters:
str - The string to replace tokens for
pattern - The pattern to look for
replace - The replacement for the pattern
Returns:
A string with tokens replaced

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.