org.apache.sling.installer.api
Class InstallableResource

java.lang.Object
  extended by org.apache.sling.installer.api.InstallableResource

public class InstallableResource
extends Object

A piece of data that can be installed by the OsgiInstaller Currently the OSGi installer supports bundles and configurations, but it can be extended by additional task factories supporting other formats. The installable resource contains as much information as the client can provide. An input stream or dictionary is mandatory everything else is optional. All optional values will be tried to be evaluated by the OSGi installer. If such evaluation fails the resource will be ignore during installation. If the client provides a configuration it should use the resource type TYPE_PROPERTIES. Otherwise the resource type TYPE_FILE should be used. These two generic types are transformed by resource transformer services to the appropriate resource type like bundle or configuration etc. This frees the client from having any knowledge about the provided data. However, if the client has the knowledge about the data it can provided a specific resource type.


Field Summary
static String BUNDLE_START_LEVEL
          Optional parameter in the dictionary if a bundle is installed.
static int DEFAULT_PRIORITY
          Default resource priority
static String TYPE_BUNDLE
          The type for a bundle - in this case getInputStream() must return an input stream to the bundle.
static String TYPE_CONFIG
          The type for a configuration - in this case getDictionary() must return a dictionary with the configuration.
static String TYPE_FILE
          The type for all other provided data like a bundle etc.
static String TYPE_PROPERTIES
          The type for properties - in this case getDictionary() should contain a dictionary or the getInputStream() should point to a property or configuration file.
 
Constructor Summary
InstallableResource(String id, InputStream is, Dictionary<String,Object> dict, String digest, String type, Integer priority)
          Create a data object - this is a simple constructor just using the values as they are provided.
 
Method Summary
 Dictionary<String,Object> getDictionary()
          Return this resource's dictionary.
 String getDigest()
          Return this resource's digest.
 String getId()
          Return this data's id.
 InputStream getInputStream()
          Return an input stream with the data of this resource.
 int getPriority()
          Return the priority of this resource.
 String getType()
          Return the type of this resource.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_PROPERTIES

public static final String TYPE_PROPERTIES
The type for properties - in this case getDictionary() should contain a dictionary or the getInputStream() should point to a property or configuration file.

Since:
3.1
See Also:
Constant Field Values

TYPE_FILE

public static final String TYPE_FILE
The type for all other provided data like a bundle etc. In this case getInputStream() must return an input stream to the data. getDictionary() might return additional information.

Since:
3.1
See Also:
Constant Field Values

TYPE_BUNDLE

public static final String TYPE_BUNDLE
The type for a bundle - in this case getInputStream() must return an input stream to the bundle. getDictionary() might return additional information. This type should only be used if the client really knows that the provided data is a bundle.

See Also:
Constant Field Values

TYPE_CONFIG

public static final String TYPE_CONFIG
The type for a configuration - in this case getDictionary() must return a dictionary with the configuration. This type should only be used if the client really knows that the provided data is an OSGi configuration.

See Also:
Constant Field Values

BUNDLE_START_LEVEL

public static final String BUNDLE_START_LEVEL
Optional parameter in the dictionary if a bundle is installed. If this is set with a valid start level, the bundle is installed in that start level.

See Also:
Constant Field Values

DEFAULT_PRIORITY

public static final int DEFAULT_PRIORITY
Default resource priority

See Also:
Constant Field Values
Constructor Detail

InstallableResource

public InstallableResource(String id,
                           InputStream is,
                           Dictionary<String,Object> dict,
                           String digest,
                           String type,
                           Integer priority)
Create a data object - this is a simple constructor just using the values as they are provided.

Parameters:
id - Unique id for the resource, For auto detection of the resource type, the id should contain an extension like .jar, .cfg etc.
is - The input stream to the data or
dict - A dictionary with data
digest - A digest of the data - providers should make sure to set a digest. Calculating a digest by the installer can be very expensive.
type - The resource type if known, otherwise TYPE_PROPERTIES or TYPE_FILE
priority - Optional priority - if not specified DEFAULT_PRIORITY is used
Throws:
IllegalArgumentException - if something is wrong
Method Detail

getId

public String getId()
Return this data's id. It is opaque for the OsgiInstaller but should uniquely identify the resource within the namespace of the used installation mechanism.


getType

public String getType()
Return the type of this resource.

Returns:
The resource type or null if the type is unnown for the client.

getInputStream

public InputStream getInputStream()
Return an input stream with the data of this resource. Null if resource contains a configuration instead. Caller is responsible for closing the stream. If this resource is of type CONFIG it must not return an input stream and if this resource is of type BUNDLE it must return an input stream!

Returns:
The input stream or null.

getDictionary

public Dictionary<String,Object> getDictionary()
Return this resource's dictionary. Null if resource contains an InputStream instead. If this resource is of type CONFIG it must return a dictionary and if this resource is of type BUNDLE it might return a dictionary!

Returns:
The resource's dictionary or null.

getDigest

public String getDigest()
Return this resource's digest. Not necessarily an actual md5 or other digest of the data, can be any string that changes if the data changes.

Returns:
The digest or null

getPriority

public int getPriority()
Return the priority of this resource. Priorities are used to decide which resource to install when several are registered for the same OSGi entity (bundle, config, etc.)


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.