org.apache.jetspeed.portal.portlets
Class AbstractPortlet

java.lang.Object
  extended byorg.apache.jetspeed.portal.portlets.AbstractPortlet
All Implemented Interfaces:
Cacheable, Portlet, PortletState, org.apache.turbine.services.cache.Refreshable, java.io.Serializable
Direct Known Subclasses:
AbstractInstancePortlet, AbstractPortletControl, AggregatePortlet, ApplicationsPortlet, BadURLManagerPortlet, ClearPortlet, DaemonAdminPortlet, GlobalAdminPortlet, JavaRuntimePortlet, JetspeedContentAdmin, JetspeedPropertiesPortlet, LinkPortlet, PortletInfoPortlet, PreviewPortlet, ServletContextPortlet, ServletInvokerPortlet, ServletProxyPortlet, TurbineScreenPortlet, XMLPortlet

public abstract class AbstractPortlet
extends java.lang.Object
implements Portlet, PortletState, Cacheable, org.apache.turbine.services.cache.Refreshable

Should be used by most Portlets that wish to conform to default behavior

PERFORMANCE NOTE: getContent returns a StringElement that was generated on setContent(). This is used so that performance is increased since ECS does not have to work overtime to generate output.

Version:
$Id: AbstractPortlet.java,v 1.67 2005/04/02 17:31:08 jford Exp $
Author:
Kevin A. Burton, Raphaël Luta, Santiago Gala, Paul Spencer, Mark Orciuch
See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable content
          Holds instances of ConcreteElements (Portlet output/content) based on its current CapabilityMap.
 
Fields inherited from interface org.apache.jetspeed.portal.Portlet
PORTLET_MAXIMIZED, PORTLET_MINIMIZED, PORTLET_NORMAL
 
Constructor Summary
AbstractPortlet()
           
 
Method Summary
 boolean allowClose(org.apache.turbine.util.RunData rundata)
          Implements the default close behavior: security permissions will be checked.
 boolean allowCustomize(org.apache.turbine.util.RunData rundata)
          Implements the default customize behavior: security permissions will be checked.
 boolean allowInfo(org.apache.turbine.util.RunData rundata)
          Implements the default info behavior: security permissions will be checked.
 boolean allowMaximize(org.apache.turbine.util.RunData rundata)
          Implements the default maximize behavior: security permissions will be checked.
 boolean allowMinimize(org.apache.turbine.util.RunData rundata)
          Implements the default info behavior: security permissions will be checked.
 boolean allowPrintFriendly(org.apache.turbine.util.RunData rundata)
          Implements the default print friendly format behavior: security permissions will be checked.
 boolean allowView(org.apache.turbine.util.RunData rundata)
          Implements the default view behavior: security permissions will be checked.
protected  void clearContent()
           
 boolean getAllowEdit(org.apache.turbine.util.RunData rundata)
          Is the portled editable/customizeable.
 boolean getAllowMaximize(org.apache.turbine.util.RunData rundata)
          Can this portlet be maximized
 boolean getAllowView(org.apache.turbine.util.RunData rundata)
          Is the portled viewable.
 java.lang.String getAttribute(java.lang.String attrName, java.lang.String attrDefValue, org.apache.turbine.util.RunData rundata)
          Retrieve a portlet attribute from persistent storage
 org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData rundata)
          Returns an HTML representation of this portlet.
 org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData rundata, CapabilityMap map)
           
 org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData rundata, CapabilityMap map, boolean allowRecurse)
           
 long getCreationTime()
          Get the creation time for this Portlet
 java.lang.String getDescription()
          Provide a description within PML if the user has specified one.
 java.lang.String getDescription(java.lang.String instanceDescription)
          Provide a Description within PML if the user has specified one.
 java.lang.Long getExpirationMillis()
          Set the expiration time in milliseconds.
 Expire getExpire()
          Used by a Cacheable object to determine when it should expire itself from the cache.
 java.lang.String getHandle()
          Used by the cache to get a unique reference on what you want to add and then retrieve in the future from the cache
