org.jboss.portal.server.impl
Class LayoutServerImpl

java.lang.Object
  extended by org.jboss.portal.server.impl.LayoutServerImpl
All Implemented Interfaces:
LayoutServer, org.jboss.system.Service

public class LayoutServerImpl
extends java.lang.Object
implements LayoutServer, org.jboss.system.Service

Implementaion of the layout server.

The layout server is a registry of all available layouts. The server also allows access to all available render sets and layout strategies. Render sets and layout strategies can be independent (named), or children of a layout. Accordingly, the layout server provides accessor methods to get strategies and render set by name, or by layout. Render sets and layout strategies can, and must, be defined for a specific media type (mime type).

See Also:
PortalLayout, PortalRenderSet, LayoutStrategy, MediaType

Constructor Summary
LayoutServerImpl()
           
 
Method Summary
 void addLayout(LayoutRegistrationMetaData metaData)
          Add a layout.
 void addRenderSet(PortalRenderSet renderSet)
           
 void addStrategy(AbstractLayoutStrategy strategy)
           
 void create()
           
 void destroy()
           
 PortalLayout getLayout(ServerRegistrationID id, boolean defaultOnNull)
          Get the layout for the provided registration id.
 PortalLayout getLayout(java.lang.String name, boolean defaultOnNull)
          Get the layout for the provided name.
 PortalRenderSet getRenderSet(PortalLayout layout, MediaType mediaType)
          Get the render set for the provided layout.
 PortalRenderSet getRenderSet(java.lang.String renderSetName, MediaType mediaType)
          Get the render set for the provided layout.
 LayoutStrategy getStrategy(PortalLayout layout, MediaType mediaType)
          Get the layout strategy that was defined for the provided layout.
 LayoutStrategy getStrategy(java.lang.String strategyName, MediaType mediaType)
           
 void removeLayout(ServerRegistrationID id)
          Remove the layout identified by the provided registration id.
 void removeLayouts(java.lang.String appName)
          Remove all layouts that are hosted in the provided application.
 void removeRenderSets(java.lang.String appName)
          Remove all rendersets that are hosted in the provided application.
 void removeStrategies(java.lang.String appName)
          Remove all strategies that are hosted in the provided application.
 void setDefaultLayout(java.lang.String name)
          Set the default layout (on a global level).
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayoutServerImpl

public LayoutServerImpl()
Method Detail

create

public void create()
            throws java.lang.Exception
Specified by:
create in interface org.jboss.system.Service
Throws:
java.lang.Exception
See Also:
Service.create()

destroy

public void destroy()
Specified by:
destroy in interface org.jboss.system.Service
See Also:
Service.destroy()

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface org.jboss.system.Service
Throws:
java.lang.Exception
See Also:
Service.start()

stop

public void stop()
Specified by:
stop in interface org.jboss.system.Service
See Also:
Service.stop()

addLayout

public void addLayout(LayoutRegistrationMetaData metaData)
               throws LayoutException
Description copied from interface: LayoutServer
Add a layout.

Specified by:
addLayout in interface LayoutServer
Parameters:
metaData - the meta information about the layout
Throws:
LayoutException
See Also:
LayoutServer.addLayout(LayoutRegistrationMetaData)

setDefaultLayout

public void setDefaultLayout(java.lang.String name)
                      throws LayoutException
Description copied from interface: LayoutServer
Set the default layout (on a global level).

Specified by:
setDefaultLayout in interface LayoutServer
Parameters:
name - the name of the layout to set as default
Throws:
LayoutException
See Also:
LayoutServer.setDefaultLayout(String)

getLayout

public PortalLayout getLayout(ServerRegistrationID id,
                              boolean defaultOnNull)
Description copied from interface: LayoutServer
Get the layout for the provided registration id.

Specified by:
getLayout in interface LayoutServer
Parameters:
id - the registration id of the layout to get
defaultOnNull - true, if the default layout (if any is defined) should be returned in case the requested layout is not found
Returns:
the requested layout , of the default layout, or null
See Also:
LayoutServer.getLayout(org.jboss.portal.server.ServerRegistrationID, boolean)

getLayout

public PortalLayout getLayout(java.lang.String name,
                              boolean defaultOnNull)
Description copied from interface: LayoutServer
Get the layout for the provided name.

Specified by:
getLayout in interface LayoutServer
Parameters:
name - the name of the layout to request
defaultOnNull - true, if the default layout (if any is defined) should be returned in case the requested layout is not found
Returns:
the requested layout , of the default layout, or null
See Also:
LayoutServer.getLayout(String, boolean)

removeLayout

public void removeLayout(ServerRegistrationID id)
                  throws LayoutException
Remove the layout identified by the provided registration id.

Parameters:
id - the id of the layout that needs to be removed
Throws:
LayoutException

removeLayouts

public void removeLayouts(java.lang.String appName)
                   throws LayoutException
Description copied from interface: LayoutServer
Remove all layouts that are hosted in the provided application.

Specified by:
removeLayouts in interface LayoutServer
Parameters:
appName - the name of the application that hosts the layout(s) to be removed
Throws:
LayoutException
See Also:
LayoutServer.removeLayouts(String)

addStrategy

public void addStrategy(AbstractLayoutStrategy strategy)
Specified by:
addStrategy in interface LayoutServer
See Also:
LayoutServer.addStrategy(org.jboss.portal.server.theme.strategy.AbstractLayoutStrategy)

getStrategy

public LayoutStrategy getStrategy(PortalLayout layout,
                                  MediaType mediaType)
Description copied from interface: LayoutServer
Get the layout strategy that was defined for the provided layout.

In the layout descriptor (portal-layouts.xml) a strategy can be defined to be used in conjunction with every layout that is defined in this file. The layout must be defined per media type. The portal provides a default implementation on a strategy which can be accessed by passing null as the layout.

Specified by:
getStrategy in interface LayoutServer
Parameters:
layout - the layout to get the strategy for (or null for the default layout strategy)
mediaType - the media type (content type ; mime type) of the strategy
Returns:
an implementation of a LayoutStrategy or null if no strategy was found
See Also:
LayoutServer.getStrategy(org.jboss.portal.server.theme.PortalLayout, org.jboss.portal.common.MediaType)

getStrategy

public LayoutStrategy getStrategy(java.lang.String strategyName,
                                  MediaType mediaType)
Specified by:
getStrategy in interface LayoutServer
Returns:
See Also:
LayoutServer.getStrategy(String, org.jboss.portal.common.MediaType)

removeStrategies

public void removeStrategies(java.lang.String appName)
                      throws LayoutException
Description copied from interface: LayoutServer
Remove all strategies that are hosted in the provided application.

Specified by:
removeStrategies in interface LayoutServer
Parameters:
appName - the name of the application that hosts the strategie(s) to be removed
Throws:
LayoutException
See Also:
LayoutServer.removeStrategies(String)

addRenderSet

public void addRenderSet(PortalRenderSet renderSet)
Specified by:
addRenderSet in interface LayoutServer
See Also:
LayoutServer.addRenderSet(org.jboss.portal.server.theme.PortalRenderSet)

getRenderSet

public PortalRenderSet getRenderSet(PortalLayout layout,
                                    MediaType mediaType)
Description copied from interface: LayoutServer
Get the render set for the provided layout.

Specified by:
getRenderSet in interface LayoutServer
Returns:
See Also:
LayoutServer.getRenderSet(org.jboss.portal.server.theme.PortalLayout, org.jboss.portal.common.MediaType)

getRenderSet

public PortalRenderSet getRenderSet(java.lang.String renderSetName,
                                    MediaType mediaType)
Description copied from interface: LayoutServer
Get the render set for the provided layout.

Specified by:
getRenderSet in interface LayoutServer
Returns:
See Also:
LayoutServer.getRenderSet(String, org.jboss.portal.common.MediaType)

removeRenderSets

public void removeRenderSets(java.lang.String appName)
                      throws LayoutException
Description copied from interface: LayoutServer
Remove all rendersets that are hosted in the provided application.

Specified by:
removeRenderSets in interface LayoutServer
Parameters:
appName - the name of the application that hosts the render set(s) to be removed
Throws:
LayoutException
See Also:
LayoutServer.removeRenderSets(String)