org.jboss.portal.theme.impl
Class ThemeServiceImpl

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.portal.jems.as.system.AbstractJBossService
              extended by org.jboss.portal.theme.impl.ThemeServiceImpl
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, ThemeService, ThemeServiceInfo, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class ThemeServiceImpl
extends AbstractJBossService
implements ThemeService, org.jboss.system.Service

TODO: A description of this class.

Version:
$Revision: 8784 $
Author:
Martin Holzner.

Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
ThemeServiceImpl()
           
 
Method Summary
 void addTheme(RuntimeContext runtimeContext, PortalThemeMetaData metaData)
          Add a theme.
protected  void createService()
           
protected  void destroyService()
           
 PortalTheme getDefaultTheme()
           
 PortalTheme getTheme(ServerRegistrationID themeId, boolean defaultOnNull)
          Get a reference to a theme.
 PortalTheme getTheme(java.lang.String name, boolean defaultOnNull)
          Get a reference to a theme.
 PortalTheme getThemeById(java.lang.String themeIdString)
           
 java.util.Collection getThemeNames()
          Get a Collection of all the registered theme's names
 java.util.Collection getThemes()
          Get a Collection of all registered themes.
static java.lang.String[] parseId(java.lang.String layoutIDString)
          parse the provided String for '.' as a separator.
 void removeTheme(PortalTheme theme)
          Remove the theme from the available themes.
 void removeThemes(java.lang.String appId)
          Remove all themes that are registered with the provided application.
 void setDefault(ServerRegistrationID themeId)
          Set the default theme on a global scope.
 void setDefaultFromName(java.lang.String name)
          Set the default theme.
 void setDefaultThemeName(java.lang.String defaultName)
           
protected  void startService()
           
protected  void stopService()
           
 
Methods inherited from class org.jboss.portal.jems.as.system.AbstractJBossService
create, destroy, getState, getStateString, start, stop
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Constructor Detail

ThemeServiceImpl

public ThemeServiceImpl()
Method Detail

createService

protected void createService()
                      throws java.lang.Exception
Overrides:
createService in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception

destroyService

protected void destroyService()
Overrides:
destroyService in class org.jboss.system.ServiceMBeanSupport

startService

protected void startService()
                     throws java.lang.Exception
Overrides:
startService in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception

stopService

protected void stopService()
Overrides:
stopService in class org.jboss.system.ServiceMBeanSupport

addTheme

public void addTheme(RuntimeContext runtimeContext,
                     PortalThemeMetaData metaData)
              throws ThemeException
Description copied from interface: ThemeService
Add a theme.

Specified by:
addTheme in interface ThemeService
metaData - the meta data about the theme
Throws:
ThemeException

removeTheme

public void removeTheme(PortalTheme theme)
Description copied from interface: ThemeService
Remove the theme from the available themes.

Specified by:
removeTheme in interface ThemeService
Parameters:
theme - the theme to be removed
See Also:
ThemeService.removeTheme(org.jboss.portal.theme.PortalTheme)

removeThemes

public void removeThemes(java.lang.String appId)
Description copied from interface: ThemeService
Remove all themes that are registered with the provided application.

On deployment of a new application, the theme descriptor (if any present) in that application is parsed for themes that are to be registered with the theme server. For each entry in the descriptor, a new theme is registered with the theme server. Uppon undeployment of that same application, all themes must be deregistered. This method is a convenient way to achieve this.

Specified by:
removeThemes in interface ThemeService
Parameters:
appId - the name of the application that hosts the themes to unregister
See Also:
ThemeService.removeThemes(String)

setDefault

public void setDefault(ServerRegistrationID themeId)
                throws ThemeException
Description copied from interface: ThemeService
Set the default theme on a global scope.

Specified by:
setDefault in interface ThemeService
Parameters:
themeId - the registration id of the theme to be the new default theme
Throws:
ThemeException - if the theme with this id is not available in the list of currently registered themes
See Also:
ThemeService.setDefault(org.jboss.portal.theme.ServerRegistrationID)

setDefaultThemeName

public void setDefaultThemeName(java.lang.String defaultName)
                         throws ThemeException
Throws:
ThemeException

getDefaultTheme

public PortalTheme getDefaultTheme()
Specified by:
getDefaultTheme in interface ThemeService

setDefaultFromName

public void setDefaultFromName(java.lang.String name)
                        throws ThemeException
Set the default theme.

Parameters:
name - the name of the theme that is to be set as default
Throws:
ThemeException - if the theme is not part of the available themes

getTheme

public PortalTheme getTheme(ServerRegistrationID themeId,
                            boolean defaultOnNull)
Description copied from interface: ThemeServiceInfo
Get a reference to a theme.

Specified by:
getTheme in interface ThemeServiceInfo
Parameters:
themeId - the registration id of the theme to retrieve
defaultOnNull - true, when the server should return the default theme, in case the requested is not found
Returns:
the requested theme, null, or the default theme if defaultOnNull was provided as true
See Also:
ThemeServiceInfo.getTheme(org.jboss.portal.theme.ServerRegistrationID,boolean)

getTheme

public PortalTheme getTheme(java.lang.String name,
                            boolean defaultOnNull)
Description copied from interface: ThemeServiceInfo
Get a reference to a theme.

Specified by:
getTheme in interface ThemeServiceInfo
Parameters:
name - the name of the theme to retrieve
defaultOnNull - true, when the server should return the default theme, in case the requested is not found
Returns:
the requested theme, null, or the default theme if defaultOnNull was provided as true
See Also:
ThemeServiceInfo.getTheme(String,boolean)

getThemeById

public PortalTheme getThemeById(java.lang.String themeIdString)
Specified by:
getThemeById in interface ThemeServiceInfo
Returns:

getThemes

public java.util.Collection getThemes()
Description copied from interface: ThemeServiceInfo
Get a Collection of all registered themes.

Specified by:
getThemes in interface ThemeServiceInfo
Returns:
a Collection of all registered themes
See Also:
ThemeServiceInfo.getThemes()

getThemeNames

public java.util.Collection getThemeNames()
Description copied from interface: ThemeServiceInfo
Get a Collection of all the registered theme's names

Specified by:
getThemeNames in interface ThemeServiceInfo
Returns:
a collection of theme names
See Also:
ThemeServiceInfo.getThemeNames()

parseId

public static java.lang.String[] parseId(java.lang.String layoutIDString)
parse the provided String for '.' as a separator. For each token, add an entry to a String[] that will be returned as the result

Parameters:
layoutIDString - the string to be examined
Returns:
an array of Strings