Examples of CarbonContextHolder


Examples of org.wso2.carbon.utils.multitenancy.CarbonContextHolder

    }

    public static String getExtensionLibDirectoryPath() {
        CarbonUtils.checkSecurity(Arrays.asList(
                RegistryConfigurationProcessor.class.getCanonicalName()));
        CarbonContextHolder carbonContextHolder =
                CarbonContextHolder.getCurrentCarbonContextHolder();
        return (carbonContextHolder.getTenantId() > 0 ?
                (CarbonUtils.getCarbonTenantsDirPath() + File.separator +
                        carbonContextHolder.getTenantId()) :
                (CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator +
                        "deployment" + File.separator + "server")) +
                File.separator + "registryextensions";
    }
View Full Code Here

Examples of org.wso2.carbon.utils.multitenancy.CarbonContextHolder

            method.invoke(clazz, (Object[]) null);

            // Invalidate all existing Http Sessions
            HttpSessionManager.invalidateSessions();

            CarbonContextHolder currentCarbonContextHolder =
                    CarbonContextHolder.getCurrentCarbonContextHolder();
            try {
                currentCarbonContextHolder.startTenantFlow();
                currentCarbonContextHolder.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
                currentCarbonContextHolder.unloadTenant();
            } finally {
                currentCarbonContextHolder.endTenantFlow();
            }

            // ACL keys its loggers off of the ContextClassLoader which prevents GC without calling release.
            // This section explicitly calls release if ACL is used.
            try {
View Full Code Here

Examples of org.wso2.carbon.utils.multitenancy.CarbonContextHolder


public class TenantDomainHandler extends AbstractHandler {

    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
        CarbonContextHolder carbonContext = CarbonContextHolder.getThreadLocalCarbonContextHolder();
        String tenantDomain = null;
        EndpointReference epr = msgContext.getTo();
        if (epr != null) {
            String toAddress = epr.getAddress();
            if (toAddress != null) {
                int tenantDelimiterIndex = toAddress.indexOf("/a/");
                if (tenantDelimiterIndex != -1) {
                    String temp = toAddress.substring(tenantDelimiterIndex + 3);
                    tenantDomain = temp.substring(0, temp.indexOf("/"));
                    if (tenantDomain != null) {
                        carbonContext.setTenantDomain(tenantDomain);
                    }
                    //remove the domain details so that it can be dispatched
                    String newAddress = toAddress.replace("/a/" + tenantDomain, "");
                    EndpointReference newEpr = new EndpointReference(newAddress);
                    msgContext.setTo(newEpr);
                    msgContext.getOptions().setTo(newEpr);
                }
            }
        }

        if (tenantDomain == null) {
            // try to dispatch from the soap header.
            SOAPHeader soapHeader = msgContext.getEnvelope().getHeader();
            if (soapHeader != null) {
                OMElement tenantDomainElement =
                        soapHeader.getFirstChildWithName(
                                new QName(MultitenantConstants.TENANT_DOMAIN_HEADER_NAMESPACE,
                                        MultitenantConstants.TENANT_DOMAIN_HEADER_NAME));
                if (tenantDomainElement != null) {
                    tenantDomain = tenantDomainElement.getText();
                }
            }

        }

        if (tenantDomain == null) {
            Map<String, String> transportHeaders =
                    (Map<String, String>) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
            if (transportHeaders != null) {
                tenantDomain = transportHeaders.get(MultitenantConstants.TENANT_DOMAIN_HEADER_NAME);
            }
        }
        if (tenantDomain != null) {
            carbonContext.setTenantDomain(tenantDomain);
        }
        return InvocationResponse.CONTINUE;
    }
View Full Code Here

Examples of org.wso2.carbon.utils.multitenancy.CarbonContextHolder

     * @throws CarbonException If a deployment error occurs
     */
    public void deploy(File webappFile,
                       List<WebContextParameter> webContextParams,
                       List<Object> applicationEventListeners) throws CarbonException {
        CarbonContextHolder currentCarbonContextHolder =
                CarbonContextHolder.getCurrentCarbonContextHolder();
        currentCarbonContextHolder.startTenantFlow();
        try {
            currentCarbonContextHolder.setTenantId(tenantId);
            currentCarbonContextHolder.setTenantDomain(tenantDomain);
            long lastModifiedTime = webappFile.lastModified();
            WebApplication deployedWebapp =
                    webappsHolder.getStartedWebapps().get(webappFile.getName());
            WebApplication undeployedWebapp =
                    webappsHolder.getStoppedWebapps().get(webappFile.getName());
            WebApplication faultyWebapp =
                    webappsHolder.getFaultyWebapps().get(webappFile.getName());
            if (deployedWebapp == null && faultyWebapp == null && undeployedWebapp == null) {
                handleHotDeployment(webappFile, webContextParams, applicationEventListeners);
            } else if (deployedWebapp != null &&
                    deployedWebapp.getLastModifiedTime() != lastModifiedTime) {
                handleHotUpdate(deployedWebapp, webContextParams, applicationEventListeners);
            } else if (faultyWebapp != null &&
                    faultyWebapp.getLastModifiedTime() != lastModifiedTime) {
                handleHotDeployment(webappFile, webContextParams, applicationEventListeners);
            }
        } finally {
            currentCarbonContextHolder.endTenantFlow();
        }
    }
View Full Code Here

Examples of org.wso2.carbon.utils.multitenancy.CarbonContextHolder

     *
     * @param webappFile The webapp file to be undeployed
     * @throws CarbonException If an error occurs while undeploying webapp
     */
    public void undeploy(File webappFile) throws CarbonException {
        CarbonContextHolder currentCarbonContextHolder =
                CarbonContextHolder.getCurrentCarbonContextHolder();
        currentCarbonContextHolder.startTenantFlow();
        try {
            currentCarbonContextHolder.setTenantId(tenantId);
            currentCarbonContextHolder.setTenantDomain(tenantDomain);
            Map<String, WebApplication> deployedWebapps = webappsHolder.getStartedWebapps();
            String fileName = webappFile.getName();
            if (deployedWebapps.containsKey(fileName)) {
                undeploy(deployedWebapps.get(fileName));
            }

            clearFaultyWebapp(fileName);
        } finally {
            currentCarbonContextHolder.endTenantFlow();
        }
    }
View Full Code Here

Examples of org.wso2.carbon.utils.multitenancy.CarbonContextHolder

     *
     * @param webappFile The webapp file to be undeployed
     * @throws CarbonException If an error occurs while lazy unloading
     */
    public void lazyUnload(File webappFile) throws CarbonException {
        CarbonContextHolder currentCarbonContextHolder =
                CarbonContextHolder.getCurrentCarbonContextHolder();
        currentCarbonContextHolder.startTenantFlow();
        try {
            currentCarbonContextHolder.setTenantId(tenantId);
            currentCarbonContextHolder.setTenantDomain(tenantDomain);
            Map<String, WebApplication> deployedWebapps = webappsHolder.getStartedWebapps();
            String fileName = webappFile.getName();
            if (deployedWebapps.containsKey(fileName)) {
                deployedWebapps.get(fileName).lazyUnload();
            }

            clearFaultyWebapp(fileName);
        } finally {
            currentCarbonContextHolder.endTenantFlow();
        }
    }
View Full Code Here

Examples of org.wso2.carbon.utils.multitenancy.CarbonContextHolder

    public void initCarbonContext(Request request) throws Exception {
        if (!isWebappManagementEnabled) {
            return;
        }
        String tenantDomain = getTenantDomain(request);
        CarbonContextHolder carbonContextHolder =
                CarbonContextHolder.getThreadLocalCarbonContextHolder();
        carbonContextHolder.setTenantDomain(tenantDomain);
        UserRealmService userRealmService = OSGiEnvironmentDataHolder.getUserRealmService();
        if (userRealmService != null) {
            if(tenantManager == null) {
                tenantManager = userRealmService.getTenantManager();
            }
            int tenantId = tenantManager.getTenantId(tenantDomain);
            carbonContextHolder.setTenantId(tenantId);
            carbonContextHolder.setProperty(CarbonContextHolder.USER_REALM,
                                            userRealmService.getTenantUserRealm(tenantId));
            RegistryService registryService = OSGiEnvironmentDataHolder.getRegistryService();
            carbonContextHolder.setProperty(CarbonContextHolder.CONFIG_SYSTEM_REGISTRY_INSTANCE,
                                            new GhostRegistry(registryService, tenantId,
                                                              RegistryType.SYSTEM_CONFIGURATION));
            carbonContextHolder.setProperty(CarbonContextHolder.GOVERNANCE_SYSTEM_REGISTRY_INSTANCE,
                                            new GhostRegistry(registryService, tenantId,
                                                              RegistryType.SYSTEM_GOVERNANCE));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.