DeploymentSession
Date: 2016-06-25

org.osgi.service.deploymentadmin.spi

## Interface DeploymentSession

-     public interface DeploymentSession

  The session interface represents a currently running deployment session (install/update/uninstall).

  When a deployment package is installed the target package, when uninstalled the source package is an empty deployment package. The empty deployment package is a virtual entity it doesn't appear for the outside world. It is only visible on the DeploymentSession interface used by Resource Processors. Although the empty package is only visible for Resource Processors it has the following characteristics:

  - has version 0.0.0
  - its name is an empty string
  - it is stale
  - it has no bundles (see `DeploymentPackage.getBundle(String)`)
  - it has no resources (see `DeploymentPackage.getResources()`)
  - it has no headers except
    - `DeploymentPackage-SymbolicName` and
    - `DeploymentPackage-Version`
    (see `DeploymentPackage.getHeader(String)`)
  - it has no resource headers (see `DeploymentPackage.getResourceHeader(String, String)`)
  - `DeploymentPackage.uninstall()` throws `IllegalStateException`
  - `DeploymentPackage.uninstallForced()` throws `IllegalStateException`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.io.File` | `getDataFile(org.osgi.framework.Bundle bundle)` Returns the private data area of the specified bundle.
    `DeploymentPackage` | `getSourceDeploymentPackage()` If the deployment action is an install or an update, this call returns the `DeploymentPackage` instance that corresponds to the deployment package being streamed in for this session.
    `DeploymentPackage` | `getTargetDeploymentPackage()` If the deployment action is an update or an uninstall, this call returns the `DeploymentPackage` instance for the installed deployment package.

- - ### Method Detail

    - #### getTargetDeploymentPackage

          DeploymentPackage getTargetDeploymentPackage()

      If the deployment action is an update or an uninstall, this call returns the `DeploymentPackage` instance for the installed deployment package. If the deployment action is an install, this call returns the empty deployment package (see `DeploymentPackage`).
      Returns:
        the target deployment package
      See Also:
        `DeploymentPackage`

    - #### getSourceDeploymentPackage

          DeploymentPackage getSourceDeploymentPackage()

      If the deployment action is an install or an update, this call returns the `DeploymentPackage` instance that corresponds to the deployment package being streamed in for this session. If the deployment action is an uninstall, this call returns the empty deployment package (see `DeploymentPackage`).
      Returns:
        the source deployment package
      See Also:
        `DeploymentPackage`

    - #### getDataFile

          java.io.File getDataFile(org.osgi.framework.Bundle bundle)

      Returns the private data area of the specified bundle. The bundle must be part of either the source or the target deployment packages. The permission set the caller resource processor needs to manipulate the private area of the bundle is set by the Deployment Admin on the fly when this method is called. The permissions remain available during the deployment action only.

      The bundle and the caller Resource Processor have to be in the same Deployment Package.

      Parameters:
        `bundle` - the bundle the private area belongs to
      Returns:
        file representing the private area of the bundle. It cannot be null.
      Throws:
        `java.lang.SecurityException` - if the caller doesn't have the appropriate `DeploymentCustomizerPermission`("<filter>", "privatearea") permission.
      See Also:
        `DeploymentPackage`, `DeploymentCustomizerPermission`