org.wso2.carbon.server.util
Class Utils

java.lang.Object
  extended by org.wso2.carbon.server.util.Utils

public class Utils
extends Object


Nested Class Summary
static class Utils.JarFileFilter
           
 
Field Summary
static String JAR_TO_BUNDLE_DIR
           
 
Constructor Summary
Utils()
           
 
Method Summary
static void archiveDir(String destArchive, String sourceDir)
          Archive a directory
static void clearPrefixedSystemProperties(String prefix, Map<String,String> targetPropertyMap)
          clearPrefixedSystemProperties clears System Properties by writing null properties in the targetPropertyMap that match a prefix
static void copyFile(File src, File dst)
          Copies src file to dst file.
static void copyFileToDir(File src, File dst)
          Copies src file to dst directory.
static void createBundle(File jarFile, File bundle, Manifest manifest)
          Create an OSGi bundle out of a JAR file
static void createBundle(File jarFile, File targetDir, Manifest mf, String extensionPrefix)
          Create an OSGi bundle out of a JAR file
static boolean deleteDir(File dir)
          Deletes all files and subdirectories under dir.
static void extract(String archive, String extractDir)
           
static void extractFromStream(InputStream inputStream, String extractDir)
           
static String[] getArgs()
           
static File getBundleConfigDirectory()
           
static File getBundleDirectory(String bundleDir)
          Create & return the bundle directory
static File getCarbonComponentRepo()
           
static String getCarbonRepoPath()
           
protected static String getZipEntryPath(File f, String archiveSourceDir)
           
static Properties loadProperties(String filePath)
          loadProperties is a convenience method to load properties from a servlet context resource
static String parseJar(File jarFile)
           
static void printUsages()
           
static String searchFor(String target, String start)
           
protected static void zipDir(File zipDir, ZipOutputStream zos, String archiveSourceDir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAR_TO_BUNDLE_DIR

public static final String JAR_TO_BUNDLE_DIR
Constructor Detail

Utils

public Utils()
Method Detail

getCarbonRepoPath

public static String getCarbonRepoPath()

getCarbonComponentRepo

public static File getCarbonComponentRepo()

printUsages

public static void printUsages()

searchFor

public static String searchFor(String target,
                               String start)

getArgs

public static String[] getArgs()

getBundleDirectory

public static File getBundleDirectory(String bundleDir)
Create & return the bundle directory

Parameters:
bundleDir - The relative path of directory which contains the jars to be made into bundles
Returns:
The bundle directory

createBundle

public static void createBundle(File jarFile,
                                File targetDir,
                                Manifest mf,
                                String extensionPrefix)
                         throws IOException
Create an OSGi bundle out of a JAR file

Parameters:
jarFile - The jarfile to be bundled
targetDir - The directory into which the created OSGi bundle needs to be placed into.
mf - The bundle manifest file
extensionPrefix - Prefix, if any, for the bundle
Throws:
IOException - If an error occurs while reading the jar or creating the bundle

createBundle

public static void createBundle(File jarFile,
                                File bundle,
                                Manifest manifest)
                         throws IOException
Create an OSGi bundle out of a JAR file

Parameters:
jarFile - The jarfile to be bundled
bundle - The bundle to be created
manifest - The manifest file
Throws:
IOException - If an error occurs while reading the jar or creating the bundle

deleteDir

public static boolean deleteDir(File dir)
Deletes all files and subdirectories under dir. Returns true if all deletions were successful. If a deletion fails, the method stops attempting to delete and returns false.


archiveDir

public static void archiveDir(String destArchive,
                              String sourceDir)
                       throws IOException
Archive a directory

Parameters:
destArchive -
sourceDir -
Throws:
IOException

zipDir

protected static void zipDir(File zipDir,
                             ZipOutputStream zos,
                             String archiveSourceDir)
                      throws IOException
Throws:
IOException

getZipEntryPath

protected static String getZipEntryPath(File f,
                                        String archiveSourceDir)

copyFileToDir

public static void copyFileToDir(File src,
                                 File dst)
                          throws IOException
Copies src file to dst directory. If the dst directory does not exist, it is created

Throws:
IOException

copyFile

public static void copyFile(File src,
                            File dst)
                     throws IOException
Copies src file to dst file. If the dst file does not exist, it is created

Throws:
IOException

extract

public static void extract(String archive,
                           String extractDir)
                    throws IOException
Throws:
IOException

extractFromStream

public static void extractFromStream(InputStream inputStream,
                                     String extractDir)
                              throws IOException
Throws:
IOException

parseJar

public static String parseJar(File jarFile)
                       throws IOException
Parameters:
jarFile - jar file location
Returns:
package name list separated by ","
Throws:
IOException - IOException

getBundleConfigDirectory

public static File getBundleConfigDirectory()

clearPrefixedSystemProperties

public static void clearPrefixedSystemProperties(String prefix,
                                                 Map<String,String> targetPropertyMap)
clearPrefixedSystemProperties clears System Properties by writing null properties in the targetPropertyMap that match a prefix

Parameters:
prefix - prefix
targetPropertyMap - targetPropertyMap

loadProperties

public static Properties loadProperties(String filePath)
loadProperties is a convenience method to load properties from a servlet context resource

Parameters:
filePath - - path to load properties from
Returns:
the properties


Copyright © 2014 WSO2 Inc. All rights reserved.