org.wso2.carbon.context
Class PrivilegedCarbonContext

java.lang.Object
  extended by org.wso2.carbon.context.CarbonContext
      extended by org.wso2.carbon.context.PrivilegedCarbonContext

public class PrivilegedCarbonContext
extends CarbonContext

This CarbonContext provides users the ability to carry out privileged actions such as switching tenant flows, setting tenant ID etc.


Method Summary
static void destroyCurrentContext()
           
static void endTenantFlow()
          This will end the tenant flow and restore the previous CarbonContext.
 Object getOSGiService(Class clazz)
          Deprecated. please use getOSGiService(Class, java.util.Hashtable)instead
 Object getOSGiService(Class clazz, Hashtable<String,String> props)
          Obtain the first OSGi service found for interface or class clazz and props
 List<Object> getOSGiServices(Class clazz)
          Deprecated. please use getOSGiServices(Class, java.util.Hashtable) instead
 List<Object> getOSGiServices(Class clazz, Hashtable<String,String> props)
          Obtain the OSGi services found for interface or class clazz and props
 org.wso2.carbon.registry.api.Registry getRegistry(RegistryType type)
          Method to obtain an instance of a registry on this CarbonContext instance.
 String getTenantDomain(boolean resolve)
          Method to obtain the tenant domain on this CarbonContext instance.
 int getTenantId(boolean resolve)
          Method to obtain the tenant id on this CarbonContext instance.
static PrivilegedCarbonContext getThreadLocalCarbonContext()
           
 void setApplicationName(String applicationName)
           
 void setRegistry(RegistryType type, org.wso2.carbon.registry.api.Registry registry)
          Method to set an instance of a registry on this CarbonContext instance.
 void setTenantDomain(String tenantDomain)
          Method to set the tenant domain on this CarbonContext instance.
 void setTenantDomain(String tenantDomain, boolean resolveTenantId)
          Method to set the tenant domain on this CarbonContext instance.
 void setTenantId(int tenantId)
          Method to set the tenant id on this CarbonContext instance.
 void setTenantId(int tenantId, boolean resolveTenantDomain)
          Method to set the tenant id on this CarbonContext instance.
 void setUsername(String username)
          Method to set the username on this CarbonContext instance.
 void setUserRealm(org.wso2.carbon.user.api.UserRealm userRealm)
           
static void startTenantFlow()
          Starts a tenant flow.
static void unloadTenant(int tenantId)
           
 
Methods inherited from class org.wso2.carbon.context.CarbonContext
createFilter, discover, getApplicationName, getCarbonContextDataHolder, getJNDIContext, getJNDIContext, getQueue, getTenantDomain, getTenantId, getUsername, getUserRealm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

startTenantFlow

public static void startTenantFlow()
Starts a tenant flow. This will stack the current CarbonContext and begin a new nested flow which can have an entirely different context. This is ideal for scenarios where multiple super-tenant and sub-tenant phases are required within as a single block of execution.

See Also:
CarbonContextDataHolder.startTenantFlow()

endTenantFlow

public static void endTenantFlow()
This will end the tenant flow and restore the previous CarbonContext.

See Also:
CarbonContextDataHolder.endTenantFlow()

unloadTenant

public static void unloadTenant(int tenantId)

destroyCurrentContext

public static void destroyCurrentContext()

getThreadLocalCarbonContext

public static PrivilegedCarbonContext getThreadLocalCarbonContext()
Returns:
PrivilegedCarbonContext from the current thread

setTenantId

public void setTenantId(int tenantId)
Method to set the tenant id on this CarbonContext instance. This method will not automatically calculate the tenant domain based on the tenant id.

Parameters:
tenantId - the tenant id.

setTenantId

public void setTenantId(int tenantId,
                        boolean resolveTenantDomain)
Method to set the tenant id on this CarbonContext instance.

Parameters:
tenantId - the tenant id.
resolveTenantDomain - whether the tenant domain should be calculated based on this tenant id.

setUsername

public void setUsername(String username)
Method to set the username on this CarbonContext instance.

Parameters:
username - the username.

setTenantDomain

public void setTenantDomain(String tenantDomain)
Method to set the tenant domain on this CarbonContext instance. This method will not automatically calculate the tenant id based on the tenant domain.

Parameters:
tenantDomain - the tenant domain.

setTenantDomain

public void setTenantDomain(String tenantDomain,
                            boolean resolveTenantId)
Method to set the tenant domain on this CarbonContext instance.

Parameters:
tenantDomain - the tenant domain.
resolveTenantId - whether the tenant id should be calculated based on this tenant domain.

getTenantDomain

public String getTenantDomain(boolean resolve)
Method to obtain the tenant domain on this CarbonContext instance. This method can optionally resolve the tenant domain using the tenant id that is already posses.

Parameters:
resolve - whether the tenant domain should be calculated based on the tenant id that is already known.
Returns:
the tenant domain.

getTenantId

public int getTenantId(boolean resolve)
Method to obtain the tenant id on this CarbonContext instance. This method can optionally resolve the tenant id using the tenant domain that is already posses.

Parameters:
resolve - whether the tenant id should be calculated based on the tenant domain that is already known.
Returns:
the tenant id.

setRegistry

public void setRegistry(RegistryType type,
                        org.wso2.carbon.registry.api.Registry registry)
Method to set an instance of a registry on this CarbonContext instance.

Parameters:
type - the type of registry to set.
registry - the registry instance.

getRegistry

public org.wso2.carbon.registry.api.Registry getRegistry(RegistryType type)
Method to obtain an instance of a registry on this CarbonContext instance.

Overrides:
getRegistry in class CarbonContext
Parameters:
type - the type of registry required.
Returns:
the requested registry instance.

setUserRealm

public void setUserRealm(org.wso2.carbon.user.api.UserRealm userRealm)

getOSGiService

@Deprecated
public Object getOSGiService(Class clazz)
Deprecated. please use getOSGiService(Class, java.util.Hashtable)instead

Obtain the first OSGi service found for interface or class clazz

Overrides:
getOSGiService in class CarbonContext
Parameters:
clazz - The type of the OSGi service
Returns:
The OSGi service

getOSGiServices

@Deprecated
public List<Object> getOSGiServices(Class clazz)
Deprecated. please use getOSGiServices(Class, java.util.Hashtable) instead

Obtain the OSGi services found for interface or class clazz

Overrides:
getOSGiServices in class CarbonContext
Parameters:
clazz - The type of the OSGi service
Returns:
The List of OSGi services

getOSGiService

public Object getOSGiService(Class clazz,
                             Hashtable<String,String> props)
Obtain the first OSGi service found for interface or class clazz and props

Overrides:
getOSGiService in class CarbonContext
Parameters:
props - attribute list that filter the service
clazz - The type of the OSGi service
Returns:
The OSGi service

getOSGiServices

public List<Object> getOSGiServices(Class clazz,
                                    Hashtable<String,String> props)
Obtain the OSGi services found for interface or class clazz and props

Overrides:
getOSGiServices in class CarbonContext
Parameters:
props - attribute list that filter the service list
clazz - The type of the OSGi service
Returns:
The List of OSGi services

setApplicationName

public void setApplicationName(String applicationName)


Copyright © 2014 WSO2 Inc. All rights reserved.