|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jxtaimpl.storage.CmsStorage
This class is in charge of managing the resources to be shared within the Anthill network.
Field Summary |
Fields inherited from interface anthill.storage.Storage |
DOC_STORAGE, PHR_STORAGE, URL_STORAGE |
Constructor Summary | |
CmsStorage(String species,
long size,
String confDir,
URL pipeId,
String pipeName,
String pipeType)
This is the constructor. |
Method Summary | |
void |
addResource(Object key,
Resource resource)
Deprecated. The public void addResource(Object key, Resource resource, byte[] buffer)
method should be used in place of this one |
void |
addResource(Object key,
Resource resource,
byte[] buffer)
Adds the resource described by Resource resource and contained in
byte[] buffer . |
void |
clear()
This method does nothing, it has no sense in the jxtaimpl
implementation. |
boolean |
containsResource(Object key)
Returns true if one resource satisfing the query key ,
(please see Query javadocs) is contained in
the storage, false otherwise. |
Resource[] |
getAllResources()
This method will return the complete set of resources stored in the local nest if the storage is not empty, else it returns null . |
long |
getCapacity()
Returns the initial capacity of this generic storage. |
InputStream |
getInputStreamForContent(byte[] contentId)
Gets the InputStream for reading in the resource identified by the
the given contentId. |
long |
getRemainingCapacity()
Returns the remaining capacity of this generic storage. |
Resource |
getResource(Object key)
Returns the first resource which satisfies the query (key). |
Resource[] |
getResources(Object key)
Returns the resources associated with the specified key. |
Iterator |
iterator()
Returns the complete set of resources stored in this storage object using an iterator. |
void |
removeResource(Object query)
This method removes the first resource which satisfies the given query. |
void |
share(byte[] content,
String name,
String type,
String description)
This method is used by the Nest instance in order to share new resources not found by ants, but passed by the application level. |
void |
share(File file,
String name,
String type,
String description)
This method is used by the Nest instance in order to share new resources not found by ants, but passed by the application level. |
void |
unShare(AnthillResource resource)
This method removes the specified resouce from the local storage. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CmsStorage(String species, long size, String confDir, URL pipeId, String pipeName, String pipeType)
species
- The ant species this storage is associated tosize
- The desired storage's size expressed in bytespipeId
- This is the JXTA pipeID of the local jxtaimpl.DownloadService
input-pipe waiting for download requests to comepipeName
- The pipe's logical namepipeType
- The pipe's type (point-to-point, propagate, secure)Method Detail |
public void clear()
jxtaimpl
implementation.
clear
in interface Clearable
public Resource getResource(Object key)
jxtaimpl
implementation of Anthill, the key object has
to be an instance of the the class Query belonging to this same package.
getResource
in interface GenericStorage
key
- whose associated resource to retreive.
public Resource[] getResources(Object key)
jxtaimpl
implementation of Anthill, the key object has
to be an instance of the the class Query belonging to this same package.
getResources
in interface QueryStorage
key
- whose associated resource to retreive.
public Resource[] getAllResources()
null
.
public boolean containsResource(Object key)
key
,
(please see Query
javadocs) is contained in
the storage, false otherwise. The key
is meant to be a couple
like this: (elementName, values)
. Both of them are meant to be
String
. All the interesting values contained in values
must be separated by a blank space. It doesn't matter whether they are upper-case
or not.
containsResource
in interface GenericStorage
key
- the key to be searched
key
is contained in
the storagepublic void addResource(Object key, Resource resource) throws CapacityException
public void addResource(Object key, Resource resource, byte[] buffer)
method should be used in place of this one
CapacityException
is thrown
containing information about the remaining capacity. Method
getContentLength()
may be invoked on the resource
to determine the amount of space required by the resource.
In order to be stored on persistent storage, resource must
implement the Serializable
interface.
addResource
in interface GenericStorage
key
- the key identifying the resourceresource
- the resource to be added
CapacityException
- raised if the given resource object
exceeds the total available capacity for this storage.public void addResource(Object key, Resource resource, byte[] buffer) throws CapacityException
Resource resource
and contained in
byte[] buffer
. This method should be invoked in place of the
addResource(Object key, Resource resource)
method for locally adding
a new resource.
key
- The key identifieing the resource. This might be null
since
in this method's signature there is a resource descriptor as wellresource
- This is the resource descriptor which has to be an AnthillResource
instancebuffer
- This is the content which has to be locally stored
CapacityException
public void removeResource(Object query)
removeResource
in interface GenericStorage
query
- This object must be a jxtaimpl.storage.Query
instance or
has to extend it for this method to work. It contains the couple
(ElementName, Value)
identifieing the resource we want to removepublic void share(File file, String name, String type, String description) throws ResourceAlreadyStoredException, CapacityException
file
- The file representing the resource we want to sharename
- The logical name for the resourcetype
- The resource's typedescription
- A logical description of the resource
ResourceAlreadyStoredException
CapacityException
public void share(byte[] content, String name, String type, String description) throws ResourceAlreadyStoredException, CapacityException
name
- The logical name for the resourcetype
- The resource's typedescription
- A logical description of the resource
ResourceAlreadyStoredException
CapacityException
public void unShare(AnthillResource resource)
public Iterator iterator()
iterator
in interface GenericStorage
public long getCapacity()
getCapacity
in interface GenericStorage
public long getRemainingCapacity()
getRemainingCapacity
in interface GenericStorage
public InputStream getInputStreamForContent(byte[] contentId)
InputStream
for reading in the resource identified by the
the given contentId. The byte
array is actually the String
rapresentation of the ContentIdImpl
instance.
This method should only be used by the Nest
instance in order to
upload the resource identified by the given contentID.
contentId
- The byte array representing the String
from which
the ContentIdImpl
identifieing the resource
we are interested in should be generated
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |