Package org.wso2.carbon.context

Examples of org.wso2.carbon.context.PrivilegedCarbonContext


        TenantPersistor tenantPersistor = new TenantPersistor();
        return tenantPersistor;
    }

    public static ConfigurationContextService getConfigurationContext() {
        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext.
                getOSGiService(ConfigurationContextService.class);
        return configurationContextService;
    }
View Full Code Here


        int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            // TODO: This is only a workaround. Proper fix is to write to tenant registry
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

                persistSubscription(cartridgeSubscription);

            } finally {
                PrivilegedCarbonContext.endTenantFlow();
View Full Code Here

        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            // TODO: This is only a workaround. Proper fix is to write to tenant registry
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

                removeSubscription(tenantId, type, alias);

            } finally {
                PrivilegedCarbonContext.endTenantFlow();
View Full Code Here

        int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            // TODO: This is only a workaround. Proper fix is to write to tenant registry
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

                persistDeployedService(service);

            } finally {
                PrivilegedCarbonContext.endTenantFlow();
View Full Code Here

        int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            // TODO: This is only a workaround. Proper fix is to write to tenant registry
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

                return traverseAndGetDeloyedServices(STRATOS_MANAGER_REOSURCE + SERVICES);

            } finally {
                PrivilegedCarbonContext.endTenantFlow();
View Full Code Here

        int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            // TODO: This is only a workaround. Proper fix is to write to tenant registry
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

               return getDeployedService(cartridgeType);

            } finally {
                PrivilegedCarbonContext.endTenantFlow();
View Full Code Here

        int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            // TODO: This is only a workaround. Proper fix is to write to tenant registry
            try {
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
                carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);

                removeDeployedService(cartridgeType);

            } finally {
                PrivilegedCarbonContext.endTenantFlow();
View Full Code Here

        return cacheManager;
    }

    private static void startSuperTenantFlow() {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
        ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    }
View Full Code Here

        final Function callback = function;
        final ContextFactory factory = cx.getFactory();
        timeout = ((Number) args[1]).longValue();
        String uuid = UUID.randomUUID().toString();

        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        final int tenantId = carbonContext.getTenantId();
        final String tenantDomain = carbonContext.getTenantDomain();
        final String applicationName = carbonContext.getApplicationName();
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

        ScheduledFuture future = timerExecutor.schedule(new Callable<Void>() {
            public Void call() throws Exception {
                //set the context classloader
                Thread currentThread = Thread.currentThread();
                ClassLoader originalClassLoader = currentThread.getContextClassLoader();
                Thread.currentThread().setContextClassLoader(contextClassLoader);
                // child inherits context properties form the parent thread.
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantId(tenantId);
                carbonContext.setTenantDomain(tenantDomain);
                carbonContext.setApplicationName(applicationName);

                try {
                    Context ctx = RhinoEngine.enterContext(factory);
                    RhinoEngine.putContextProperty(EngineConstants.JAGGERY_CONTEXT, context);
                    callback.call(ctx, thisObj, thisObj, params);
View Full Code Here

        final Function callback = function;
        final ContextFactory factory = cx.getFactory();
        interval = ((Number) args[1]).longValue();
        String uuid = UUID.randomUUID().toString();

        PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        final int tenantId = carbonContext.getTenantId();
        final String tenantDomain = carbonContext.getTenantDomain();
        final String applicationName = carbonContext.getApplicationName();
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

        ScheduledFuture future = timerExecutor.scheduleAtFixedRate(new Runnable() {

            private boolean firstTime = true;

            @Override
            public void run() {
                //set the context classloader
                Thread currentThread = Thread.currentThread();
                ClassLoader originalClassLoader = currentThread.getContextClassLoader();
                Thread.currentThread().setContextClassLoader(contextClassLoader);
                // child inherits context properties form the parent thread.
                PrivilegedCarbonContext.startTenantFlow();
                PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
                carbonContext.setTenantId(tenantId);
                carbonContext.setTenantDomain(tenantDomain);
                carbonContext.setApplicationName(applicationName);

                try {
                    Context cx = RhinoEngine.enterContext(factory);
                    RhinoEngine.putContextProperty(EngineConstants.JAGGERY_CONTEXT, context);
                    callback.call(cx, thisObj, thisObj, params);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.context.PrivilegedCarbonContext

Copyright © 2018 www.massapicom. 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.