JXTA

net.jxta.protocol
Class SrdiMessage

java.lang.Object
  extended by net.jxta.protocol.SrdiMessage

public abstract class SrdiMessage
extends Object

A generic message that can be used by services to push shared resources to other peers on the network.


Nested Class Summary
static class SrdiMessage.Entry
          Entries object, which describes each entry described by this message
 
Field Summary
static int PERSISTONLY
          PERSIST Scope is persist only. i.e.
static int REPLICATE
          REPLICATE Scope is persist and replicate. i.e.
 
Constructor Summary
SrdiMessage()
           
 
Method Summary
 void addEntry(SrdiMessage.Entry entry)
           
 void addEntry(String key, String value, long expiration)
          Adds an index entry
 void decrementTTL()
          Decrements TTL
abstract  Document getDocument(MimeMediaType asMimeType)
          Write advertisement into a document. asMimeType is a mime media-type specification and provides the form of the document which is being requested.
 Collection<SrdiMessage.Entry> getEntries()
          Returns the entries of this SrdiMessage
static String getMessageType()
          All messages have a type (in xml this is !
 PeerID getPeerID()
          returns the source peerid
 String getPrimaryKey()
          get the primary key
 int getScope()
          Returns the current scope of this message.
 int getTTL()
          Deprecated. ttl is a misnomer, it is meant to be defined as scope. use #getScope() instead
 void setEntries(Collection<SrdiMessage.Entry> newEntries)
          Set the Entries for this SrdiMessage.
 void setPeerID(PeerID peerid)
          Set the source peerid
 void setPrimaryKey(String pkey)
          Set the primary key
 void setScope(int scope)
          Sets the current scope of this message.
 void setTTL(int newTTL)
          Deprecated. ttl is a misnomer, it is meant to be defined as scope. use #setScope() instead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERSISTONLY

public static final int PERSISTONLY
PERSIST Scope is persist only. i.e. A node receiving such message is expected to only persist the indexes contained within.

See Also:
Constant Field Values

REPLICATE

public static final int REPLICATE
REPLICATE Scope is persist and replicate. i.e. A node receiving such message is expected to pnly persist the indexes contained within.

See Also:
Constant Field Values
Constructor Detail

SrdiMessage

public SrdiMessage()
Method Detail

getDocument

public abstract Document getDocument(MimeMediaType asMimeType)
Write advertisement into a document. asMimeType is a mime media-type specification and provides the form of the document which is being requested. Two standard document forms are defined. 'text/text' encodes the document in a form nice for printing out and 'text/xml' which provides an XML format.

Parameters:
asMimeType - mime-type requested representation for the returned document
Returns:
Document document representing the advertisement

getPeerID

public PeerID getPeerID()
returns the source peerid

Returns:
PeerID

getPrimaryKey

public String getPrimaryKey()
get the primary key

Returns:
primaryKey

getTTL

@Deprecated
public int getTTL()
Deprecated. ttl is a misnomer, it is meant to be defined as scope. use #getScope() instead

Returns the current TTL value.

Returns:
The current TTL value.

setTTL

@Deprecated
public void setTTL(int newTTL)
Deprecated. ttl is a misnomer, it is meant to be defined as scope. use #setScope() instead

sets the ttl

Parameters:
newTTL - The new TTL value.

getScope

public int getScope()
Returns the current scope of this message.

Scope is either 0 (persist only), or 1 (persist and replicate)

Returns:
The current scope value.

setScope

public void setScope(int scope)
Sets the current scope of this message.

Scope is either 0 (persist only), or 1 (persist and replicate)

Parameters:
scope - The new TTL value.
See Also:
PERSISTONLY, REPLICATE

decrementTTL

public void decrementTTL()
Decrements TTL


getEntries

public Collection<SrdiMessage.Entry> getEntries()
Returns the entries of this SrdiMessage

Returns:
the entries of this SrdiMessage

addEntry

public void addEntry(String key,
                     String value,
                     long expiration)
Adds an index entry

Parameters:
key - key
value - the value
expiration - expiration in millisconds

addEntry

public void addEntry(SrdiMessage.Entry entry)

setEntries

public void setEntries(Collection<SrdiMessage.Entry> newEntries)
Set the Entries for this SrdiMessage.

Parameters:
newEntries - The entries to be included in this message.

setPeerID

public void setPeerID(PeerID peerid)
Set the source peerid

Parameters:
peerid - the source PeerID

setPrimaryKey

public void setPrimaryKey(String pkey)
Set the primary key

Parameters:
pkey - the primary key

getMessageType

public static String getMessageType()
All messages have a type (in xml this is !doctype) which identifies the message, if no expiration is defined Default expiration infinite for entries. This is the amount of time which an entry will live in cache. After this time, the entry is garbage collected, it also worthy to note that it is up to the peer caching these entries to honor the lifetime of the entry, and peer may choose to garbage collect entries based on quotas, relationship with other peers, etc. *

Returns:
String "jxta:GenSRDI"

JXSE