You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2013/07/08 11:55:12 UTC

git commit: Stratos Activation module refactoring

Updated Branches:
  refs/heads/master 544ff39ae -> f0e11c603


Stratos Activation module refactoring

Signed-off-by: Lakmal Warusawithana <la...@wso2.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/f0e11c60
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/f0e11c60
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/f0e11c60

Branch: refs/heads/master
Commit: f0e11c6033778b495e1ac378999a4399084e3db3
Parents: 544ff39
Author: Udara Liyanage <ud...@wso2.com>
Authored: Mon Jul 8 13:37:40 2013 +0530
Committer: Lakmal Warusawithana <la...@wso2.com>
Committed: Mon Jul 8 15:24:54 2013 +0530

----------------------------------------------------------------------
 .../org.apache.stratos.activation/2.1.2/pom.xml |  96 +++++++++++
 .../internal/ActivationServiceComponent.java    | 152 +++++++++++++++++
 .../activation/module/ActivationHandler.java    | 161 +++++++++++++++++++
 .../activation/module/ActivationModule.java     |  65 ++++++++
 .../activation/service/ActivationService.java   |  85 ++++++++++
 .../activation/utils/ActivationManager.java     |  96 +++++++++++
 .../activation/activation/utils/Util.java       | 138 ++++++++++++++++
 .../src/main/resources/META-INF/module.xml      |  33 ++++
 .../src/main/resources/META-INF/services.xml    |  30 ++++
 .../2.1.3/pom.xml                               |   9 +-
 10 files changed, 857 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/pom.xml b/components/org.apache.stratos.activation/2.1.2/pom.xml
