org.apache.sling.installer.core.impl
Class RegisteredResourceImpl

java.lang.Object
  extended by org.apache.sling.installer.core.impl.RegisteredResourceImpl
All Implemented Interfaces:
Serializable, Comparable<RegisteredResourceImpl>, RegisteredResource, TaskResource

public class RegisteredResourceImpl
extends Object
implements TaskResource, Serializable, Comparable<RegisteredResourceImpl>

Implementation of the registered resource

See Also:
Serialized Form

Method Summary
 void cleanup()
          Clean up used data files.
 TaskResource clone(TransformationResult transformationResult)
          Create a new resource with updated information
static int compare(TaskResource a, TaskResource b)
          Compare resources.
 int compareTo(RegisteredResourceImpl b)
           
static RegisteredResourceImpl create(InternalResource input)
          Try to create a registered resource.
 boolean equals(Object obj)
           
 Object getAttribute(String key)
          Get the value of an attribute.
 Dictionary<String,Object> getDictionary()
          Return this resource's dictionary.
 String getDigest()
          Return this resource's digest.
 String getEntityId()
          Return the identifier of the OSGi "entity" that this resource represents, for example "bundle:SID" where SID is the bundle's symbolic ID, or "config:PID" where PID is config's PID.
 InputStream getInputStream()
          Return an input stream with the data of this resource.
 long getLastChange()
          When did the last change happen?
 int getPriority()
          Return the priority of this resource.
 String getScheme()
          Return the scheme from where the artifact is orginated.
 ResourceState getState()
          Get the current state of the resource.
 Object getTemporaryAttribute(String key)
          Get the value of a temporary attribute.
 String getType()
          Return the type of this resource.
 String getURL()
          Return this data's url.
 int hashCode()
           
 void setAttribute(String key, Object value)
          Set the value of an attribute.
 void setState(ResourceState s)
          Set the state for the resource.
 void setTemporaryAttribute(String key, Object value)
          Set the value of a temporary attribute.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static RegisteredResourceImpl create(InternalResource input)
                                     throws IOException
Try to create a registered resource.

Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

cleanup

public void cleanup()
Clean up used data files.


getURL

public String getURL()
Description copied from interface: RegisteredResource
Return this data's url. The url is the RegisteredResource.getScheme() followed by a colon, followed by a unique identifier of the resource within the providers space..

Specified by:
getURL in interface RegisteredResource
See Also:
RegisteredResource.getURL()

getInputStream

public InputStream getInputStream()
                           throws IOException
Description copied from interface: RegisteredResource
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 PROPERTIES it must not return an input stream and if this resource is of type FILE it must return an input stream!

Specified by:
getInputStream in interface RegisteredResource
Returns:
The input stream or null.
Throws:
IOException
See Also:
RegisteredResource.getInputStream()

getDictionary

public Dictionary<String,Object> getDictionary()
Description copied from interface: RegisteredResource
Return this resource's dictionary. Null if resource contains an InputStream instead. If this resource is of type PROPERTIES it must return a dictionary and if this resource is of type FILE it might return a dictionary!

Specified by:
getDictionary in interface RegisteredResource
Returns:
The resource's dictionary or null.
See Also:
RegisteredResource.getDictionary()

getDigest

public String getDigest()
Description copied from interface: RegisteredResource
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.

Specified by:
getDigest in interface RegisteredResource
See Also:
RegisteredResource.getDigest()

getType

public String getType()
Description copied from interface: RegisteredResource
Return the type of this resource.

Specified by:
getType in interface RegisteredResource
Returns:
The resource type.
See Also:
RegisteredResource.getType()

getEntityId

public String getEntityId()
Description copied from interface: RegisteredResource
Return the identifier of the OSGi "entity" that this resource represents, for example "bundle:SID" where SID is the bundle's symbolic ID, or "config:PID" where PID is config's PID.

Specified by:
getEntityId in interface RegisteredResource
See Also:
RegisteredResource.getEntityId()

getAttribute

public Object getAttribute(String key)
Description copied from interface: TaskResource
Get the value of an attribute. Attributes include the bundle symbolic name, bundle version, etc.

Specified by:
getAttribute in interface TaskResource
Parameters:
key - The name of the attribute
Returns:
The value of the attribute or null
See Also:
TaskResource.getAttribute(java.lang.String)

setAttribute

public void setAttribute(String key,
                         Object value)
Description copied from interface: TaskResource
Set the value of an attribute.

Specified by:
setAttribute in interface TaskResource
Parameters:
key - The name of the attribute
value - The attribute value or null to remove it.
See Also:
TaskResource.setAttribute(java.lang.String, java.lang.Object)

getScheme

public String getScheme()
Description copied from interface: RegisteredResource
Return the scheme from where the artifact is orginated.

Specified by:
getScheme in interface RegisteredResource
See Also:
RegisteredResource.getScheme()

getPriority

public int getPriority()
Description copied from interface: RegisteredResource
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.)

Specified by:
getPriority in interface RegisteredResource
See Also:
RegisteredResource.getPriority()

getState

public ResourceState getState()
Description copied from interface: TaskResource
Get the current state of the resource.

Specified by:
getState in interface TaskResource
See Also:
TaskResource.getState()

setState

public void setState(ResourceState s)
Set the state for the resource.


getLastChange

public long getLastChange()
When did the last change happen?

Returns:
-1 if no change , 0 if unknown, > 0 otherwise

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

compareTo

public int compareTo(RegisteredResourceImpl b)
Specified by:
compareTo in interface Comparable<RegisteredResourceImpl>
See Also:
Comparable.compareTo(java.lang.Object)

compare

public static int compare(TaskResource a,
                          TaskResource b)
Compare resources. First we compare the entity id - the entity id contains the resource type together with an entity identifier for the to be installed resource like the symbolic name of a bundle, the pid for a configuration etc.


getTemporaryAttribute

public Object getTemporaryAttribute(String key)
Description copied from interface: TaskResource
Get the value of a temporary attribute.

Specified by:
getTemporaryAttribute in interface TaskResource
Parameters:
key - The name of the attribute
Returns:
The value of the attribute or null
See Also:
TaskResource.getTemporaryAttribute(java.lang.String)

setTemporaryAttribute

public void setTemporaryAttribute(String key,
                                  Object value)
Description copied from interface: TaskResource
Set the value of a temporary attribute.

Specified by:
setTemporaryAttribute in interface TaskResource
Parameters:
key - The name of the attribute
value - The attribute value or null to remove it.
See Also:
TaskResource.setTemporaryAttribute(java.lang.String, java.lang.Object)

clone

public TaskResource clone(TransformationResult transformationResult)
                   throws IOException
Create a new resource with updated information

Throws:
IOException


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