Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
NEXUS-3032: commented the helper methods.
Browse files Browse the repository at this point in the history
git-svn-id: file:///opt/svn/repositories/sonatype.org/nexus/trunk@5609 2aa8b3fc-8ebb-4439-a84f-95066eaea8ab
  • Loading branch information
Tamas Cservenak committed Nov 23, 2009
1 parent 039785b commit f29fc8b
Showing 1 changed file with 49 additions and 0 deletions.
Expand Up @@ -5,16 +5,37 @@

import org.codehaus.plexus.util.FileUtils;

/**
* This is a JSW Wrapper helper class to manipulate wrapper.conf. It has only one "dependency": to have set the
* "basedir" property on System properties with path pointing to the root of the Application bundle. This is the case
* with Nexus bundle.
*
* @author cstamas
*/
public class WrapperHelper
{
/**
* The File pointing to basedir. Lazily inited, see getBasedir() method.
*/
private static File basedir;

/**
* Backups wrapper.conf if not backed up already.
*
* @throws IOException
*/
public static void backupWrapperConf()
throws IOException
{
backupWrapperConf( false );
}

/**
* Backups wrapper.conf. It may be forced to do so, potentionally overwriting the backup file.
*
* @param overwrite true, if you want to overwrite the backup file even if it exists.
* @throws IOException
*/
public static void backupWrapperConf( boolean overwrite )
throws IOException
{
Expand All @@ -26,27 +47,55 @@ public static void backupWrapperConf( boolean overwrite )
}
}

/**
* Replaces the wrapper.conf file with the provided one.
*
* @param file
* @throws IOException
*/
public static void swapInWrapperConf( File file )
throws IOException
{
FileUtils.copyFile( file, getWrapperConfFile() );
}

/**
* Return the File that points to wrapper.conf.
*
* @return
*/
public static File getWrapperConfFile()
{
return getConfFile( "wrapper.conf" );
}

/**
* Returns any configuration file from /conf directory of bundle.
*
* @param name for example "wrapper.conf", but better use getWrapperConfFile() method for that!
* @return
*/
public static File getConfFile( String name )
{
return new File( getConfDir(), name );
}

/**
* Returns the File pointing to /conf directory of the bundle.
*
* @return
*/
public static File getConfDir()
{
return new File( getBasedir(), "conf" );
}

/**
* Returns the File pointing to the basedir. If it is not set in System properties, it will try to "guess" (and
* probably give wrong results, as this method is copied from PlexusTestCase class).
*
* @return
*/
public static File getBasedir()
{
if ( basedir != null )
Expand Down

0 comments on commit f29fc8b

Please sign in to comment.