Class CarbonContextCreatorValve

  • All Implemented Interfaces:
    MBeanRegistration, org.apache.catalina.Contained, org.apache.catalina.JmxEnabled, org.apache.catalina.Lifecycle, org.apache.catalina.Valve

    public class CarbonContextCreatorValve
    extends org.apache.catalina.valves.ValveBase
    This valve handles creation of the CarbonContext when a request comes in
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle

        org.apache.catalina.Lifecycle.SingleUse
    • Field Summary

      • Fields inherited from class org.apache.catalina.valves.ValveBase

        asyncSupported, container, containerLog, next, sm
      • Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase

        mserver
      • Fields inherited from interface org.apache.catalina.Lifecycle

        AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected String getAppNameForURLMapping​(org.apache.catalina.connector.Request request)
      Derive the app name from the URL mapping.
      protected String getAppNameFromRequest​(org.apache.catalina.connector.Request request)
      Derive the app name from the request.
      void initCarbonContext​(org.apache.catalina.connector.Request request)  
      void invoke​(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response)  
      protected void setMDCValues​(int tenantId, String tenantDomain, String appName)
      Set the tenantId, tenantDomain and appName to the MDC.
      protected void setValuesToCarbonContext​(org.wso2.carbon.context.PrivilegedCarbonContext carbonContext, String tenantDomain, String appName)
      Method to set values to the CarbonContext instance.
      • Methods inherited from class org.apache.catalina.valves.ValveBase

        backgroundProcess, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, startInternal, stopInternal, toString
      • Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase

        destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
      • Methods inherited from class org.apache.catalina.util.LifecycleBase

        addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
    • Constructor Detail

      • CarbonContextCreatorValve

        public CarbonContextCreatorValve()
    • Method Detail

      • invoke

        public void invoke​(org.apache.catalina.connector.Request request,
                           org.apache.catalina.connector.Response response)
                    throws IOException,
                           javax.servlet.ServletException
        Throws:
        IOException
        javax.servlet.ServletException
      • initCarbonContext

        public void initCarbonContext​(org.apache.catalina.connector.Request request)
                               throws Exception
        Throws:
        Exception
      • getAppNameFromRequest

        protected String getAppNameFromRequest​(org.apache.catalina.connector.Request request)
        Derive the app name from the request.
        Parameters:
        request - The request.
        Returns:
        app name.
      • getAppNameForURLMapping

        protected String getAppNameForURLMapping​(org.apache.catalina.connector.Request request)
        Derive the app name from the URL mapping.
        Parameters:
        request - The request.
        Returns:
        app name.
      • setValuesToCarbonContext

        protected void setValuesToCarbonContext​(org.wso2.carbon.context.PrivilegedCarbonContext carbonContext,
                                                String tenantDomain,
                                                String appName)
                                         throws Exception
        Method to set values to the CarbonContext instance.
        Parameters:
        carbonContext - The carbon context.
        tenantDomain - The domain of the tenant.
        appName - The name of the application.
        Throws:
        Exception - if an error occurs.
      • setMDCValues

        protected void setMDCValues​(int tenantId,
                                    String tenantDomain,
                                    String appName)
        Set the tenantId, tenantDomain and appName to the MDC.
        Parameters:
        tenantId - The ID of the tenant.
        tenantDomain - The domain of the tenant.
        appName - The name of the application.