Package org.wso2.carbon.server.util
Class Utils
- java.lang.Object
-
- org.wso2.carbon.server.util.Utils
-
public class Utils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUtils.JarFileFilter
-
Field Summary
Fields Modifier and Type Field Description static StringJAR_TO_BUNDLE_DIR
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidarchiveDir(String destArchive, String sourceDir)Archive a directorystatic voidclearPrefixedSystemProperties(String prefix, Map<String,String> targetPropertyMap)clearPrefixedSystemProperties clears System Properties by writing null properties in the targetPropertyMap that match a prefixstatic voidcopyFile(File src, File dst)Copies src file to dst file.static voidcopyFileToDir(File src, File dst)Copies src file to dst directory.static voidcreateBundle(File jarFile, File bundle, Manifest manifest)Create an OSGi bundle out of a JAR filestatic voidcreateBundle(File jarFile, File targetDir, Manifest mf, String extensionPrefix)Create an OSGi bundle out of a JAR filestatic booleandeleteDir(File dir)Deletes all files and subdirectories under dir.static voidextract(String archive, String extractDir)static voidextractFromStream(InputStream inputStream, String extractDir)static String[]getArgs()static FilegetBundleConfigDirectory()static FilegetBundleDirectory(String bundleDir)Create & return the bundle directorystatic FilegetCarbonComponentRepo()static StringgetCarbonRepoPath()protected static StringgetZipEntryPath(File f, String archiveSourceDir)static PropertiesloadProperties(String filePath)loadProperties is a convenience method to load properties from a servlet context resourcestatic StringparseJar(File jarFile)static voidprintUsages()static StringsearchFor(String target, String start)protected static voidzipDir(File zipDir, ZipOutputStream zos, String archiveSourceDir)
-
-
-
Field Detail
-
JAR_TO_BUNDLE_DIR
public static final String JAR_TO_BUNDLE_DIR
-
-
Method Detail
-
getCarbonRepoPath
public static String getCarbonRepoPath()
-
getCarbonComponentRepo
public static File getCarbonComponentRepo()
-
printUsages
public static void printUsages()
-
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 bundledtargetDir- The directory into which the created OSGi bundle needs to be placed into.mf- The bundle manifest fileextensionPrefix- 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 bundledbundle- The bundle to be createdmanifest- 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
-
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- prefixtargetPropertyMap- 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
-
-