JXTA

net.jxta.impl.content
Class AbstractPipeContentShare<T extends ContentAdvertisement,U extends AbstractPipeContentShareAdvertisement>

java.lang.Object
  extended by net.jxta.impl.content.AbstractContentShare<T,U>
      extended by net.jxta.impl.content.AbstractPipeContentShare<T,U>
All Implemented Interfaces:
ContentShare
Direct Known Subclasses:
DefaultContentShare, SRDIContentShare

public abstract class AbstractPipeContentShare<T extends ContentAdvertisement,U extends AbstractPipeContentShareAdvertisement>
extends AbstractContentShare<T,U>

Partial implementation of the ContentShare interface for use in provider implementations that use a PipeAdvertisement to contact the server. This class implements the bare minimum requirements for a Content share implementation and will need to be extended by the provider implementation to be useful.


Constructor Summary
AbstractPipeContentShare(ContentProvider origin, Content content)
          Construct a new ContentShare object.
AbstractPipeContentShare(ContentProvider origin, Content content, PipeAdvertisement pAdv)
          Construct a new ContentShare object and immediately associate it with the specified pipe.
 
Method Summary
protected abstract  U createContentShareAdvertisement()
          Called when a new share advertisement object is needed.
 U getContentShareAdvertisement()
          Obtain the ContentShareAdvertisement which can be used to inform remote peers of how to contact the possessor of this Content.
 void setPipeAdvertisement(PipeAdvertisement pAdv)
          Sets the PipeAdvertisement used to contact the server.
 
Methods inherited from class net.jxta.impl.content.AbstractContentShare
addContentShareListener, createContentAdvertisement, getContent, getContentProvider, getContentShareListeners, removeContentShareListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPipeContentShare

public AbstractPipeContentShare(ContentProvider origin,
                                Content content)
Construct a new ContentShare object.

Parameters:
origin - provider which created this share
content - content object to share

AbstractPipeContentShare

public AbstractPipeContentShare(ContentProvider origin,
                                Content content,
                                PipeAdvertisement pAdv)
Construct a new ContentShare object and immediately associate it with the specified pipe.

Parameters:
content - content object to share
pAdv - the pipe advertisement used to contact the server
Method Detail

setPipeAdvertisement

public final void setPipeAdvertisement(PipeAdvertisement pAdv)
Sets the PipeAdvertisement used to contact the server. This must be called prior to the call to getContentAdvertisement().

Parameters:
pAdv - the pipe advertisement used to contact the server

getContentShareAdvertisement

public U getContentShareAdvertisement()
Obtain the ContentShareAdvertisement which can be used to inform remote peers of how to contact the possessor of this Content. Note that this does not necessitate using the discovery mechanism as this info can be embedded in other documents and/or sent out-of-band. This method may return null, signalling the fact that the provider does not provide a mechanism by which remote peers can obtain the Content. This allows for the ability to define stores of Content while not providing methods of transport (other providers may be used for transport in this case). This method calls createContentShareListener() to instantiate it's advertisement. It then sets the ContentID, MetaID, and the MimeType fields. This method extends the functionality provided by the super-class by intercepting the resulting AbstractPipeContentShareAdvertisement and associating the Pipe with it.

Specified by:
getContentShareAdvertisement in interface ContentShare
Overrides:
getContentShareAdvertisement in class AbstractContentShare<T extends ContentAdvertisement,U extends AbstractPipeContentShareAdvertisement>
Returns:
advertisement containing information on how to contact the Content possessor, or null if the provider does not support remote retrieval of the Content. If another peer is made aware of this advertisement it should be able to retrieve the Content it advertises.

createContentShareAdvertisement

protected abstract U createContentShareAdvertisement()
Called when a new share advertisement object is needed. Restricts return type to AbstractPipeContentAdvertisement.

Specified by:
createContentShareAdvertisement in class AbstractContentShare<T extends ContentAdvertisement,U extends AbstractPipeContentShareAdvertisement>
Returns:
created content share advertisement

JXSE