Package org.onosproject.common.app
Class ApplicationArchive
- java.lang.Object
-
- org.onosproject.store.AbstractStore<ApplicationEvent,ApplicationStoreDelegate>
-
- org.onosproject.common.app.ApplicationArchive
-
- All Implemented Interfaces:
Store<ApplicationEvent,ApplicationStoreDelegate>
- Direct Known Subclasses:
DistributedApplicationStore
public class ApplicationArchive extends AbstractStore<ApplicationEvent,ApplicationStoreDelegate>
Facility for reading application archive stream and managing application directory structure.
-
-
Field Summary
-
Fields inherited from class org.onosproject.store.AbstractStore
delegate
-
-
Constructor Summary
Constructors Constructor Description ApplicationArchive()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
clearActive(java.lang.String appName)
Clears the app as active by deleting token file in the app directory.ApplicationDescription
getApplicationDescription(java.lang.String appName)
Loads the application descriptor from the specified application archive stream and saves the stream in the appropriate application archive directory.java.io.InputStream
getApplicationInputStream(java.lang.String appName)
Returns application archive stream for the specified application.java.util.Set<java.lang.String>
getApplicationNames()
Returns the set of installed application names.ApplicationRole
getRole(java.lang.String value)
java.lang.String
getRootPath()
Returns the root directory where apps directory is contained.long
getUpdateTime(java.lang.String appName)
Returns the timestamp in millis since start of epoch, of when the specified application was last modified or changed state.protected boolean
isActive(java.lang.String appName)
Indicates whether the app was marked as active by checking for token file.void
purgeApplication(java.lang.String appName)
Purges the application archive directory.ApplicationDescription
saveApplication(java.io.InputStream stream)
Loads the application descriptor from the specified application archive stream and saves the stream in the appropriate application archive directory.protected boolean
setActive(java.lang.String appName)
Marks the app as active by creating token file in the app directory.protected void
setRootPath(java.lang.String root)
Sets the root directory where apps directory is contained.protected boolean
updateTime(java.lang.String appName)
Updates the time-stamp of the app descriptor file.-
Methods inherited from class org.onosproject.store.AbstractStore
hasDelegate, notifyDelegate, notifyDelegate, setDelegate, unsetDelegate
-
-
-
-
Method Detail
-
setRootPath
protected void setRootPath(java.lang.String root)
Sets the root directory where apps directory is contained.- Parameters:
root
- top-level directory path
-
getRootPath
public java.lang.String getRootPath()
Returns the root directory where apps directory is contained.- Returns:
- top-level directory path
-
getApplicationNames
public java.util.Set<java.lang.String> getApplicationNames()
Returns the set of installed application names.- Returns:
- installed application names
-
getUpdateTime
public long getUpdateTime(java.lang.String appName)
Returns the timestamp in millis since start of epoch, of when the specified application was last modified or changed state.- Parameters:
appName
- application name- Returns:
- number of millis since start of epoch
-
getApplicationDescription
public ApplicationDescription getApplicationDescription(java.lang.String appName)
Loads the application descriptor from the specified application archive stream and saves the stream in the appropriate application archive directory.- Parameters:
appName
- application name- Returns:
- application descriptor
- Throws:
ApplicationException
- if unable to read application description
-
saveApplication
public ApplicationDescription saveApplication(java.io.InputStream stream)
Loads the application descriptor from the specified application archive stream and saves the stream in the appropriate application archive directory.- Parameters:
stream
- application archive stream- Returns:
- application descriptor
- Throws:
ApplicationException
- if unable to read the archive stream or store the application archive
-
purgeApplication
public void purgeApplication(java.lang.String appName)
Purges the application archive directory.- Parameters:
appName
- application name
-
getApplicationInputStream
public java.io.InputStream getApplicationInputStream(java.lang.String appName)
Returns application archive stream for the specified application. This will be either the application OAR file, JAR file or the plain XML file.- Parameters:
appName
- application name- Returns:
- application archive stream
-
setActive
protected boolean setActive(java.lang.String appName)
Marks the app as active by creating token file in the app directory.- Parameters:
appName
- application name- Returns:
- true if file was created
-
clearActive
protected boolean clearActive(java.lang.String appName)
Clears the app as active by deleting token file in the app directory.- Parameters:
appName
- application name- Returns:
- true if file was deleted
-
updateTime
protected boolean updateTime(java.lang.String appName)
Updates the time-stamp of the app descriptor file.- Parameters:
appName
- application name- Returns:
- true if the app descriptor was updated
-
isActive
protected boolean isActive(java.lang.String appName)
Indicates whether the app was marked as active by checking for token file.- Parameters:
appName
- application name- Returns:
- true if the app is marked as active
-
getRole
public ApplicationRole getRole(java.lang.String value)
-
-