org.alfresco.repo.content
Class AbstractContentAccessor

java.lang.Object
  extended by org.alfresco.repo.content.AbstractContentAccessor
All Implemented Interfaces:
ContentAccessor
Direct Known Subclasses:
AbstractContentReader, AbstractContentWriter

public abstract class AbstractContentAccessor
extends java.lang.Object
implements ContentAccessor

Provides basic support for content accessors.


Nested Class Summary
protected  class AbstractContentAccessor.CallbackFileChannel
          Wraps a FileChannel to provide callbacks to listeners when the channel is closed.
protected  class AbstractContentAccessor.ChannelCloseCallbackAdvise
          Advise that listens for the completion of specific methods on the ByteChannel interface.
 
Constructor Summary
protected AbstractContentAccessor(java.lang.String contentUrl)
           
 
Method Summary
protected  void channelOpened()
          Derived classes can call this method to ensure that necessary trace logging is performed when the IO Channel is opened.
protected  void finalize()
           
protected  java.nio.channels.FileChannel getCallbackFileChannel(java.nio.channels.FileChannel directChannel, java.util.List listeners)
          Generate a callback instance of the FileChannel.
 ContentData getContentData()
          Get the data representation of the content being accessed.
 java.lang.String getContentUrl()
          Retrieve the URL that this accessor references
 java.lang.String getEncoding()
          Get the encoding of the content being accessed
 java.util.Locale getLocale()
          Get the locale of the content being accessed
 java.lang.String getMimetype()
          Get the content mimetype
protected  void setContentUrl(java.lang.String contentUrl)
          Allow derived implementations to set the Content URL.
 void setEncoding(java.lang.String encoding)
          Set the String encoding for this accessor
 void setLocale(java.util.Locale locale)
          Set the Locale for this accessor
 void setMimetype(java.lang.String mimetype)
          Set the mimetype that must be used for accessing the content
 void setRetryingTransactionHelper(RetryingTransactionHelper helper)
          Set the transaction helper for callbacks.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.alfresco.service.cmr.repository.ContentAccessor
addListener, getSize, isChannelOpen
 

Constructor Detail

AbstractContentAccessor

protected AbstractContentAccessor(java.lang.String contentUrl)
Parameters:
contentUrl - the content URL
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getContentData

public ContentData getContentData()
Description copied from interface: ContentAccessor
Get the data representation of the content being accessed.

The content mimetype must be set before this method is called as the content data requires a mimetype whenever the content URL is specified.

Specified by:
getContentData in interface ContentAccessor
Returns:
Returns the content data
See Also:
ContentData.ContentData(String, String, long, String)

setRetryingTransactionHelper

public void setRetryingTransactionHelper(RetryingTransactionHelper helper)
Description copied from interface: ContentAccessor
Set the transaction helper for callbacks.

Specified by:
setRetryingTransactionHelper in interface ContentAccessor

channelOpened

protected final void channelOpened()
Derived classes can call this method to ensure that necessary trace logging is performed when the IO Channel is opened.


getContentUrl

public java.lang.String getContentUrl()
Description copied from interface: ContentAccessor
Retrieve the URL that this accessor references

Specified by:
getContentUrl in interface ContentAccessor
Returns:
the content URL

setContentUrl

protected void setContentUrl(java.lang.String contentUrl)
Allow derived implementations to set the Content URL. This allows for implementations where the URL is not known when the accessor is first constructed.

Parameters:
contentUrl - the new content URL

getMimetype

public java.lang.String getMimetype()
Description copied from interface: ContentAccessor
Get the content mimetype

Specified by:
getMimetype in interface ContentAccessor
Returns:
Returns a content mimetype

setMimetype

public void setMimetype(java.lang.String mimetype)
Description copied from interface: ContentAccessor
Set the mimetype that must be used for accessing the content

Specified by:
setMimetype in interface ContentAccessor
Parameters:
mimetype - the underlying content's mimetype - null if unknown

getEncoding

public java.lang.String getEncoding()
Description copied from interface: ContentAccessor
Get the encoding of the content being accessed

Specified by:
getEncoding in interface ContentAccessor
Returns:
Returns the content encoding - null if unknown

setEncoding

public void setEncoding(java.lang.String encoding)
Description copied from interface: ContentAccessor
Set the String encoding for this accessor

Specified by:
setEncoding in interface ContentAccessor
Parameters:
encoding - the underlying content's encoding - null if unknown

getLocale

public java.util.Locale getLocale()
Description copied from interface: ContentAccessor
Get the locale of the content being accessed

Specified by:
getLocale in interface ContentAccessor
Returns:
Returns the content locale or null if unkown

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: ContentAccessor
Set the Locale for this accessor

Specified by:
setLocale in interface ContentAccessor
Parameters:
locale - the content's locale, if known.

getCallbackFileChannel

protected java.nio.channels.FileChannel getCallbackFileChannel(java.nio.channels.FileChannel directChannel,
                                                               java.util.List listeners)
                                                        throws ContentIOException
Generate a callback instance of the FileChannel.

Parameters:
directChannel - the delegate that to perform the actual operations
listeners - the listeners to call
Returns:
Returns a new channel that functions just like the original, except that it issues callbacks to the listeners
Throws:
ContentIOException


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.