new file mode 100644
index 0000000..16f9f3c
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/pom.xml
@@ -0,0 +1,96 @@
+<!--
+# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+       <groupId>org.apache.stratos</groupId>
+       <artifactId>stratos-components-parent</artifactId>
+       <version>2.0.0</version>
+       <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.stratos.activation</artifactId>
+    <version>2.1.2</version>
+    <packaging>bundle</packaging>
+    <name>Apache Stratos - Activation</name>
+
+    <build>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Axis2Module>${project.artifactId}-${project.version}</Axis2Module>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Export-Package>
+                            org.apache.stratos.activation.activation.*,
+                        </Export-Package>
+                        <Import-Package>
+                            org.apache.stratos.common.*,
+                            org.wso2.carbon.registry.core.*;version=1.0.1,
+                            org.wso2.carbon.registry.resource.*,
+                            !javax.xml.namespace,
+                            javax.xml.namespace; version=0.0.0,
+                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
+                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
+                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
+                            *;resolution:=optional
+                        </Import-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.utils</artifactId>
+	    <version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.registry.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.common</artifactId>
+	    <version>2.1.2</version>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/internal/ActivationServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/internal/ActivationServiceComponent.java b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/internal/ActivationServiceComponent.java
new file mode 100644
index 0000000..bcb1901
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/internal/ActivationServiceComponent.java
@@ -0,0 +1,152 @@
+/*
+ *  Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ *  WSO2 Inc. licenses this file to you under the Apache License,
+ *  Version 2.0 (the "License"); you may not use this file except
+ *  in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.stratos.activation.activation.internal;
+
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.ConfigurationContextService;
+import org.apache.stratos.activation.activation.service.ActivationService;
+import org.apache.stratos.activation.activation.utils.ActivationManager;
+import org.apache.stratos.activation.activation.utils.Util;
+
+/**
+ * The Declarative Service Component for the Service Activation Module for Tenants.
+ *
+ * @scr.component name="org.wso2.carbon.metering" immediate="true"
+ * @scr.reference name="registry.service"
+ * interface="org.wso2.carbon.registry.core.service.RegistryService"
+ * cardinality="1..1" policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
+ * @scr.reference name="user.realmservice.default"
+ * interface="org.wso2.carbon.user.core.service.RealmService"
+ * cardinality="1..1" policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
+ * @scr.reference name="config.context.service"
+ * interface="org.wso2.carbon.utils.ConfigurationContextService"
+ * cardinality="0..1" policy="dynamic"  bind="setConfigurationContextService"
+ * unbind="unsetConfigurationContextService"
+ */
+@SuppressWarnings({"JavaDoc", "unused"})
+public class ActivationServiceComponent {
+
+    private static final Log log = LogFactory.getLog(ActivationServiceComponent.class);
+
+    private static ServiceRegistration registration = null;
+
+    /**
+     * Activates the Registry Kernel bundle.
+     *
+     * @param context the OSGi component context.
+     */
+    protected void activate(ComponentContext context) {
+        try {
+            ActivationManager.startCacheCleaner();
+            if (registration == null) {
+                registration = context.getBundleContext().registerService(
+                        ActivationService.class.getName(), new ActivationService(), null);
+            }
+            log.debug("******* Stratos Activation bundle is activated ******* ");
+        } catch (Exception e) {
+            log.error("******* Stratos Activation bundle failed activating ****", e);
+        }
+    }
+
+    /**
+     * Deactivates the Registry Kernel bundle.
+     *
+     * @param context the OSGi component context.
+     */
+    protected void deactivate(ComponentContext context) {
+        registration.unregister();
+        registration = null;
+        ActivationManager.stopCacheCleaner();
+        log.debug("******* Stratos Activation bundle is deactivated ******* ");
+    }
+
+    /**
+     * Method to set the registry service used. This will be used when accessing the registry. This
+     * method is called when the OSGi Registry Service is available.
+     *
+     * @param registryService the registry service.
+     */
+    protected void setRegistryService(RegistryService registryService) {
+        Util.setRegistryService(registryService);
+    }
+
+    /**
+     * This method is called when the current registry service becomes un-available.
+     *
+     * @param registryService the current registry service instance, to be used for any
+     *                        cleaning-up.
+     */
+    protected void unsetRegistryService(RegistryService registryService) {
+        Util.setRegistryService(null);
+    }
+
+    /**
+     * Method to set the realm service used. This will be used when accessing the user realm. This
+     * method is called when the OSGi Realm Service is available.
+     *
+     * @param realmService the realm service.
+     */
+    protected void setRealmService(RealmService realmService) {
+        Util.setRealmService(realmService);
+    }
+
+    /**
+     * This method is called when the current realm service becomes un-available.
+     *
+     * @param realmService the current realm service instance, to be used for any cleaning-up.
+     */
+    protected void unsetRealmService(RealmService realmService) {
+        Util.setRealmService(null);
+    }
+
+    /**
+     * Method to set the configuration context service used. This method is called when the OSGi
+     * ConfigurationContext Service is available.
+     *
+     * @param contextService the configuration context service.
+     */
+    protected void setConfigurationContextService(ConfigurationContextService contextService) {
+        try {
+            if (contextService.getServerConfigContext() != null &&
+                    contextService.getServerConfigContext().getAxisConfiguration() != null) {
+                contextService.getServerConfigContext().getAxisConfiguration().engageModule(
+                        "activation");
+            } else {
+                log.error("Failed to engage Activation Module.");
+            }
+        } catch (AxisFault e) {
+            log.error("Failed to engage Activation Module", e);
+        }
+    }
+
+    /**
+     * This method is called when the current configuration context service becomes un-available.
+     *
+     * @param contextService the current configuration context service instance, to be used for any
+     *                       cleaning-up.
+     */
+    protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationHandler.java b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationHandler.java
new file mode 100644
index 0000000..732d8de
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationHandler.java
@@ -0,0 +1,161 @@
+/*
+ *  Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ *  WSO2 Inc. licenses this file to you under the Apache License,
+ *  Version 2.0 (the "License"); you may not use this file except
+ *  in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.stratos.activation.activation.module;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.activation.activation.utils.ActivationManager;
+import org.apache.stratos.activation.activation.utils.Util;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils;
+import org.apache.stratos.common.util.CloudServicesUtil;
+import org.wso2.carbon.utils.ServerConstants;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
+
+public class ActivationHandler extends AbstractHandler implements Handler {
+
+    private static final Log log = LogFactory.getLog(ActivationHandler.class);
+
+    private String name = "ActivationHandler";
+
+    /**
+     * {@inheritDoc}
+     */
+    public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
+        String serviceName = Util.getServiceName();
+        //TODO - tenant id and domain should retrieve from thread local carbon context
+        //If service is api manager then we will pass activation handler check
+        if(serviceName.equalsIgnoreCase("WSO2 API Manager")) {
+            return InvocationResponse.CONTINUE;
+        }
+        if(log.isDebugEnabled()){
+            log.debug("Starting Activation Handler invocation. Incoming Message: " +
+                    messageContext.getEnvelope().toString());
+        }
+
+        AxisService service = messageContext.getAxisService();
+        int tenantId = getTenantId(messageContext);
+        if (service != null && "ActivationService".equals(service.getName())) {
+            log.debug("Granted access to the Activation Service");
+            if (tenantId > 0) {
+                TenantAxisUtils.getTenantAxisConfiguration(getTenantDomain(messageContext),
+                        messageContext.getConfigurationContext());
+                log.debug("Loaded Tenant Configuration");
+            }
+            return InvocationResponse.CONTINUE;
+        }
+        if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
+            log.debug("Granted access for super tenant");
+            return InvocationResponse.CONTINUE;
+        }
+        if (ActivationManager.activationRecorded(tenantId)) {
+            if (ActivationManager.getActivation(tenantId)) {
+                TenantAxisUtils.getTenantAxisConfiguration(getTenantDomain(messageContext),
+                        messageContext.getConfigurationContext());
+                log.debug("Loaded Tenant Configuration");
+                return InvocationResponse.CONTINUE;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn("Failed attempt to access " + serviceName + " by tenant " + tenantId);
+                }
+                return InvocationResponse.ABORT;
+            }
+        }
+
+        try {
+            if (CloudServicesUtil.isCloudServiceActive(serviceName, tenantId)) {
+                log.debug("Successful attempt to access " + serviceName + " by tenant " + tenantId);
+                ActivationManager.setActivation(tenantId, true);
+                TenantAxisUtils.getTenantAxisConfiguration(getTenantDomain(messageContext),
+                        messageContext.getConfigurationContext());
+                log.debug("Loaded Tenant Configuration");
+                return InvocationResponse.CONTINUE;
+            }
+        } catch (Exception e) {
+            throw new AxisFault("Failed to determine Activation status.", e);
+        }
+        log.warn("Failed attempt to access " + serviceName + " by tenant " + tenantId);
+        ActivationManager.setActivation(tenantId, false);
+        return InvocationResponse.ABORT;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Method to set the name of the activation handler.
+     *
+     * @param name the name.
+     */
+    @SuppressWarnings("unused")
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    private String getTenantDomain(MessageContext messageContext) {
+        //Ideally this should take from thread local carbon context change this temporary
+        return PrivilegedCarbonContext.getCurrentContext(messageContext).getTenantDomain();
+    }
+
+    private int getTenantId(MessageContext messageContext) {
+        //Ideally this should take from thread local carbon context change this temporary
+        PrivilegedCarbonContext carbonContext =
+                PrivilegedCarbonContext.getCurrentContext(messageContext);
+        int tenantId = carbonContext.getTenantId();
+        if (tenantId > -1 || tenantId == MultitenantConstants.SUPER_TENANT_ID) {
+            return tenantId;
+        }
+        String domain = carbonContext.getTenantDomain();
+        if (domain == null) {
+            SOAPBody soapBody = messageContext.getEnvelope().getBody();
+            if (soapBody != null && soapBody.getFirstElement() != null) {
+                OMElement usernameElem = soapBody.getFirstElement().getFirstChildWithName(
+                        new QName(ServerConstants.AUTHENTICATION_SERVICE_NS,
+                                ServerConstants.AUTHENTICATION_SERVICE_USERNAME));
+                if (usernameElem != null) {
+                    String userName = usernameElem.getText();
+                    domain = MultitenantUtils.getTenantDomain(userName);
+                }
+            }
+        }
+        if (domain != null) {
+            try {
+                tenantId = Util.getRealmService().getTenantManager().getTenantId(domain);
+            } catch (org.wso2.carbon.user.api.UserStoreException e) {
+                log.error("An error occurred while obtaining the tenant id.", e);
+            }
+        }
+        return tenantId;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationModule.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationModule.java b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationModule.java
new file mode 100644
index 0000000..e76d0ea
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationModule.java
@@ -0,0 +1,65 @@
+/*
+ *  Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ *  WSO2 Inc. licenses this file to you under the Apache License,
+ *  Version 2.0 (the "License"); you may not use this file except
+ *  in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.stratos.activation.activation.module;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.modules.Module;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+/**
+ * Module used to engage the activation handler.
+ */
+public class ActivationModule implements Module {
+
+    /**
+     * {@inheritDoc}
+     */
+    public void init(ConfigurationContext configurationContext, AxisModule axisModule)
+            throws AxisFault {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void engageNotify(AxisDescription axisDescription) throws AxisFault {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean canSupportAssertion(Assertion assertion) {
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/service/ActivationService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/service/ActivationService.java b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/service/ActivationService.java
new file mode 100644
index 0000000..e993703
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/service/ActivationService.java
@@ -0,0 +1,85 @@
+/*
+ *  Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ *  WSO2 Inc. licenses this file to you under the Apache License,
+ *  Version 2.0 (the "License"); you may not use this file except
+ *  in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.stratos.activation.activation.service;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.activation.activation.utils.ActivationManager;
+import org.apache.stratos.activation.activation.utils.Util;
+import org.apache.stratos.common.config.CloudServiceConfigParser;
+import org.apache.stratos.common.config.CloudServicesDescConfig;
+import org.apache.stratos.common.util.CloudServicesUtil;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+/**
+ * Admin Service to handle activation of cloud services used by tenants.
+ */
+public class ActivationService {
+
+    private static final Log log = LogFactory.getLog(ActivationService.class);
+
+    /**
+     * Method to update an activation record.
+     *
+     * @param tenantId the tenant identifier.
+     *
+     * @throws Exception if the operation failed.
+     */
+    public static void updateActivation(int tenantId) throws Exception {
+        if (tenantId != 0) {
+            String serviceName = Util.getServiceName();
+            boolean isActive = CloudServicesUtil.isCloudServiceActive(serviceName, tenantId);
+            CloudServicesDescConfig cloudServicesDesc =
+                                                        CloudServiceConfigParser.loadCloudServicesConfiguration();
+            CloudServicesUtil.setCloudServiceActive(!isActive,
+                                                    serviceName,
+                                                    tenantId,
+                                                    cloudServicesDesc.getCloudServiceConfigs()
+                                                                     .get(serviceName));
+            ActivationManager.setActivation(tenantId, !isActive);
+        }
+    }
+
+    /**
+     * Method to determine whether a service is active for the given tenant.
+     *
+     * @param tenantId tenantId the tenant identifier.
+     *
+     * @return whether the service is active.
+     * @throws Exception if the operation failed.
+     */
+    public boolean isActive(int tenantId) throws Exception {
+        if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
+            return true;
+        }
+        if (ActivationManager.activationRecorded(tenantId)) {
+            return ActivationManager.getActivation(tenantId);
+        }
+        String serviceName = Util.getServiceName();
+        if (CloudServicesUtil.isCloudServiceActive(serviceName, tenantId)) {
+            log.debug("Successful attempt to access " + serviceName + " by tenant " + tenantId);
+            ActivationManager.setActivation(tenantId, true);
+            return true;
+        }
+        log.warn("Failed attempt to access " + serviceName + " by tenant " + tenantId);
+        ActivationManager.setActivation(tenantId, false);
+        return false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/ActivationManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/ActivationManager.java b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/ActivationManager.java
new file mode 100644
index 0000000..91a0ad9
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/ActivationManager.java
@@ -0,0 +1,96 @@
+/*
+ *  Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ *  WSO2 Inc. licenses this file to you under the Apache License,
+ *  Version 2.0 (the "License"); you may not use this file except
+ *  in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.stratos.activation.activation.utils;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Manages Activations of Services for Tenants.
+ */
+public class ActivationManager {
+
+    private static final ConcurrentHashMap<Integer, Boolean> activations =
+            new ConcurrentHashMap<Integer, Boolean>();
+    private static Timer timer = null;
+
+    /**
+     * Starts cleaning up cached activation records at periodic intervals.
+     */
+    public static void startCacheCleaner() {
+        TimerTask faultyServiceRectifier = new CacheCleaner();
+        timer = new Timer();
+        // Retry in 1 minute
+        long retryIn = 1000 * 60;
+        timer.schedule(faultyServiceRectifier, 0, retryIn);
+    }
+
+    /**
+     * Stops cleaning up cached activation records.
+     */
+    public static void stopCacheCleaner() {
+        timer.cancel();
+        timer = null;
+    }
+
+    /**
+     * Method to set an activation record.
+     *
+     * @param tenantId the tenant identifier.
+     * @param status   true if the service is active or false if not.
+     */
+    public static void setActivation(int tenantId, boolean status) {
+        ActivationManager.activations.put(tenantId, status);
+    }
+
+    /**
+     * Method to check whether an activation record exists for the given tenant.
+     *
+     * @param tenantId the tenant identifier.
+     *
+     * @return true if a record exists.
+     */
+    public static boolean activationRecorded(int tenantId) {
+        return ActivationManager.activations.get(tenantId) != null;
+    }
+
+    /**
+     * Method to retrieve an activation record.
+     *
+     * @param tenantId the tenant identifier.
+     *
+     * @return true if the service is active or false if not.
+     */
+    public static boolean getActivation(int tenantId) {
+        return ActivationManager.activations.get(tenantId) != null &&
+                ActivationManager.activations.get(tenantId);
+    }
+
+    private static class CacheCleaner extends TimerTask {
+
+        /**
+         * {@inheritDoc}
+         */
+        public void run() {
+            ActivationManager.activations.clear();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/Util.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/Util.java b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/Util.java
new file mode 100644
index 0000000..98bb716
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/Util.java
@@ -0,0 +1,138 @@
+/*
+ *  Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ *  WSO2 Inc. licenses this file to you under the Apache License,
+ *  Version 2.0 (the "License"); you may not use this file except
+ *  in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.stratos.activation.activation.utils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+import org.wso2.carbon.user.core.service.RealmService;
+
+/**
+ * Utilities for the Service Activation Module for Tenants.
+ */
+public class Util {
+
+    private static RegistryService registryService = null;
+    private static RealmService realmService = null;
+    private static String serviceName = null;
+    private static final Log log = LogFactory.getLog(Util.class);
+
+    private static boolean cloudServiceInfoPathSanityChecked = false;
+
+    /**
+     * Stores an instance of the Registry Service that can be used to access the registry.
+     *
+     * @param service the Registry Service instance.
+     */
+    public static synchronized void setRegistryService(RegistryService service) {
+        if (registryService == null) {
+            registryService = service;
+        }
+    }
+
+    /**
+     * Method to retrieve the Registry Service instance.
+     *
+     * @return the Registry Service instance if it has been stored or null if not.
+     */
+    @SuppressWarnings("unused")
+    public static RegistryService getRegistryService() {
+        return registryService;
+    }
+
+    /**
+     * Stores an instance of the Realm Service that can be used to access the user realm.
+     *
+     * @param service the Realm Service instance.
+     */
+    public static synchronized void setRealmService(RealmService service) {
+        if (realmService == null) {
+            realmService = service;
+        }
+    }
+
+    /**
+     * Method to retrieve the Realm Service instance.
+     *
+     * @return the Realm Service instance if it has been stored or null if not.
+     */
+    public static RealmService getRealmService() {
+        return realmService;
+    }
+
+    private static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException {
+        return registryService.getGovernanceSystemRegistry();
+    }
+
+//    /**
+//     * Method to determine whether the given cloud service is active.
+//     *
+//     * @param cloudServiceName the name of the cloud service.
+//     * @param tenantId         the tenant identifier.
+//     * @param systemRegistry   the super tenant's governance system registry
+//     *
+//     * @return true if the service is active or false if not.
+//     * @throws Exception if the operation failed.
+//     */
+//    public static boolean isCloudServiceActive(String cloudServiceName,
+//                                               int tenantId, UserRegistry systemRegistry)
+//            throws Exception {
+//        // The cloud manager is always active
+//        if (StratosConstants.CLOUD_MANAGER_SERVICE.equals(cloudServiceName)) {
+//            return true;
+//        }
+//
+//        if(!cloudServiceInfoPathSanityChecked) {
+//            if(!systemRegistry.resourceExists(StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH)) {
+//                throw new RuntimeException("Cloud services list resource " +
+//                                           StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH + " does not exist");
+//            }
+//            cloudServiceInfoPathSanityChecked = true;
+//        }
+//
+//        String cloudServiceInfoPath = StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH +
+//                RegistryConstants.PATH_SEPARATOR + tenantId +
+//                RegistryConstants.PATH_SEPARATOR + cloudServiceName;
+//        Resource cloudServiceInfoResource;
+//        if (systemRegistry.resourceExists(cloudServiceInfoPath)) {
+//            cloudServiceInfoResource = systemRegistry.get(cloudServiceInfoPath);
+//            String isActiveStr =
+//                cloudServiceInfoResource.getProperty(StratosConstants.CLOUD_SERVICE_IS_ACTIVE_PROP_KEY);
+//            return Boolean.toString(true).equals(isActiveStr);
+//        }
+//        return false;
+//    }
+//
+
+    /**
+     * Method to obtain the name of the cloud service in which this module is running.
+     *
+     * @return the name of the service as defined in the server configuration.
+     */
+    public static String getServiceName() {
+        if (serviceName == null) {
+            serviceName = ServerConfiguration.getInstance().getFirstProperty("Name");
+        }
+        return serviceName;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/module.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/module.xml b/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/module.xml
new file mode 100644
index 0000000..220e0e5
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/module.xml
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you under the Apache License,
+ ~ Version 2.0 (the "License"); you may not use this file except
+ ~ in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~    http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied.  See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<module name="activation" class="org.apache.stratos.activation.activation.module.ActivationModule">
+   <InFlow>
+        <handler name="InFlowActivationHandler"
+                 class="org.apache.stratos.activation.activation.module.ActivationHandler">
+        <order phase="Validation" phaseFirst="true"/>
+        </handler>
+   </InFlow>
+
+   <InFaultFlow>
+        <handler name="FaultInFlowActivationHandler"
+                 class="org.apache.stratos.activation.activation.module.ActivationHandler">
+        <order phase="Validation" phaseFirst="true"/>
+        </handler>
+   </InFaultFlow>
+  <parameter name="adminModule" locked="true">true</parameter>
+</module>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/services.xml
new file mode 100644
index 0000000..01c4d91
--- /dev/null
+++ b/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/services.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ !
+ ! Copyright (c) 2005-2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ !
+ ! WSO2 Inc. licenses this file to you under the Apache License,
+ ! Version 2.0 (the "License"); you may not use this file except
+ ! in compliance with the License.
+ ! You may obtain a copy of the License at
+ !
+ ! http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+<serviceGroup>
+    <service name="ActivationService" scope="transportsession">
+        <transports>
+            <transport>https</transport>
+        </transports>
+        <parameter name="ServiceClass" locked="false">
+            org.apache.stratos.activation.activation.service.ActivationService
+        </parameter>
+    </service>
+    <parameter name="hiddenService" locked="true">true</parameter>
+</serviceGroup>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f0e11c60/components/org.apache.stratos.cloud.controller/2.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/2.1.3/pom.xml b/components/org.apache.stratos.cloud.controller/2.1.3/pom.xml
index b461e7e..19a38a9 100644
--- a/components/org.apache.stratos.cloud.controller/2.1.3/pom.xml
+++ b/components/org.apache.stratos.cloud.controller/2.1.3/pom.xml
@@ -17,14 +17,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-<!--
-    <parent>
-       <groupId>org.wso2.carbon</groupId>
-       <artifactId>stratos-components</artifactId>
-       <version>2.1.0</version>
-       <relativePath>../../pom.xml</relativePath>
-    </parent>
--->
+
     <parent>
        <groupId>org.apache.stratos</groupId>
        <artifactId>stratos-components-parent</artifactId>