static java.lang.Object getHandle(java.lang.Object config)
          Builds a new cache handle for this cacheable class with the specified config object.
 java.lang.String getID()
          Retrieve a unique portlet id
 java.lang.String getImage()
          Getter for property image.
 java.lang.String getImage(java.lang.String instanceImage)
          Getter for property image.
 PortletInstance getInstance(org.apache.turbine.util.RunData rundata)
          Gets the portlet instance associated with this portlet.
 java.lang.String getName()
          Get the portlet's name
 PortletConfig getPortletConfig()
          Get the config of this servlet
 java.lang.String getTitle()
          Provide a title within PML if the user has specified one.
 java.lang.String getTitle(java.lang.String instanceTitle)
          Provide a title within PML if the user has specified one.
 void init()
          By default don't provide any initialization
 boolean isCacheable()
          Is this portlet cacheable.
 boolean isClosed(org.apache.turbine.util.RunData rundata)
          Returns true if this portlet is currently closed
 boolean isMinimized(org.apache.turbine.util.RunData rundata)
          Returns true if this portlet is currently minimized
 boolean isShowTitleBar(org.apache.turbine.util.RunData rundata)
          Returns TRUE if the title bar in should be displayed.
 boolean providesCustomization()
           
 void refresh()
          Usually called by caching system when portlet is marked as expired, but has not be idle longer then TimeToLive.
 void setAttribute(java.lang.String attrName, java.lang.String attrValue, org.apache.turbine.util.RunData rundata)
          Stores a portlet attribute in persistent storage
 void setCacheable(boolean cacheable)
          Set cachable.
 void setCachedObject(org.apache.turbine.services.cache.CachedObject cachedObject)
          Set this portlet's cached object.
 void setClosed(boolean close, org.apache.turbine.util.RunData rundata)
          Toggles the portlet state between closed and normal
protected  void setContent(org.apache.ecs.ConcreteElement content)
           
protected  void setContent(org.apache.ecs.ConcreteElement content, CapabilityMap map)
           
protected  void setContent(java.lang.String content)
           
 void setCreationTime(long creationTime)
          Set the creation time for this Portlet
 void setDescription(java.lang.String description)
          Set the description for this Portlet
 void setExpirationMillis(long expirationMillis)
          Sets the cache expiration time.
 void setHandle(java.lang.String handle)
          Deprecated. cacheable classes should now implement a static getHandle(config) method
 void setID(java.lang.String id)
           
 void setImage(java.lang.String image)
          Setter for property image.
 void setMinimized(boolean minimize, org.apache.turbine.util.RunData rundata)
          Change the portlet visibility state ( minimized <-> normal )
 void setName(java.lang.String name)
          Set the name of the portlet
 void setPortletConfig(PortletConfig pc)
          Set's the configuration of this servlet.
 void setTitle(java.lang.String title)
          Set the title for this Portlet.
 void setTitle(java.lang.String title, org.apache.turbine.util.RunData rundata)
           
 boolean supportsType(MimeType mimeType)
          Returns true portlet is able to output content for given mimetype
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

content

protected java.util.Hashtable content
Holds instances of ConcreteElements (Portlet output/content) based on its current CapabilityMap.

Constructor Detail

AbstractPortlet

public AbstractPortlet()
Method Detail

clearContent

protected void clearContent()

setContent

protected void setContent(org.apache.ecs.ConcreteElement content)

setContent

protected void setContent(java.lang.String content)

setContent

protected void setContent(org.apache.ecs.ConcreteElement content,
                          CapabilityMap map)
                   throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

refresh

public void refresh()
Usually called by caching system when portlet is marked as expired, but has not be idle longer then TimeToLive. This method should be implement in cachable portlets

Specified by:
refresh in interface org.apache.turbine.services.cache.Refreshable

isCacheable

public boolean isCacheable()
Is this portlet cacheable. It is the portlet's responsability to cache the content.

Specified by:
isCacheable in interface Cacheable
Returns:
true Cachable
false Not cachable

setCacheable

public void setCacheable(boolean cacheable)
Set cachable. This should only be called in the portlet's init().

Specified by:
setCacheable in interface Cacheable
Parameters:
cacheable - true Portlet is cachable
false Portlet is NOT cachable

getExpire

public Expire getExpire()
Used by a Cacheable object to determine when it should expire itself from the cache.

Specified by:
getExpire in interface Cacheable
Returns:
Expire

getHandle

public final java.lang.String getHandle()

Used by the cache to get a unique reference on what you want to add and then retrieve in the future from the cache

Most implementations should just call the CacheHandleManager with the given params within the implementation and just return this.

Specified by:
getHandle in interface Cacheable
Returns:
Cache handle (key)

setHandle

public final void setHandle(java.lang.String handle)
Deprecated. cacheable classes should now implement a static getHandle(config) method

Used by a Cacheable object to determine when it should expire itself from the cache.

Specified by:
setHandle in interface Cacheable
Parameters:
handle - Cache Handle

getExpirationMillis

public java.lang.Long getExpirationMillis()
Set the expiration time in milliseconds.

Specified by:
getExpirationMillis in interface Cacheable
Returns:
Expiration time in milliseconds since epoch, or null if the expiration was not set.

setExpirationMillis

public void setExpirationMillis(long expirationMillis)
Sets the cache expiration time. When the portlet is stale (expired), the refresh() will be called if the portlet has not been untouched longer then then it's TimeToLive.

