You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2013/07/10 18:52:13 UTC

[38/45] fixing component version issues and adding currently refactored components to the parent pom

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/subscriber/TopologySubscriber.java
----------------------------------------------------------------------
diff --git a/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/subscriber/TopologySubscriber.java b/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/subscriber/TopologySubscriber.java
deleted file mode 100644
index 0c127a1..0000000
--- a/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/subscriber/TopologySubscriber.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF 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.lb.endpoint.subscriber;
-
-import java.util.Properties;
-
-import javax.jms.*;
-import javax.naming.InitialContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.lb.endpoint.util.ConfigHolder;
-import org.apache.stratos.lb.endpoint.util.TopologyConstants;
-
-public class TopologySubscriber {
-
-	private static final Log log = LogFactory.getLog(TopologySubscriber.class);
-	
-    public static void subscribe(String topicName) {
-        Properties initialContextProperties = new Properties();
-        TopicSubscriber topicSubscriber = null;
-        TopicSession topicSession = null;
-        TopicConnection topicConnection = null;
-        InitialContext initialContext = null;
-
-        initialContextProperties.put("java.naming.factory.initial",
-            "org.wso2.andes.jndi.PropertiesFileInitialContextFactory");
-
-        String mbServerUrl = null;
-        if (ConfigHolder.getInstance().getLbConfig() != null) {
-            mbServerUrl = ConfigHolder.getInstance().getLbConfig().getLoadBalancerConfig().getMbServerUrl();
-        }
-        String connectionString =
-            "amqp://admin:admin@clientID/carbon?brokerlist='tcp://" +
-                (mbServerUrl == null ? TopologyConstants.DEFAULT_MB_SERVER_URL : mbServerUrl) + "'&reconnect='true'";
-        initialContextProperties.put("connectionfactory.qpidConnectionfactory", connectionString);
-
-        try {
-            initialContext = new InitialContext(initialContextProperties);
-            TopicConnectionFactory topicConnectionFactory =
-                (TopicConnectionFactory) initialContext.lookup("qpidConnectionfactory");
-            topicConnection = topicConnectionFactory.createTopicConnection();
-            topicConnection.start();
-            topicSession =
-                topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-
-            Topic topic = topicSession.createTopic(topicName);
-            topicSubscriber =
-                topicSession.createSubscriber(topic);
-
-            topicSubscriber.setMessageListener(new TopologyListener());
-
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-
-            try {
-                if (topicSubscriber != null) {
-                    topicSubscriber.close();
-                }
-
-                if (topicSession != null) {
-                    topicSession.close();
-                }
-
-                if (topicConnection != null) {
-                    topicConnection.close();
-                }
-            } catch (JMSException e1) {
-                // ignore
-            }
-
-        } 
-        finally {
-            // start the health checker
-            Thread healthChecker = new Thread(new TopicHealthChecker(topicName, topicSubscriber));
-            healthChecker.start();
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/util/ConfigHolder.java
----------------------------------------------------------------------
diff --git a/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/util/ConfigHolder.java b/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/util/ConfigHolder.java
deleted file mode 100644
index 3817579..0000000
--- a/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/util/ConfigHolder.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF 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.lb.endpoint.util;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.config.SynapseConfiguration;
-import org.apache.stratos.lb.common.conf.LoadBalancerConfiguration;
-import org.apache.stratos.lb.common.service.LoadBalancerConfigurationService;
-import org.apache.stratos.lb.endpoint.TenantAwareLoadBalanceEndpointException;
-import org.apache.stratos.lb.endpoint.TenantLoadBalanceMembershipHandler;
-import org.wso2.carbon.mediation.dependency.mgt.services.DependencyManagementService;
-import org.wso2.carbon.mediation.initializer.services.SynapseEnvironmentService;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.user.core.service.RealmService;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/**
- *
- */
-public class ConfigHolder {
-
-    private static ConfigHolder instance;
-    private static final Log log = LogFactory.getLog(ConfigHolder.class);
-
-    private SynapseConfiguration synapseConfiguration;
-    private ConfigurationContext configCtxt;
-    private AxisConfiguration axisConfiguration;
-    private UserRegistry configRegistry;
-    private UserRegistry governanceRegistry;
-    private DependencyManagementService dependencyManager;
-    private TenantLoadBalanceMembershipHandler tenantMembershipHandler;
-    private LoadBalancerConfigurationService lbConfigService;
-    private BlockingQueue<String> sharedTopologyQueue = new LinkedBlockingQueue<String>();
-    private String previousMsg;
-    
-
-    private Map<Integer, SynapseEnvironmentService> synapseEnvironmentServices =
-            new HashMap<Integer, SynapseEnvironmentService>();
-
-    public RealmService getRealmService() {
-        return realmService;
-    }
-
-    public void setRealmService(RealmService realmService) {
-        this.realmService = realmService;
-    }
-
-    private RealmService realmService;
-
-    private ConfigHolder() {
-    }
-
-    public static ConfigHolder getInstance() {
-        if (instance == null) {
-            instance = new ConfigHolder();
-        }
-        return instance;
-    }
-
-    public SynapseConfiguration getSynapseConfiguration() throws TenantAwareLoadBalanceEndpointException{
-        assertNull("SynapseConfiguration", synapseConfiguration);
-        return synapseConfiguration;
-    }
-
-    public void setSynapseConfiguration(SynapseConfiguration synapseConfiguration) {
-        this.synapseConfiguration = synapseConfiguration;
-    }
-
-    public AxisConfiguration getAxisConfiguration() throws TenantAwareLoadBalanceEndpointException {
-        assertNull("AxisConfiguration", axisConfiguration);
-        return axisConfiguration;
-    }
-
-    public void setAxisConfiguration(AxisConfiguration axisConfiguration) {
-        this.axisConfiguration = axisConfiguration;
-    }
-
-    public UserRegistry getConfigRegistry() throws TenantAwareLoadBalanceEndpointException {
-        assertNull("Registry", configRegistry);
-        return configRegistry;
-    }
-
-    public void setConfigRegistry(UserRegistry configRegistry) {
-        this.configRegistry = configRegistry;
-    }
-
-    public DependencyManagementService getDependencyManager() {
-        return dependencyManager;
-    }
-
-    public void setDependencyManager(DependencyManagementService dependencyManager) {
-        this.dependencyManager = dependencyManager;
-    }
-
-    private void assertNull(String name, Object object) throws TenantAwareLoadBalanceEndpointException {
-        if (object == null) {
-            String message = name + " reference in the proxy admin config holder is null";
-            log.error(message);
-            throw new TenantAwareLoadBalanceEndpointException(message);
-        }
-    }
-
-    public UserRegistry getGovernanceRegistry() {
-        return governanceRegistry;
-    }
-
-    public void setGovernanceRegistry(UserRegistry governanceRegistry) {
-        this.governanceRegistry = governanceRegistry;
-    }
-
-    public SynapseEnvironmentService getSynapseEnvironmentService(int id) {
-        return synapseEnvironmentServices.get(id);
-    }
-
-    public void addSynapseEnvironmentService(int id,
-                                             SynapseEnvironmentService synapseEnvironmentService) {
-        synapseEnvironmentServices.put(id, synapseEnvironmentService);
-    }
-
-    public void removeSynapseEnvironmentService(int id) {
-        synapseEnvironmentServices.remove(id);
-    }
-
-    public Map<Integer, SynapseEnvironmentService> getSynapseEnvironmentServices() {
-        return synapseEnvironmentServices;
-    }
-    
-    public void setTenantLoadBalanceMembershipHandler(TenantLoadBalanceMembershipHandler handler) {
-        tenantMembershipHandler = handler;
-    }
-    
-    public TenantLoadBalanceMembershipHandler getTenantLoadBalanceMembershipHandler() {
-        return tenantMembershipHandler;
-    }
-
-    public ConfigurationContext getConfigCtxt() {
-        return configCtxt;
-    }
-
-    public void setConfigCtxt(ConfigurationContext configCtxt) {
-        this.configCtxt = configCtxt;
-    }
-    
-    public void setLbConfigService(LoadBalancerConfigurationService lbConfigSer) {
-        this.lbConfigService = lbConfigSer;
-    }
-
-    public LoadBalancerConfiguration getLbConfig() {
-        return (LoadBalancerConfiguration) lbConfigService.getLoadBalancerConfig();
-    }
-
-	public BlockingQueue<String> getSharedTopologyDiffQueue() {
-	    return sharedTopologyQueue;
-    }
-
-	public void setSharedTopologyDiffQueue(BlockingQueue<String> sharedTopologyDiffQueue) {
-	    this.sharedTopologyQueue = sharedTopologyDiffQueue;
-    }
-
-	public String getPreviousMsg() {
-	    return previousMsg;
-    }
-
-	public void setPreviousMsg(String previousMsg) {
-	    this.previousMsg = previousMsg;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/util/TopologyConstants.java
----------------------------------------------------------------------
diff --git a/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/util/TopologyConstants.java b/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/util/TopologyConstants.java
deleted file mode 100644
index 970e4b9..0000000
--- a/components/lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3/src/main/java/org/apache/stratos/lb/endpoint/util/TopologyConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF 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.lb.endpoint.util;
-
-public class TopologyConstants {
-    
-    public static final String TOPIC_NAME = "cloud-controller-topology";
-    public static final String MB_SERVER_URL = "mb.server.ip";
-    public static final String DEFAULT_MB_SERVER_URL = "localhost:5672";
-    
-    public static final String TOPOLOGY_SYNC_CRON = "1 * * * * ? *";
-	public static final String TOPOLOGY_SYNC_TASK_NAME = "TopologySubscriberTaskOfADC";
-	public static final String TOPOLOGY_SYNC_TASK_TYPE = "TOPOLOGY_SUBSCRIBER_TASK";
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/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
deleted file mode 100644
index 1723267..0000000
--- a/components/org.apache.stratos.activation/2.1.2/pom.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<!--
-# 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>3.0.0-SNAPSHOT</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/ac065d73/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
deleted file mode 100644
index bcb1901..0000000
--- a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/internal/ActivationServiceComponent.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- *  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/ac065d73/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
deleted file mode 100644
index 732d8de..0000000
--- a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationHandler.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- *  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/ac065d73/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
deleted file mode 100644
index e76d0ea..0000000
--- a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/module/ActivationModule.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *  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/ac065d73/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
deleted file mode 100644
index e993703..0000000
--- a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/service/ActivationService.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *  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/ac065d73/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
deleted file mode 100644
index 91a0ad9..0000000
--- a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/ActivationManager.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *  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/ac065d73/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
deleted file mode 100644
index 98bb716..0000000
--- a/components/org.apache.stratos.activation/2.1.2/src/main/java/org/apache/stratos/activation/activation/utils/Util.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- *  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/ac065d73/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
deleted file mode 100644
index 220e0e5..0000000
--- a/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/module.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
- ~ 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/ac065d73/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
deleted file mode 100644
index 01c4d91..0000000
--- a/components/org.apache.stratos.activation/2.1.2/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?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/ac065d73/components/org.apache.stratos.activation/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/pom.xml b/components/org.apache.stratos.activation/pom.xml
new file mode 100644
index 0000000..81e69ac
--- /dev/null
+++ b/components/org.apache.stratos.activation/pom.xml
@@ -0,0 +1,94 @@
+<!--
+# 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>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.stratos.activation</artifactId>
+    <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>${wso2carbon.version}</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>${apache.stratos.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ac065d73/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/internal/ActivationServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/internal/ActivationServiceComponent.java b/components/org.apache.stratos.activation/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/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/ac065d73/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/module/ActivationHandler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/module/ActivationHandler.java b/components/org.apache.stratos.activation/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/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/ac065d73/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/module/ActivationModule.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/module/ActivationModule.java b/components/org.apache.stratos.activation/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/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/ac065d73/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/service/ActivationService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/service/ActivationService.java b/components/org.apache.stratos.activation/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/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/ac065d73/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/utils/ActivationManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.activation/src/main/java/org/apache/stratos/activation/activation/utils/ActivationManager.java b/components/org.apache.stratos.activation/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/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();
+        }
+    }
+
+}