org.wso2.carbon.context
Class CarbonContext

java.lang.Object
  extended by org.wso2.carbon.context.CarbonContext
Direct Known Subclasses:
PrivilegedCarbonContext

public class CarbonContext
extends Object

This provides the API for sub-tenant programming around WSO2 Carbon and WSO2 Stratos. Each CarbonContext will utilize an underlying CarbonContextDataHolder instance, which will store the actual data.


Constructor Summary
protected CarbonContext(CarbonContextDataHolder carbonContextHolder)
          Creates a CarbonContext using the given CarbonContext holder as its backing instance.
 
Method Summary
protected  org.osgi.framework.Filter createFilter(org.osgi.framework.BundleContext bundleContext, Class clazz, Hashtable<String,String> props)
          Create filter from the bundle context adding class name and properties
 String[] discover(URI[] scopes)
          Method to discover a set of service endpoints belonging the defined scopes..
 String getApplicationName()
           
protected  CarbonContextDataHolder getCarbonContextDataHolder()
          Utility method to obtain the current CarbonContext holder after an instance of a CarbonContext has been created.
 Context getJNDIContext()
          Method to obtain a JNDI-context.
 Context getJNDIContext(Hashtable properties)
          Method to obtain a JNDI-context with the given initialization properties.
 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.queuing.CarbonQueue<?> getQueue(String name)
          Method to obtain a named queue instance.
 org.wso2.carbon.registry.api.Registry getRegistry(RegistryType type)
          Method to obtain an instance of a registry on this CarbonContext instance.
 String getTenantDomain()
          Method to obtain the tenant domain on this CarbonContext instance.
 int getTenantId()
          Method to obtain the tenant id on this CarbonContext instance.
static CarbonContext getThreadLocalCarbonContext()
           
 String getUsername()
          Method to obtain the username on this CarbonContext instance.
 org.wso2.carbon.user.api.UserRealm getUserRealm()
          Method to obtain the user realm on this CarbonContext instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CarbonContext

protected CarbonContext(CarbonContextDataHolder carbonContextHolder)
Creates a CarbonContext using the given CarbonContext holder as its backing instance.

Parameters:
carbonContextHolder - the CarbonContext holder that backs this CarbonContext object.
See Also:
CarbonContextDataHolder
Method Detail

getCarbonContextDataHolder

protected CarbonContextDataHolder getCarbonContextDataHolder()
Utility method to obtain the current CarbonContext holder after an instance of a CarbonContext has been created.

Returns:
the current CarbonContext holder

getThreadLocalCarbonContext

public static CarbonContext getThreadLocalCarbonContext()

getTenantId

public int getTenantId()
Method to obtain the tenant id on this CarbonContext instance.

Returns:
the tenant id.

getUsername

public String getUsername()
Method to obtain the username on this CarbonContext instance.

Returns:
the username.

getTenantDomain

public String getTenantDomain()
Method to obtain the tenant domain on this CarbonContext instance.

Returns:
the tenant domain.

getRegistry

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

Parameters:
type - the type of registry required.
Returns:
the requested registry instance.

getUserRealm

public org.wso2.carbon.user.api.UserRealm getUserRealm()
Method to obtain the user realm on this CarbonContext instance.

Returns:
the user realm instance.

getQueue

public org.wso2.carbon.queuing.CarbonQueue<?> getQueue(String name)
Method to obtain a named queue instance.

Parameters:
name - the name of the queue instance.
Returns:
the queue instance.

getJNDIContext

public Context getJNDIContext(Hashtable properties)
                       throws NamingException
Method to obtain a JNDI-context with the given initialization properties.

Parameters:
properties - the properties required to create the JNDI-contNDext instance.
Returns:
the JNDI-context.
Throws:
NamingException - if the operation failed.

getJNDIContext

public Context getJNDIContext()
                       throws NamingException
Method to obtain a JNDI-context.

Returns:
the JNDI-context.
Throws:
NamingException - if the operation failed.

discover

public String[] discover(URI[] scopes)
Method to discover a set of service endpoints belonging the defined scopes..

Parameters:
scopes - the scopes in which to look-up for the service.
Returns:
a list of service endpoints.

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

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

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

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

Parameters:
props - attribute list that filter the service list
clazz - The type of the OSGi service
Returns:
The List of OSGi services

createFilter

protected org.osgi.framework.Filter createFilter(org.osgi.framework.BundleContext bundleContext,
                                                 Class clazz,
                                                 Hashtable<String,String> props)
                                          throws org.osgi.framework.InvalidSyntaxException
Create filter from the bundle context adding class name and properties

Parameters:
bundleContext - BundleContext
clazz - The type of the OSGi service
props - attribute list that filter the service list
Returns:
Filter
Throws:
org.osgi.framework.InvalidSyntaxException

getApplicationName

public String getApplicationName()


Copyright © 2014 WSO2 Inc. All rights reserved.