Specified by:
setExpirationMillis in interface Cacheable
Parameters:
expirationMillis - setExpirationMillis Expiration in milliseconds since epoch

getHandle

public static java.lang.Object getHandle(java.lang.Object config)
Builds a new cache handle for this cacheable class with the specified config object.

Parameters:
config - The configuration object to use for building the handle
Returns:
A cache handle

setCachedObject

public void setCachedObject(org.apache.turbine.services.cache.CachedObject cachedObject)
Set this portlet's cached object.

Specified by:
setCachedObject in interface Cacheable
Parameters:
cachedObject - Cached Object associated to this portlet

getName

public java.lang.String getName()
Get the portlet's name

Specified by:
getName in interface Portlet
Returns:
Name of the portlet

setName

public void setName(java.lang.String name)
Set the name of the portlet

Specified by:
setName in interface Portlet
Parameters:
name - Name of the portlet
See Also:
Portlet.getName()

getPortletConfig

public PortletConfig getPortletConfig()
Get the config of this servlet

Specified by:
getPortletConfig in interface Portlet
Returns:
PortletConfig Portlet

setPortletConfig

public void setPortletConfig(PortletConfig pc)
Set's the configuration of this servlet.

Specified by:
setPortletConfig in interface Portlet

getContent

public org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData rundata)
Description copied from interface: Portlet
Returns an HTML representation of this portlet. Usually a Portlet would initialized itself within init() and then when getContent is called it would return its presentation.

Specified by:
getContent in interface Portlet
Parameters:
rundata - The RunData object for the current request

getContent

public org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData rundata,
                                                 CapabilityMap map)

getContent

public org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData rundata,
                                                 CapabilityMap map,
                                                 boolean allowRecurse)
Parameters:
rundata - The RunData object for the current request

getDescription

public java.lang.String getDescription()
Provide a description within PML if the user has specified one.

Specified by:
getDescription in interface Portlet
Returns:
a null entry if the user hasn't defined anything

getDescription

public java.lang.String getDescription(java.lang.String instanceDescription)
Provide a Description within PML if the user has specified one.

Specified by:
getDescription in interface Portlet
Parameters:
instanceDescription - Description from PSML
Returns:
a null if entry AND portlet have not defined a description

setDescription

public void setDescription(java.lang.String description)
Description copied from interface: Portlet
Set the description for this Portlet

Specified by:
setDescription in interface Portlet

getTitle

public java.lang.String getTitle()
Provide a title within PML if the user has specified one.

Specified by:
getTitle in interface Portlet
Returns:
a null entry if the user hasn't defined anything

getTitle

public java.lang.String getTitle(java.lang.String instanceTitle)
Provide a title within PML if the user has specified one.

Specified by:
getTitle in interface Portlet
Parameters:
instanceTitle - Title from PSML
Returns:
a null if entry AND portlet have not defined a title

setTitle

public void setTitle(java.lang.String title)
Set the title for this Portlet.

Specified by:
setTitle in interface Portlet
Parameters:
title - Portlet title.

setTitle

public void setTitle(java.lang.String title,
                     org.apache.turbine.util.RunData rundata)
Specified by:
setTitle in interface Portlet

getImage

public java.lang.String getImage()
Getter for property image.

Returns:
Name of portlet image, icon. The name is expected to be in the form of a URL.

getImage

public java.lang.String getImage(java.lang.String instanceImage)
Getter for property image.

Specified by:
getImage in interface Portlet
Returns:
a null if entry AND portlet have not defined an icon.

setImage

public void setImage(java.lang.String image)
Description copied from interface: Portlet
Setter for property image.

Specified by:
setImage in interface Portlet

getAllowEdit

public boolean getAllowEdit(org.apache.turbine.util.RunData rundata)
Is the portled editable/customizeable.

Specified by:
getAllowEdit in interface Portlet
Parameters:
rundata - The RunData object for the current request
Returns:
true Editing is allow false Editing is NOT alowed

getAllowView

public boolean getAllowView(org.apache.turbine.util.RunData rundata)
Is the portled viewable.

Specified by:
getAllowView in interface Portlet
Parameters:
rundata - The RunData object for the current request
Returns:
true Viewing is allow false Viewing is NOT alowed Override this method to control your own View behavior

getAllowMaximize

public boolean getAllowMaximize(org.apache.turbine.util.RunData rundata)
Can this portlet be maximized

Specified by:
getAllowMaximize in interface Portlet
Parameters:
rundata - The RunData object for the current request
Returns:
true Portlet can be maximized
false Portlet can NOT be maximized

init

public void init()
          throws PortletException
By default don't provide any initialization

Specified by:
init in interface Portlet
Throws:
PortletException

getCreationTime

public long getCreationTime()
Description copied from interface: Portlet
Get the creation time for this Portlet

