Framework Professional Edition Package


com.prosyst.mbs.framework.storage
Interface Storage


public interface Storage

Storage abstraction. This module is responsible for managing the Framework's and bundles' persistent storage.

Author:
Teodor Todorov, Svetozar Dimov

Field Summary
static int ADMIN_PERMISSIONS
           
static int CONDITIONAL_PERMISSIONS
           
static int FRAMEWORK_STATE
           
static int START_LEVEL
           
 
Method Summary
 short addJar(java.lang.String url, java.io.InputStream is, java.lang.Object rec, boolean keepData, java.lang.String fileName, boolean fromFile, boolean inMainStorage, java.lang.String storageRoot, boolean isSymbolicNameSet)
          Adds a new version of the bundle's jar in the storage.
 java.lang.String[] clearGarbage()
          Clears the garbage files from the underlying file system.
 void clearZombies()
          Removes all bundles' data of bundles that were not installed or uninstalled properly (for example when some crash situation occurred).
 void close()
          Closes the storage.
 short copy(java.lang.Object rec, short oldVer)
          Copy the system files with the old bundle version to the new bundle version
 void delDataFiles(java.lang.Object rec, short ver)
          Deletes all data files of the specified version of the bundle
 void delJars(java.lang.Object rec, short ver, boolean toDelOnlySubJars)
           
 void dirStateChanged(java.lang.String dirName, boolean isPlugged)
          Notify the framework that a flashcard with an installed bundle is unplugged or plugged.
 java.io.File getArchiveFile(java.lang.Object rec)
           
 int getArchiveLength(java.lang.Object rec)
          Returns the length of the specified archive.
 java.lang.String getArchiveName(java.lang.Object rec)
          Returns the absolute pathname of the specified archive.
 void getBundleAllocations(java.lang.String location, java.lang.Object rec, java.util.Vector v1, java.util.Dictionary dic)
           
 java.lang.String getBundleLocation(java.lang.String dataFileName)
          Returns the location of the bundle in which private storage area is the specified data file.
 java.io.File getDataDir()
           
 java.io.File getDataFile(java.lang.String fileName, java.lang.Object rec, short ver, boolean root)
          Returns a File from the bundle's data directory.
 java.lang.String[] getEntries(java.lang.Object subJar, java.lang.Object rec, short ver)
          Parses the archive and returns the bundle entries.
 java.io.InputStream getJarEntry(java.lang.Object subJar, java.lang.String fileName, java.lang.Object rec, short ver)
           
 byte[] getJarEntryBytes(java.lang.Object subJar, java.lang.String fileName, java.lang.Object rec, short ver)
           
 java.net.URLConnection getJarEntryURLConnection(java.lang.Object subJar, java.lang.String fileName, java.lang.Object rec, short ver, java.net.URL url, boolean dirConns)
           
 java.util.Dictionary getJarManifest(java.lang.Object rec)
          Returns an Dictionary containg the manifest headers of the bundle's jar.
 long getLastMountTime(java.lang.String storageRoot)
          This method returns the last time, when that storage was mounted (e.g.
 boolean getNativeFlag()
          Returns true if and only if jdk11 native model is used.
 java.lang.String getNativeLibrary(java.lang.String path, java.lang.Object rec, boolean install)
          Extracts the specified entry from the bundle's main jar into the bundle's native directory, and returns the full canonical path to the resulting File
 XProperties getProperties(int type)
          Returns dictionary containing information about framework's state, bundle permissions or bundle start levels depending on .
 java.lang.Object getRec(Bundle b)
          Creates a new Object, that is unique for the bundle and is used in the other methods of Storage module as an identifier of that bundle.
 int getSize(java.lang.Object entry)
           
 java.io.InputStream getStateFileInputStream(int type, boolean backup)
          Gets the input stream of framework's state, bundle permissions, certificate store or bundle start levels depending on .
 java.io.OutputStream getStateFileOutputStream(int type)
          Gets the output stream of framework's state, bundle permissions, certificate store or bundle start levels depending on .
 java.lang.String[] getStorageRoots()
          Get all registered storage root directories.
 java.lang.Object getSubJar(int subJarIndex, java.lang.String jarName, java.lang.Object rec, short ver)
          The subjar from specify bundle will be return if it exists or null.
 int getTime(java.lang.Object entry)
           
 boolean hasDir(java.lang.Object subJar, java.lang.String dirName, java.lang.Object rec, short ver)
           
 boolean hasJarEntry(java.lang.Object subJar, java.lang.String fileName, java.lang.Object rec, short ver)
           
 boolean isBundleInStorageRoot(java.lang.Object bundleRec, java.lang.String storageRoot)
          This method will check if the bundle, identified by the bundle record is installed in the specified root
 boolean isInTrustedStorage(java.lang.Object rec)
          Checks if the given bundle is in trusted storage
 boolean isUnsigned(java.lang.Object rec)
          Returns whether the bundle jar archive is marked as unsigned in the persistent storage.
 short loadBundle(java.lang.Object brec, java.lang.String url, Key key, byte[] locationb, int verIndex, java.lang.String fileName, boolean fromFile, boolean inMainStorage, java.lang.String storageRoot, boolean isSymbolicNameSet, long checksum)
          Loads the specified bundle from the storage.
 java.io.InputStream openStream(java.lang.Object pzip, java.lang.Object entry, Bundle b)
           
 boolean persistentlyStarted(java.lang.Object rec)
          Indicates whether a bundle is persistently marked as started in storage.
 boolean setPersistentState(java.lang.Object rec, boolean started)
          Marks the bundle as started or stopped in storage, depending on the second parameter.
 boolean setUnresolvableState(java.lang.Object rec, boolean unresolvable)
          Marks the bundle as resolvable or unresolvable in storage, depending on the second parameter.
 void setUnsigned(java.lang.Object rec)
          Marks the bundle archive as unsigned in persistent storage.
 

Field Detail

FRAMEWORK_STATE

static final int FRAMEWORK_STATE
See Also:
Constant Field Values

START_LEVEL

static final int START_LEVEL
See Also:
Constant Field Values

ADMIN_PERMISSIONS

static final int ADMIN_PERMISSIONS
See Also:
Constant Field Values

CONDITIONAL_PERMISSIONS

static final int CONDITIONAL_PERMISSIONS
See Also:
Constant Field Values
Method Detail

getRec

java.lang.Object getRec(Bundle b)
Creates a new Object, that is unique for the bundle and is used in the other methods of Storage module as an identifier of that bundle. This object is stored in the Bundle object and is used by the Storage to store temp objects - like opened zip files.

Parameters:
b - the bundle associated with the new rec
Returns:
the associated BundleRec object

addJar

short addJar(java.lang.String url,
             java.io.InputStream is,
             java.lang.Object rec,
             boolean keepData,
             java.lang.String fileName,
             boolean fromFile,
             boolean inMainStorage,
             java.lang.String storageRoot,
             boolean isSymbolicNameSet)
             throws java.io.IOException
Adds a new version of the bundle's jar in the storage.

Parameters:
url - the url from which the new jar must be downloaded, or null if InputStream is specified
is - InputStream for downloading the jar, or null if url is specified
rec - identifies the Bundle which we add in storage
keepData - indicates if the old data files of the bundle should be kept when a bundle is updated
Returns:
the version assigned to the new jar.
Throws:
java.io.IOException

loadBundle

short loadBundle(java.lang.Object brec,
                 java.lang.String url,
                 Key key,
                 byte[] locationb,
                 int verIndex,
                 java.lang.String fileName,
                 boolean fromFile,
                 boolean inMainStorage,
                 java.lang.String storageRoot,
                 boolean isSymbolicNameSet,
                 long checksum)
                 throws java.io.IOException
Loads the specified bundle from the storage.

Parameters:
brec - identifies the Bundle to load
url - the location of the bundle
key - the key for the bundle in f.st properties file
locationb - the value for the bundle in f.st properties file
verIndex - the index in locationb, at which bundle version is specified
fileName - absolute path to the file, when from file is used
fromFile - indicates whether the bundle is installed from file
inMainStorage - indicates whether the bundle storage data is in the main storage
storageRoot - the storage root if the bundle storage data is not it the main storage
isSymbolicNameSet - if it's true the parameter locationb must not contain the bundle symbolic name
checksum - the checksum of the bundle, that is stored in the f.st. If set to -1 checksum verification will not be performed
Returns:
the version of the bundle record
Throws:
java.io.IOException

delJars

void delJars(java.lang.Object rec,
             short ver,
             boolean toDelOnlySubJars)
             throws java.io.IOException
Parameters:
toDelOnlySubJars - if it's true, this method will delete only subjars
Throws:
java.io.IOException

getJarManifest

java.util.Dictionary getJarManifest(java.lang.Object rec)
                                    throws java.io.IOException
Returns an Dictionary containg the manifest headers of the bundle's jar.

Parameters:
rec - identifies the Bundle which jar manifest is wanted
Returns:
the manifest of the specified bundle
Throws:
java.io.IOException

getJarEntry

java.io.InputStream getJarEntry(java.lang.Object subJar,
                                java.lang.String fileName,
                                java.lang.Object rec,
                                short ver)
                                throws java.io.IOException
Parameters:
subJar - the subJar returned from method getSubJar. If it is null, the main jar will be searched for the entry
Throws:
java.io.IOException

getJarEntryBytes

byte[] getJarEntryBytes(java.lang.Object subJar,
                        java.lang.String fileName,
                        java.lang.Object rec,
                        short ver)
                        throws java.io.IOException
Parameters:
subJar - the subJar returned from method getSubJar. If it is null, the main jar will be searched for the entry
Throws:
java.io.IOException

getJarEntryURLConnection

java.net.URLConnection getJarEntryURLConnection(java.lang.Object subJar,
                                                java.lang.String fileName,
                                                java.lang.Object rec,
                                                short ver,
                                                java.net.URL url,
                                                boolean dirConns)
                                                throws java.io.IOException
Parameters:
subJar - the subJar returned from method getSubJar. If it is null, the main jar will be searched for the entry
Throws:
java.io.IOException

openStream

java.io.InputStream openStream(java.lang.Object pzip,
                               java.lang.Object entry,
                               Bundle b)
                               throws java.io.IOException
Throws:
java.io.IOException

getTime

int getTime(java.lang.Object entry)

getSize

int getSize(java.lang.Object entry)

hasJarEntry

boolean hasJarEntry(java.lang.Object subJar,
                    java.lang.String fileName,
                    java.lang.Object rec,
                    short ver)
                    throws java.io.IOException
Parameters:
subJar - the subJar returned from method getSubJar. If it is null, the main jar will be searched for the entry
Throws:
java.io.IOException

getEntries

java.lang.String[] getEntries(java.lang.Object subJar,
                              java.lang.Object rec,
                              short ver)
                              throws java.io.IOException
Parses the archive and returns the bundle entries.

Parameters:
subJar - the subJar returned from method getSubJar. If it is null, the entries from main jar will returned.
rec - The bundle component, which must be checked for resources.
ver - The version of the bundle's jar.
Returns:
the bundle entries
Throws:
java.io.IOException

hasDir

boolean hasDir(java.lang.Object subJar,
               java.lang.String dirName,
               java.lang.Object rec,
               short ver)
               throws java.io.IOException
Throws:
java.io.IOException

getSubJar

java.lang.Object getSubJar(int subJarIndex,
                           java.lang.String jarName,
                           java.lang.Object rec,
                           short ver)
                           throws java.io.IOException
The subjar from specify bundle will be return if it exists or null.

Parameters:
subJarIndex - the index of the subjar. It must be different from -1
jarName - the full file name of the subjar
rec - The bundle component
ver - The version of the bundle's jar.
Returns:
subjar or null
Throws:
java.io.IOException - if an I/O problem exists

getArchiveName

java.lang.String getArchiveName(java.lang.Object rec)
Returns the absolute pathname of the specified archive.

Parameters:
rec - identifies the Bundle
Returns:
the absolute pathname

getArchiveLength

int getArchiveLength(java.lang.Object rec)
                     throws java.io.IOException
Returns the length of the specified archive.

Parameters:
rec - identifies the Bundle
Returns:
Throws:
java.io.IOException

getArchiveFile

java.io.File getArchiveFile(java.lang.Object rec)
                            throws java.io.IOException
Throws:
java.io.IOException

getDataFile

java.io.File getDataFile(java.lang.String fileName,
                         java.lang.Object rec,
                         short ver,
                         boolean root)
                         throws java.io.IOException
Returns a File from the bundle's data directory.

Parameters:
fileName - the file name
rec - identifies the Bundle
ver - the version of the bundle
root - if the bundle should have access to the root of the storage
Returns:
Throws:
java.io.IOException

getNativeLibrary

java.lang.String getNativeLibrary(java.lang.String path,
                                  java.lang.Object rec,
                                  boolean install)
                                  throws java.io.IOException
Extracts the specified entry from the bundle's main jar into the bundle's native directory, and returns the full canonical path to the resulting File

Parameters:
path - the entry name
rec - identifies the Bundle
install - indicates if it is called when first start of the server or restarting
Returns:
the full canonical path to the native library file
Throws:
java.io.IOException

delDataFiles

void delDataFiles(java.lang.Object rec,
                  short ver)
                  throws java.io.IOException
Deletes all data files of the specified version of the bundle

Parameters:
rec - identifies the Bundle
ver - the bundle version. if it is -1, the data files of all versions will be deleted.
Throws:
java.io.IOException

dirStateChanged

void dirStateChanged(java.lang.String dirName,
                     boolean isPlugged)
Notify the framework that a flashcard with an installed bundle is unplugged or plugged.

Parameters:
dirName - a folder (flash) which is unplugged or plugged.
isPlugged - indicate if the folder is unplugged or plugged

copy

short copy(java.lang.Object rec,
           short oldVer)
           throws java.io.IOException
Copy the system files with the old bundle version to the new bundle version

Parameters:
rec - identifies the bundle
oldVer - the old bundle version.
Returns:
the new bundle version.
Throws:
java.io.IOException

getProperties

XProperties getProperties(int type)
Returns dictionary containing information about framework's state, bundle permissions or bundle start levels depending on . type : 1 - framework state (f.st) 2 - bundle start levels (sl.st) 4 - bundle admin permissions (perms.st) 8 - reserved for bundle conditional permissions (condperms.st) 16 - reserved for certificate key store (certbase.st)

Parameters:
type -
Returns:
the dictionary

getStateFileInputStream

java.io.InputStream getStateFileInputStream(int type,
                                            boolean backup)
                                            throws java.lang.Exception
Gets the input stream of framework's state, bundle permissions, certificate store or bundle start levels depending on .

Parameters:
type - 1 - reserved for framework state (f.st) 2 - reserved for bundle start levels (sl.st) 3 - reserved for bundle admin permissions (perms.st) 8 - bundle conditional permissions (condperms.st)
backup - whether to return primary or backup input stream
Returns:
input stream to the corresponding file
Throws:
java.lang.Exception

getStateFileOutputStream

java.io.OutputStream getStateFileOutputStream(int type)
                                              throws java.lang.Exception
Gets the output stream of framework's state, bundle permissions, certificate store or bundle start levels depending on .

Parameters:
type - 1 - reserved for framework state (f.st) 2 - reserved for bundle start levels (sl.st) 3 - reserved for bundle admin permissions (perms.st) 8 - bundle conditional permissions (condperms.st)
Returns:
output stream to the corresponding file
Throws:
java.lang.Exception

persistentlyStarted

boolean persistentlyStarted(java.lang.Object rec)
Indicates whether a bundle is persistently marked as started in storage.

Parameters:
rec - identifies the Bundle
Returns:
true if the bundle is marked as started

setPersistentState

boolean setPersistentState(java.lang.Object rec,
                           boolean started)
Marks the bundle as started or stopped in storage, depending on the second parameter.

Parameters:
rec - identifies the Bundle
Returns:
true if the pers state has changed

setUnresolvableState

boolean setUnresolvableState(java.lang.Object rec,
                             boolean unresolvable)
Marks the bundle as resolvable or unresolvable in storage, depending on the second parameter.

Parameters:
rec - identifies the bundle
unresolvable - true if the bundle should be marked as unresolvable
Returns:
true if the persistent state is changed

setUnsigned

void setUnsigned(java.lang.Object rec)
Marks the bundle archive as unsigned in persistent storage.

Parameters:
rec - identifies the Bundle

isUnsigned

boolean isUnsigned(java.lang.Object rec)
Returns whether the bundle jar archive is marked as unsigned in the persistent storage.

Parameters:
rec - identifies the Bundle
Returns:

getBundleAllocations

void getBundleAllocations(java.lang.String location,
                          java.lang.Object rec,
                          java.util.Vector v1,
                          java.util.Dictionary dic)
Parameters:
v1 - contains the bundle classpath; used when deflate is supported

getBundleLocation

java.lang.String getBundleLocation(java.lang.String dataFileName)
Returns the location of the bundle in which private storage area is the specified data file. If the specified file is not in the data directory of a bundle null is returned.

Parameters:
dataFileName -
Returns:
the location or null

getNativeFlag

boolean getNativeFlag()
Returns true if and only if jdk11 native model is used.

Returns:
true if jdk11 native model is used; otherwise false

getDataDir

java.io.File getDataDir()

getStorageRoots

java.lang.String[] getStorageRoots()
Get all registered storage root directories. As for date of writing, this is used to create ExclusiveFilePermissions

Returns:
Since:
27.11.2006

isBundleInStorageRoot

boolean isBundleInStorageRoot(java.lang.Object bundleRec,
                              java.lang.String storageRoot)
This method will check if the bundle, identified by the bundle record is installed in the specified root

Parameters:
bundleRec - the bundle record object
storageRoot - the storage root.
Returns:
true if bundle is installed in that root

getLastMountTime

long getLastMountTime(java.lang.String storageRoot)
This method returns the last time, when that storage was mounted (e.g. the card was inserted)

Parameters:
storageRoot - when the card was last inserted
Returns:
the last time the specified storage was mounted
Throws:
java.util.NoSuchElementException - if the storage is unknown.

isInTrustedStorage

boolean isInTrustedStorage(java.lang.Object rec)
Checks if the given bundle is in trusted storage

Parameters:
rec - identifies the Bundle
Returns:
true if it is fals if not

close

void close()
Closes the storage. Called by the framework before exitting, so the storage can do any necesary clean-up.


clearGarbage

java.lang.String[] clearGarbage()
Clears the garbage files from the underlying file system. The result is a list containing the file names of the garbage files that could not be deleted, or null if there are no more garbage files.

Returns:
files or null

clearZombies

void clearZombies()
Removes all bundles' data of bundles that were not installed or uninstalled properly (for example when some crash situation occurred).


Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved