Package org.exoplatform.container
Class PortalContainer
- java.lang.Object
-
- org.exoplatform.container.AbstractContainer
-
- org.exoplatform.container.ExoContainer
-
- org.exoplatform.container.PortalContainer
-
- All Implemented Interfaces:
Serializable,Container,Disposable,Startable
public class PortalContainer extends ExoContainer
Created by The eXo Platform SAS
The Portal Container is an object responsible for loading services/components.- Author:
- Mestrallet Benjamin Date: Jul 31, 2003 Time: 12:15:28 AM
- See Also:
- Serialized Form
- eXo level API
- Provisional
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPortalContainer.RegisterTaskThis class is used to register a portal containerstatic classPortalContainer.UnregisterTaskThis class is used to unregister a portal container
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_PORTAL_CONTAINER_NAMEThe default name of the portal containerstatic StringDEFAULT_REALM_NAMEThe default name of a the realmstatic StringDEFAULT_REST_CONTEXT_NAMEThe default name of a theServletContextof the rest web application-
Fields inherited from class org.exoplatform.container.ExoContainer
context, LOG, parent, stopping
-
Fields inherited from class org.exoplatform.container.AbstractContainer
delegate
-
-
Constructor Summary
Constructors Constructor Description PortalContainer(RootContainer parent, javax.servlet.ServletContext portalContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddInitTask(javax.servlet.ServletContext context, RootContainer.PortalContainerInitTask task)Add an init-task to all the portal container instances related to the given ServletContextstatic voidaddInitTask(javax.servlet.ServletContext context, RootContainer.PortalContainerInitTask task, String portalContainerName)Add an init-task to all the portal container instances related to the given ServletContext if the given portal container name isnullother it will execute the task only of this portal container if theServletContextis on of its dependenciesstatic ObjectgetComponent(Class<?> key)StringgetConfigurationXML()static PortalContainergetCurrentInstance(javax.servlet.ServletContext context)We first try to get the ExoContainer that has been stored into the ThreadLocal if the value is of type PortalContainer, we return it otherwise we get the portal container corresponding the given servlet contextstatic StringgetCurrentPortalContainerName()Returns the name of the current portal container that has been stored into the ThreadLocal.static StringgetCurrentRealmName()Returns the name of the current realm corresponding to the portal container that has been stored into the ThreadLocal.static StringgetCurrentRestContextName()Returns the name of the current rest context corresponding to the portal container that has been stored into the ThreadLocal.static ObjectgetCurrentSetting(String settingName)Returns the current value of the setting corresponding to the portal container that has been stored into the ThreadLocal.static PortalContainergetInstance()static PortalContainergetInstance(javax.servlet.ServletContext context)Gives the first portal container instance related to the given ServletContextstatic PortalContainergetInstanceIfPresent()StringgetName()ClassLoadergetPortalClassLoader()PortalContainerInfogetPortalContainerInfo()javax.servlet.ServletContextgetPortalContext()StringgetRealmName()Returns the name of the realm corresponding to the current portal containerstatic StringgetRealmName(String portalContainerName)Returns the name of the realm corresponding to the given portal container nameStringgetRestContextName()Returns the name of the rest context corresponding to the current portal containerstatic StringgetRestContextName(String portalContainerName)Returns the name of the rest context corresponding to the given portal container nameObjectgetSetting(String settingName)Returns the value of the setting corresponding to the current portal containerstatic ObjectgetSetting(String portalContainerName, String settingName)Returns the value of the setting corresponding to the given portal container name and the given setting nameClassLoadergetWebAppClassLoader(javax.servlet.ServletContext context)This gives the mergedClassLoaderbetween thePortalContainerClassLoaderand theClassLoaderof the web application.static booleanisPortalContainerName(String name)static booleanisPortalContainerNameDisabled(String name)static booleanisScopeValid(PortalContainer container, javax.servlet.ServletContext context)Indicates if the given servlet context is a dependency of the given portal containerbooleanisStarted()voidregisterContext(javax.servlet.ServletContext context)Register a new servlet context that contains configuration files and potentially resource files We assume that this method is called within the initialization context of the related web applicationstatic voidsetInstance(PortalContainer instance)voidstart()Start this component.voidstop()Stop this component.voidunregisterContext(javax.servlet.ServletContext context)Unregister a servlet context that contains configuration files and potentially resource files-
Methods inherited from class org.exoplatform.container.ExoContainer
addComponentLifecylePlugin, addContainerLifecylePlugin, canBeDisposed, canBeInitialized, canBeStarted, canBeStopped, createComponent, dispose, getComponentAdapter, getComponentAdapter, getComponentAdapter, getComponentAdapterOfType, getComponentAdapterOfType, getComponentInstance, getComponentInstance, getComponentInstance, getComponentInstanceOfType, getComponentInstanceOfType, getConfiguration, getContext, getContextManager, getExternalComponentPluginsUnused, getParent, getProfiles, getProfilesFromProperty, getRegisteredComponentNames, hasProfile, hasProfileInProperty, initContainerInternal, initialize, isContextManagerLoaded, registerComponentImplementation, registerComponentInstance, start, unregisterAllComponents
-
Methods inherited from class org.exoplatform.container.AbstractContainer
accept, createComponent, getComponentAdapters, getComponentAdaptersOfType, getComponentInstancesOfType, getManagementContext, getMBeanServer, getScopingObjectName, getSuccessor, registerComponentImplementation, registerComponentInstance, unregisterComponent
-
-
-
-
Field Detail
-
DEFAULT_PORTAL_CONTAINER_NAME
public static String DEFAULT_PORTAL_CONTAINER_NAME
The default name of the portal container
-
DEFAULT_REST_CONTEXT_NAME
public static String DEFAULT_REST_CONTEXT_NAME
The default name of a theServletContextof the rest web application
-
DEFAULT_REALM_NAME
public static String DEFAULT_REALM_NAME
The default name of a the realm
-
-
Constructor Detail
-
PortalContainer
public PortalContainer(RootContainer parent, javax.servlet.ServletContext portalContext)
-
-
Method Detail
-
getWebAppClassLoader
public ClassLoader getWebAppClassLoader(javax.servlet.ServletContext context)
This gives the mergedClassLoaderbetween thePortalContainerClassLoaderand theClassLoaderof the web application.- Parameters:
context- theServletContextof the web application- Returns:
- the merged
ClassLoaderbetween thePortalContainerClassLoaderand theClassLoaderof the web application that allows us to override resources contained into theClassLoaderof the web application
-
getPortalClassLoader
public ClassLoader getPortalClassLoader()
- Returns:
- the full
ClassLoaderof the portal container after merging all theClassLoaderof allServletContextthat have been registered
-
getPortalContext
public javax.servlet.ServletContext getPortalContext()
- Returns:
- the full
ServletContextof the portal container after merging all theServletContextthat have been registered
-
registerContext
public void registerContext(javax.servlet.ServletContext context)
Register a new servlet context that contains configuration files and potentially resource files We assume that this method is called within the initialization context of the related web application- Parameters:
context- theServletContextof the web application to register
-
unregisterContext
public void unregisterContext(javax.servlet.ServletContext context)
Unregister a servlet context that contains configuration files and potentially resource files- Parameters:
context- theServletContextof the web application to unregister
-
getName
public String getName()
- Returns:
- returns the portal container name
-
getConfigurationXML
public String getConfigurationXML()
- Returns:
- returns the configuration of the container in XML format
-
getPortalContainerInfo
public PortalContainerInfo getPortalContainerInfo()
-
getInstance
public static PortalContainer getInstance()
- Returns:
- the current instance of
PortalContainerthat has been stored into the relatedThreadLocal. If no value has been set the default portal container will be returned
-
getInstanceIfPresent
public static PortalContainer getInstanceIfPresent()
- Returns:
- the current instance of
ExoContainerthat has been stored into theThreadLocalofExoContainerContext. If noPortalContainerhas been set, it will returnnull
-
isPortalContainerName
public static boolean isPortalContainerName(String name)
- Parameters:
name- the portal container name- See Also:
PortalContainerConfig.isPortalContainerName(String)
-
isPortalContainerNameDisabled
public static boolean isPortalContainerNameDisabled(String name)
- Parameters:
name- the portal container name- See Also:
PortalContainerConfig.isPortalContainerNameDisabled(String)
-
addInitTask
public static void addInitTask(javax.servlet.ServletContext context, RootContainer.PortalContainerInitTask task)Add an init-task to all the portal container instances related to the given ServletContext- Parameters:
context- the context from which we extract the context nametask- the task to execute
-
addInitTask
public static void addInitTask(javax.servlet.ServletContext context, RootContainer.PortalContainerInitTask task, String portalContainerName)Add an init-task to all the portal container instances related to the given ServletContext if the given portal container name isnullother it will execute the task only of this portal container if theServletContextis on of its dependencies- Parameters:
context- the context from which we extract the context nametask- the task to executeportalContainerName- the name of the portal container for which we want to execute the task
-
getInstance
public static PortalContainer getInstance(javax.servlet.ServletContext context)
Gives the first portal container instance related to the given ServletContext- Parameters:
context- the context from which we extract the context name
-
getCurrentInstance
public static PortalContainer getCurrentInstance(javax.servlet.ServletContext context)
We first try to get the ExoContainer that has been stored into the ThreadLocal if the value is of type PortalContainer, we return it otherwise we get the portal container corresponding the given servlet context- Parameters:
context- the context from which we extract the portal container name
-
getCurrentPortalContainerName
public static String getCurrentPortalContainerName()
Returns the name of the current portal container that has been stored into the ThreadLocal. If no value can be found the value of PortalContainer.DEFAULT_PORTAL_CONTAINER_NAME will be used
-
getCurrentRestContextName
public static String getCurrentRestContextName()
Returns the name of the current rest context corresponding to the portal container that has been stored into the ThreadLocal. If no value can be found the value of PortalContainer.DEFAULT_REST_CONTEXT_NAME will be used
-
getRestContextName
public static String getRestContextName(String portalContainerName)
Returns the name of the rest context corresponding to the given portal container name- Parameters:
portalContainerName- the name of the portal container for which we want the name of the restServletContext
-
getRestContextName
public String getRestContextName()
Returns the name of the rest context corresponding to the current portal container- Returns:
- returns the name of the rest context
-
getCurrentRealmName
public static String getCurrentRealmName()
Returns the name of the current realm corresponding to the portal container that has been stored into the ThreadLocal. If no value can be found the value of PortalContainer.DEFAULT_REALM_NAME will be used- Returns:
- returns the name of the current realm corresponding to the portal container
-
getRealmName
public static String getRealmName(String portalContainerName)
Returns the name of the realm corresponding to the given portal container name- Parameters:
portalContainerName- the name of the portal container for which we want the name of the realm- Returns:
- returns the name of the realm corresponding to the given portal container name
-
getRealmName
public String getRealmName()
Returns the name of the realm corresponding to the current portal container- Returns:
- returns the name of the realm corresponding to the current portal container
-
getCurrentSetting
public static Object getCurrentSetting(String settingName)
Returns the current value of the setting corresponding to the portal container that has been stored into the ThreadLocal. If no value can be found,nullwill be returned- Parameters:
settingName- the name of the setting wanted- Returns:
- returns the current value of the setting corresponding to the portal container
-
getSetting
public static Object getSetting(String portalContainerName, String settingName)
Returns the value of the setting corresponding to the given portal container name and the given setting name- Parameters:
portalContainerName- the name of the portal container for which we want the name of the value of the settingsettingName- the name of the setting wanted- Returns:
- returns the value of the setting corresponding to the given portal container name
-
getSetting
public Object getSetting(String settingName)
Returns the value of the setting corresponding to the current portal container- Parameters:
settingName- the name of the setting wanted- Returns:
- returns the value of the setting
-
isScopeValid
public static boolean isScopeValid(PortalContainer container, javax.servlet.ServletContext context)
Indicates if the given servlet context is a dependency of the given portal container- Parameters:
container- the portal containercontext- theServletContext- Returns:
trueif the dependencies matches,falseotherwise;
-
isStarted
public boolean isStarted()
-
start
public void start()
Description copied from class:AbstractContainerStart this component. Called initially at the begin of the lifecycle. It can be called again after a stop.- Specified by:
startin interfaceStartable- Overrides:
startin classExoContainer
-
stop
public void stop()
Description copied from class:AbstractContainerStop this component. Called near the end of the lifecycle. It can be called again after a further start. ImplementDisposableif you need a single call at the definite end of the lifecycle.- Specified by:
stopin interfaceStartable- Overrides:
stopin classExoContainer
-
setInstance
public static void setInstance(PortalContainer instance)
-
-