Specified by:
getCreationTime in interface Portlet

setCreationTime

public void setCreationTime(long creationTime)
Description copied from interface: Portlet
Set the creation time for this Portlet

Specified by:
setCreationTime in interface Portlet

supportsType

public boolean supportsType(MimeType mimeType)
Description copied from interface: Portlet
Returns true portlet is able to output content for given mimetype

Specified by:
supportsType in interface Portlet

allowClose

public boolean allowClose(org.apache.turbine.util.RunData rundata)
Implements the default close behavior: security permissions will be checked.

Specified by:
allowClose in interface PortletState
Parameters:
rundata - The RunData object for the current request

isClosed

public boolean isClosed(org.apache.turbine.util.RunData rundata)
Returns true if this portlet is currently closed

Specified by:
isClosed in interface PortletState
Parameters:
rundata - The RunData object for the current request

setClosed

public void setClosed(boolean close,
                      org.apache.turbine.util.RunData rundata)
Toggles the portlet state between closed and normal

Specified by:
setClosed in interface PortletState
Parameters:
rundata - The RunData object for the current request

allowInfo

public boolean allowInfo(org.apache.turbine.util.RunData rundata)
Implements the default info behavior: security permissions will be checked.

Specified by:
allowInfo in interface PortletState
Parameters:
rundata - The RunData object for the current request

allowCustomize

public boolean allowCustomize(org.apache.turbine.util.RunData rundata)
Implements the default customize behavior: security permissions will be checked.

Specified by:
allowCustomize in interface PortletState
Parameters:
rundata - The RunData object for the current request

allowMaximize

public boolean allowMaximize(org.apache.turbine.util.RunData rundata)
Implements the default maximize behavior: security permissions will be checked.

Specified by:
allowMaximize in interface PortletState
Parameters:
rundata - The RunData object for the current request

allowMinimize

public boolean allowMinimize(org.apache.turbine.util.RunData rundata)
Implements the default info behavior: security permissions will be checked.

Specified by:
allowMinimize in interface PortletState
Parameters:
rundata - The RunData object for the current request

allowView

public boolean allowView(org.apache.turbine.util.RunData rundata)
Implements the default view behavior: security permissions will be checked.

Parameters:
rundata - The RunData object for the current request

allowPrintFriendly

public boolean allowPrintFriendly(org.apache.turbine.util.RunData rundata)
Implements the default print friendly format behavior: security permissions will be checked.

Specified by:
allowPrintFriendly in interface PortletState
Parameters:
rundata - The RunData object for the current request

isMinimized

public boolean isMinimized(org.apache.turbine.util.RunData rundata)
Returns true if this portlet is currently minimized

Specified by:
isMinimized in interface PortletState
Parameters:
rundata - The RunData object for the current request

setMinimized

public void setMinimized(boolean minimize,
                         org.apache.turbine.util.RunData rundata)
Change the portlet visibility state ( minimized <-> normal )

Specified by:
setMinimized in interface PortletState
Parameters:
minimize - True if the portlet change to minimized
rundata - The RunData object for the current request

isShowTitleBar

public boolean isShowTitleBar(org.apache.turbine.util.RunData rundata)
Returns TRUE if the title bar in should be displayed. The title bar includes the portlet title and action buttons. This

Specified by:
isShowTitleBar in interface Portlet
Parameters:
rundata - The RunData object for the current request

getAttribute

public java.lang.String getAttribute(java.lang.String attrName,
                                     java.lang.String attrDefValue,
                                     org.apache.turbine.util.RunData rundata)
Retrieve a portlet attribute from persistent storage

Specified by:
getAttribute in interface Portlet
Parameters:
attrName - The attribute to retrieve
attrDefValue - The value if the attr doesn't exists
rundata - The RunData object for the current request
Returns:
The attribute value

setAttribute

public void setAttribute(java.lang.String attrName,
                         java.lang.String attrValue,
                         org.apache.turbine.util.RunData rundata)
Stores a portlet attribute in persistent storage

Specified by:
setAttribute in interface Portlet
Parameters:
attrName - The attribute to retrieve
rundata - The RunData object for the current request

getInstance

public PortletInstance getInstance(org.apache.turbine.util.RunData rundata)
Gets the portlet instance associated with this portlet.

Specified by:
getInstance in interface Portlet
Parameters:
rundata - The RunData object for the current request
Returns:
PortletInstance

getID

public java.lang.String getID()
Description copied from interface: Portlet
Retrieve a unique portlet id

Specified by:
getID in interface Portlet

setID

public void setID(java.lang.String id)
Specified by:
setID in interface Portlet

providesCustomization

public boolean providesCustomization()
Specified by:
providesCustomization in interface Portlet
Returns:
true if the portlet does its own customization


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.