/**
   * First create a Deployment engine, use that to create an AxisConfiguration
   *
   * @return Axis Configuration
   * @throws AxisFault
   */
  public AxisConfiguration getAxisConfiguration() throws AxisFault {
    // ClassLoader origTccl = Thread.currentThread().getContextClassLoader();
    // Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    log.info(
        "Creating tenant AxisConfiguration for tenant: " + getTenantString(tenantDomain, tenantId));
    PrivilegedCarbonContext.startTenantFlow();
    try {
      PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getCurrentContext();
      carbonContext.setTenantId(tenantId);
      carbonContext.setTenantDomain(tenantDomain);
      if (log.isDebugEnabled()) {
        log.debug("Axis2 repo: " + repoLocation);
      }
      populateAxisConfig();
      addDeployer(new ModuleDeployer(), repoLocation + File.separator + "axis2modules", "mar");
      axisConfig.setConfigurator(this);

      // TODO: May need to set certain parameters into the AxisConfig

      // Hot deployment & update should be turned on for tenants
      axisConfig.addParameter(new Parameter(DeploymentConstants.TAG_HOT_DEPLOYMENT, "true"));
      axisConfig.addParameter(new Parameter(DeploymentConstants.TAG_HOT_UPDATE, "true"));

      globallyEngagedModules = axisConfig.getEngagedModules();
      loadRepository(repoLocation);

      // set the service class loader in the axisConfig, this is needed due to ghost deployer
      // as the service deployer is no longer treated as a special case, we have to do this
      File axis2ServicesDir = new File(repoLocation, CarbonUtils.getAxis2ServicesDir(axisConfig));
      if (axis2ServicesDir.exists()) {
        axisConfig.setServiceClassLoader(
            Utils.getClassLoader(
                axisConfig.getSystemClassLoader(),
                axis2ServicesDir,
                axisConfig.isChildFirstClassLoading()));
      }

      for (Object globallyEngagedModule : globallyEngagedModules) {
        AxisModule module = (AxisModule) globallyEngagedModule;
        if (log.isDebugEnabled()) {
          log.debug("Globally engaging module: " + module.getName());
        }
      }

      // Remove all the transports made available in the tenant's axis2.xml
      axisConfig.getTransportsOut().clear();

      // Remove all in-transports made available in the tenant's axis2.xml
      axisConfig.getTransportsIn().clear();

      // Add the transports that are made available in the main axis2.xml file
      TenantAxisUtils.setTenantTransports(mainAxisConfig, tenantDomain, axisConfig);

    } finally {
      PrivilegedCarbonContext.endTenantFlow();
      // Thread.currentThread().setContextClassLoader(origTccl);
    }
    return axisConfig;
  }
 /**
  * Set the transports for the tenants
  *
  * @param mainConfigCtx The main config context
  * @throws AxisFault If an error occurs while initializing tenant transports
  */
 @SuppressWarnings("unchecked")
 public static void initializeTenantTransports(ConfigurationContext mainConfigCtx)
     throws AxisFault {
   AxisConfiguration mainAxisConfig = mainConfigCtx.getAxisConfiguration();
   Map<String, ConfigurationContext> tenantConfigContexts =
       getTenantConfigurationContexts(mainConfigCtx);
   if (tenantConfigContexts != null) {
     for (Map.Entry<String, ConfigurationContext> entry : tenantConfigContexts.entrySet()) {
       String tenantDomain = entry.getKey();
       ConfigurationContext tenantConfigCtx = entry.getValue();
       AxisConfiguration tenantAxisConfig = tenantConfigCtx.getAxisConfiguration();
       // Add the transports that are made available in the main axis2.xml file
       setTenantTransports(mainAxisConfig, tenantDomain, tenantAxisConfig);
     }
   }
 }