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/06/28 21:26:56 UTC

[12/51] [partial] initial commit to apache incubator. Here just commit WSO2 Stratos code base as it is. After that will start re-factor code to apache

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/subscribed_cartridges_ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/subscribed_cartridges_ajaxprocessor.jsp b/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/subscribed_cartridges_ajaxprocessor.jsp
new file mode 100644
index 0000000..17e394b
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/subscribed_cartridges_ajaxprocessor.jsp
@@ -0,0 +1,279 @@
+<!--
+ ~ 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.
+ -->
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
+<%@ page import="org.apache.axis2.context.ConfigurationContext"%>
+<%@ page import="org.wso2.carbon.CarbonConstants"%>
+<%@ page import="org.wso2.carbon.ui.CarbonUIMessage"%>
+<%@ page import="org.wso2.carbon.ui.CarbonUIUtil"%>
+<%@ page import="org.wso2.carbon.utils.ServerConstants"%>
+<%@ page import="org.wso2.carbon.cartridge.mgt.ui.CartridgeAdminClient"%>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon"%>
+<%@ page import="org.wso2.carbon.adc.mgt.dto.xsd.Cartridge"%>
+<%@ page import="org.wso2.carbon.adc.mgt.dto.xsd.CartridgeWrapper"%>
+<%@ page import="java.text.SimpleDateFormat"%>
+<%@ page import="java.util.ResourceBundle"%>
+<%@ page import="java.util.ArrayList"%>
+
+<jsp:include page="../dialog/display_messages.jsp" />
+
+<%
+	response.setHeader("Cache-Control", "no-cache");
+
+    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+    ConfigurationContext configContext =
+            (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+
+    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+    CartridgeAdminClient client;
+    Cartridge[] cartridges = null;
+
+    int numberOfPages = 0;
+    String pageNumber = request.getParameter("pageNumber");
+    if (pageNumber == null) {
+        pageNumber = "0";
+    }
+    int pageNumberInt = 0;
+    try {
+        pageNumberInt = Integer.parseInt(pageNumber);
+    } catch (NumberFormatException ignored) {
+    }
+
+    String cartridgeSearchString = request.getParameter("cartridgeSearchString");
+    if (cartridgeSearchString == null) {
+        cartridgeSearchString = "";
+    }
+
+    try {
+        client = new CartridgeAdminClient(cookie, backendServerURL, configContext, request.getLocale());
+        CartridgeWrapper cartridgeWrapper = client.getPagedSubscribedCartridges(cartridgeSearchString, pageNumberInt);
+        if (cartridgeWrapper != null) {
+        	numberOfPages = cartridgeWrapper.getNumberOfPages();
+        	cartridges = cartridgeWrapper.getCartridges();
+        }
+    } catch (Exception e) {
+        response.setStatus(500);
+        CarbonUIMessage uiMsg = new CarbonUIMessage(CarbonUIMessage.ERROR, e.getMessage(), e);
+        session.setAttribute(CarbonUIMessage.ID, uiMsg);
+%>
+<jsp:include page="../admin/error.jsp" />
+<%
+	return;
+    }
+%>
+
+<fmt:bundle basename="org.wso2.carbon.cartridge.mgt.ui.i18n.Resources">
+	<div>
+		<%
+			if (cartridges != null) {
+				String parameters = "cartridgeSearchString=" + cartridgeSearchString;
+		%>
+	
+		<carbon:paginator pageNumber="<%=pageNumberInt%>" numberOfPages="<%=numberOfPages%>" page="subscribed_cartridges.jsp"
+			pageNumberParameterName="pageNumber" resourceBundle="org.wso2.carbon.cartridge.mgt.ui.i18n.Resources" prevKey="prev"
+			nextKey="next" parameters="<%=parameters%>" />
+		<p>&nbsp;</p>
+	
+		<form id="frmSubC" name="cartridgesForm" method="post">
+			<input type="hidden" name="pageNumber" value="<%=pageNumber%>" />
+			<table id="cartridgesTable" class="styledLeft" style="width: 100%">
+				<thead>
+					<tr>
+						<th style="width: 10%"><fmt:message key="cartridge.display.name" /></th>
+						<th style="width: 70px"><fmt:message key="cartridge.version" /></th>
+						<th style="width: 125px"><fmt:message key="cartridge.tenancymodel" /></th>
+						<th style="width: 10%"><fmt:message key="alias" /></th>
+						<th style="width: 5%"><fmt:message key="status" /></th>
+						<th style="text-align: right; padding-right: 5px; width: 125px;"><fmt:message key="instance.count" /></th>
+						<th><fmt:message key="url" /></th>
+						<th style="width: 12%"><fmt:message key="repo.url" /></th>
+						<th style="width: 8%"><fmt:message key="action" /></th>
+					</tr>
+				</thead>
+				<tbody>
+	
+					<%
+						int id = 1; // To generate ID
+					
+						for (Cartridge cartridge : cartridges) {
+							
+							String popupID = "cartridge_popup_" + id;
+							String rowStyleClass = ((id & 1) == 0) ? "tableEvenRow" : "tableOddRow";
+							
+							// Increment ID
+							id++;
+											
+							String[] accessURLs = cartridge.getAccessURLs();
+							StringBuilder urlBuilder = new StringBuilder();
+							if (accessURLs != null) {
+								for (int i = 0; i < accessURLs.length; i++) {
+									String url = accessURLs[i];
+									if (url != null) {
+										if (i > 0) {
+											urlBuilder.append("<br />");
+										}
+										urlBuilder.append("<a href=\"").append(url).append("\" target=\"_blank\">").append(url).append("</a>");
+									}
+								}
+							}
+							
+							String displayName = (cartridge.getDisplayName() != null ? cartridge.getDisplayName() : "");
+							String version = (cartridge.getVersion() != null ? cartridge.getVersion() : "");
+							String description = (cartridge.getDescription() != null ? cartridge.getDescription() : "");
+							String alias = (cartridge.getCartridgeAlias() != null ? cartridge.getCartridgeAlias() : "");
+							String status = (cartridge.getStatus() != null ? cartridge.getStatus() : "");
+							int activeInstances = cartridge.getActiveInstances();
+							String instances = cartridge.getMultiTenant() ? "N/A" : String.valueOf(activeInstances);
+							String accessURL = urlBuilder.toString();
+							String repoURL = (cartridge.getRepoURL() != null ? cartridge.getRepoURL() : "");
+							String ip = (cartridge.getIp() != null ? cartridge.getIp() : "");
+							String dbUsername = (cartridge.getDbUserName() != null ? cartridge.getDbUserName() : "");
+							String password = (cartridge.getPassword() != null ? cartridge.getPassword() : "");
+							String mappedDomain = (cartridge.getMappedDomain() != null ? cartridge.getMappedDomain() : "");
+							String policy = (cartridge.getPolicyDescription() != null ? cartridge.getPolicyDescription() : "");
+							String tenancyModel = cartridge.getMultiTenant() ? "Multi-Tenant" : "Single-Tenant";
+							
+							if (repoURL.startsWith("http")) {
+								StringBuilder repoURLBuilder = new StringBuilder();
+								repoURL = repoURLBuilder.append("<a href=\"").append(repoURL).append("\" target=\"_blank\">").append(repoURL).append("</a>").toString();
+							}
+					%>
+	
+					<tr class="<%=rowStyleClass%>">
+						<td><%=displayName%></td>
+						<td><%=version%></td>
+						<td><%=tenancyModel%></td>
+						<td><a onclick="showCartridgeInfo('<%=popupID%>', '<%=alias%>')" style="background-image:url(../admin/images/information.gif);" class="icon-link"><%=alias%></a></td>
+						<td><span <%if (!"ACTIVE".equalsIgnoreCase(status)) {%>
+							style="background-image: url(images/ajax-loading.gif); background-repeat: no-repeat; background-position: left center; padding-left: 22px;"
+							<%}%>><%=status%></span></td>
+						<td style="text-align: right;"><%=instances%></td>
+						<td><%=accessURL%></td>
+						<td><%=repoURL%></td>
+						<td><a onclick="unsubscribeCartridge('<%=alias%>');" style="background-image:url(images/unsubscribe.png);" class="icon-link">
+	                              <fmt:message key="unsubscribe"/></a>
+	                              <% if (mappedDomain.length() == 0) {	%>
+	                              	<a href="./map_domain.jsp?cartridge_alias=<%=alias%>&domain=<%=mappedDomain%>" class="icon-link">
+	                              	<fmt:message key="mapdomain"/></a>
+	                              <% } %>
+	                              <% if (repoURL.length() > 0) {	%>
+	                              	<a onclick="syncRepo('<%=alias%>');" class="icon-link">
+	                              	<fmt:message key="syncrepo"/></a>
+	                              <% } %>
+	                              <% if (mappedDomain.length() > 0) {	%>
+	                              	<a onclick="removeDomain('<%=alias%>');" class="icon-link">
+                      				<fmt:message key="removedomain"/></a>
+	                              <% } %>
+	                              <div id="<%=popupID%>" style="display: none">
+	                              	<table class="popupTable" style="width: 100%">
+	                              		<tbody>
+	                              			<tr class="tableOddRow">
+	                              				<td style="width: 40%"><fmt:message key="cartridge.display.name" /></td>
+	                              				<td><%=displayName%></td>
+	                              			</tr>
+	                              			<tr class="tableEvenRow">
+	                              				<td style="width: 40%"><fmt:message key="cartridge.version" /></td>
+	                              				<td><%=version%></td>
+	                              			</tr>
+	                              			<tr class="tableOddRow">
+	                              				<td style="width: 40%"><fmt:message key="cartridge.description" /></td>
+	                              				<td><%=description%></td>
+	                              			</tr>
+	                              			<tr class="tableEvenRow">
+	                              				<td style="width: 40%"><fmt:message key="cartridge.tenancymodel" /></td>
+	                              				<td><%=tenancyModel%></td>
+	                              			</tr>
+	                              			<tr class="tableOddRow">
+	                              				<td style="width: 40%"><fmt:message key="alias" /></td>
+	                              				<td><%=alias%></td>
+	                              			</tr>
+	                              			<tr class="tableEvenRow">
+	                              				<td style="width: 40%"><fmt:message key="status" /></td>
+	                              				<td><%=status%></td>
+	                              			</tr>
+	                              			<tr class="tableOddRow">
+	                              				<td style="width: 40%"><fmt:message key="instance.count" /></td>
+	                              				<td><%=instances%></td>
+	                              			</tr>
+	                              			<tr class="tableEvenRow">
+	                              				<td style="width: 40%"><fmt:message key="url" /></td>
+	                              				<td><%=accessURL%></td>
+	                              			</tr>
+											<% 
+											// Assign style class according to row
+											int popupRowId = 0; 
+											%>
+	                              			<% if (policy.length() > 0) { %>
+	                              			<tr class="<%=(((++popupRowId & 1) == 0) ? "tableEvenRow" : "tableOddRow")%>">
+	                              				<td style="width: 40%"><fmt:message key="policy" /></td>
+	                              				<td><%=policy%></td>
+	                              			</tr>
+	                              			<% } %>
+	                              			<% if (repoURL.length() > 0) { %>
+	                              			<tr class="<%=(((++popupRowId & 1) == 0) ? "tableEvenRow" : "tableOddRow")%>">
+	                              				<td style="width: 40%"><fmt:message key="repo.url" /></td>
+	                              				<td><%=repoURL%></td>
+	                              			</tr>
+	                              			<% } %>
+	                              			<% if (ip.length() > 0) { %>
+	                              			<tr class="<%=(((++popupRowId & 1) == 0) ? "tableEvenRow" : "tableOddRow")%>">
+	                              				<td style="width: 40%"><fmt:message key="ip" /></td>
+	                              				<td><%=ip%></td>
+	                              			</tr>
+	                              			<% } %>
+	                              			<% if (dbUsername.length() > 0) { %>
+	                              			<tr class="<%=(((++popupRowId & 1) == 0) ? "tableEvenRow" : "tableOddRow")%>">
+	                              				<td style="width: 40%"><fmt:message key="username" /></td>
+	                              				<td><%=dbUsername%></td>
+	                              			</tr>
+	                              			<% } %>
+	                              			<% if (password.length() > 0) {	%>
+	                              			<tr class="<%=(((++popupRowId & 1) == 0) ? "tableEvenRow" : "tableOddRow")%>">
+	                              				<td style="width: 40%"><fmt:message key="password" /></td>
+	                              				<td><%=password%></td>
+	                              			</tr>
+	                              			<% } %>
+	                              			<% if (mappedDomain.length() > 0) {	%>
+	                              			<tr class="<%=(((++popupRowId & 1) == 0) ? "tableEvenRow" : "tableOddRow")%>">
+	                              				<td style="width: 40%"><fmt:message key="mappeddomain" /></td>
+	                              				<td><%=mappedDomain%></td>
+	                              			</tr>
+	                              			<% } %>
+	                              		</tbody>
+	                              	</table>
+	                              </div>
+	                          </td>
+					</tr>
+					<%
+						}
+					%>
+				</tbody>
+			</table>
+		</form>
+		<p>&nbsp;</p>
+		<carbon:paginator pageNumber="<%=pageNumberInt%>" numberOfPages="<%=numberOfPages%>" page="subscribed_cartridges.jsp"
+			pageNumberParameterName="pageNumber" resourceBundle="org.wso2.carbon.cartridge.mgt.ui.i18n.Resources" prevKey="prev"
+			nextKey="next" parameters="<%=parameters%>" />
+		<%
+			} else {
+		%>
+		<b><fmt:message key="no.cartridges.found" /></b>
+		<%
+			}
+		%>
+	</div>
+</fmt:bundle>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/sync_repo_ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/sync_repo_ajaxprocessor.jsp b/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/sync_repo_ajaxprocessor.jsp
new file mode 100644
index 0000000..e79444b
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/sync_repo_ajaxprocessor.jsp
@@ -0,0 +1,60 @@
+<!--
+ ~ Copyright (c) 2005-2013, 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.
+ -->
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
+<%@ page import="org.apache.axis2.context.ConfigurationContext"%>
+<%@ page import="org.wso2.carbon.CarbonConstants"%>
+<%@ page import="org.wso2.carbon.ui.CarbonUIMessage"%>
+<%@ page import="org.wso2.carbon.ui.CarbonUIUtil"%>
+<%@ page import="org.wso2.carbon.utils.ServerConstants"%>
+<%@ page import="org.wso2.carbon.cartridge.mgt.ui.CartridgeAdminClient"%>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon"%>
+<%@ page import="org.wso2.carbon.adc.mgt.dto.xsd.Cartridge"%>
+<%@ page import="java.text.SimpleDateFormat"%>
+<%@ page import="java.util.ResourceBundle"%>
+<jsp:include page="../dialog/display_messages.jsp" />
+
+
+<%
+	response.setHeader("Cache-Control", "no-cache");
+
+	ResourceBundle bundle = ResourceBundle.getBundle(CartridgeAdminClient.BUNDLE, request.getLocale());
+
+	String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+	ConfigurationContext configContext = (ConfigurationContext) config.getServletContext().getAttribute(
+			CarbonConstants.CONFIGURATION_CONTEXT);
+
+	String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+	CartridgeAdminClient client;
+
+	String cartridgeAlias = request.getParameter("cartridge_alias");
+	try {
+		client = new CartridgeAdminClient(cookie, backendServerURL, configContext, request.getLocale());
+		client.synchronizeRepository(cartridgeAlias);
+		//CarbonUIMessage.sendCarbonUIMessage("Initiated repository synchronization", CarbonUIMessage.INFO, request);
+		String message = "Initiated repository synchronization";
+%>
+<span id="responseMsg"><%=message%></span>
+<%
+	} catch (Exception e) {
+		//CarbonUIMessage.sendCarbonUIMessage(e.getMessage(), CarbonUIMessage.ERROR, request);
+		response.setStatus(500);
+%>
+<span id="responseMsg"><%=e.getMessage()%></span>
+<%
+	}
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/test_git_ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/test_git_ajaxprocessor.jsp b/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/test_git_ajaxprocessor.jsp
new file mode 100644
index 0000000..fa4b8a0
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/test_git_ajaxprocessor.jsp
@@ -0,0 +1,71 @@
+<!--
+ ~ 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.
+ -->
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ page import="org.apache.axis2.context.ConfigurationContext" %>
+<%@ page import="org.wso2.carbon.CarbonConstants" %>
+<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %>
+<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %>
+<%@ page import="org.wso2.carbon.utils.ServerConstants" %>
+<%@ page import="org.wso2.carbon.cartridge.mgt.ui.CartridgeAdminClient" %>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
+<%@ page import="org.wso2.carbon.adc.mgt.dto.xsd.RepositoryInformation" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%@ page import="java.util.ResourceBundle" %>
+<%@ page import="java.util.Map" %>
+<jsp:include page="../dialog/display_messages.jsp"/>
+
+
+<%
+	response.setHeader("Cache-Control", "no-cache");
+
+	ResourceBundle bundle = ResourceBundle
+        .getBundle(CartridgeAdminClient.BUNDLE, request.getLocale());
+
+    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+    ConfigurationContext configContext =
+          (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+
+    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+    CartridgeAdminClient client;
+    String repoUrl = "";
+    String repoUserName = "";
+    String repoPassword = "";
+    String repoType = null;
+    
+    repoUrl = request.getParameter("repo_url");
+    repoUserName = request.getParameter("repo_username");
+    repoPassword = request.getParameter("repo_password");
+    repoType = request.getParameter("repoType");
+    try{
+   		client = new CartridgeAdminClient(cookie, backendServerURL, configContext, request.getLocale());
+   		RepositoryInformation repositoryInformation = client.testRepositoryConnection(repoUrl, repoUserName, repoPassword, "private".equals(repoType));
+   		String message = "";
+   		if (repositoryInformation != null) {
+   			message = "Successfully connected to the repository: " + repositoryInformation.getRepoURL();
+   		}
+%>
+<span id="responseMsg"><%=message%></span>
+<%
+	} catch (Exception e) {
+		response.setStatus(500);
+%>
+<span id="responseMsg"><%=e.getMessage()%></span>
+<%
+	}
+%>
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/unsubscribe_ajaxprocessor.jsp
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/unsubscribe_ajaxprocessor.jsp b/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/unsubscribe_ajaxprocessor.jsp
new file mode 100644
index 0000000..c246091
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.cartridge.mgt.ui/2.1.3/src/main/resources/web/cartridge-mgt/unsubscribe_ajaxprocessor.jsp
@@ -0,0 +1,64 @@
+<!--
+ ~ 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.
+ -->
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ page import="org.apache.axis2.context.ConfigurationContext" %>
+<%@ page import="org.wso2.carbon.CarbonConstants" %>
+<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %>
+<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %>
+<%@ page import="org.wso2.carbon.utils.ServerConstants" %>
+    <%@ page import="org.wso2.carbon.cartridge.mgt.ui.CartridgeAdminClient" %>
+<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
+<%@ page import="org.wso2.carbon.adc.mgt.dto.xsd.Cartridge" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%@ page import="java.util.ResourceBundle" %>
+<jsp:include page="../dialog/display_messages.jsp"/>
+
+
+<%
+    response.setHeader("Cache-Control", "no-cache");
+
+	ResourceBundle bundle = ResourceBundle
+        .getBundle(CartridgeAdminClient.BUNDLE, request.getLocale());
+
+    String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
+    ConfigurationContext configContext =
+          (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
+
+    String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
+    CartridgeAdminClient client;
+
+    String cartridgeAlias = request.getParameter("cartridge_alias");
+    
+    try{
+        client= new CartridgeAdminClient(cookie, backendServerURL, configContext,request.getLocale());
+        client.unsubscribe(cartridgeAlias);
+        //CarbonUIMessage.sendCarbonUIMessage("Successfully unsubscribed "  ,
+        //                                                        CarbonUIMessage.INFO, request);
+        String message = "Successfully unsubscribed";
+%>
+<span id="responseMsg"><%=message%></span>
+<%
+    }catch (Exception e) {
+        response.setStatus(500);
+        //CarbonUIMessage uiMsg = new CarbonUIMessage(CarbonUIMessage.ERROR,  e.getMessage(), e);
+        //session.setAttribute(CarbonUIMessage.ID, uiMsg);
+%>
+<span id="responseMsg"><%=e.getMessage()%></span>
+<%
+    }
+%>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/pom.xml b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/pom.xml
new file mode 100644
index 0000000..3438d6d
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/pom.xml
@@ -0,0 +1,116 @@
+<!--
+# 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.wso2.carbon</groupId>
+        <artifactId>stratos-components</artifactId>
+        <version>2.1.0</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.wso2.carbon.db.keep.alive</artifactId>
+    <packaging>bundle</packaging>
+    <name>WSO2 Stratos - DB Keep Alive</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>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Private-Package>
+                            org.wso2.carbon.db.keep.alive.*,
+                        </Private-Package>
+                        <Import-Package>
+                            org.quartz.*,
+                            org.apache.synapse.task.*,
+                            org.wso2.carbon.registry.core.*;version=1.0.1,
+                            org.wso2.carbon.registry.resource.*,
+                            org.wso2.carbon.stratos.common.*,
+                            !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>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</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.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.user.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.user.mgt</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.billing.mgt</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.billing.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.stratos.common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-tasks</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-commons</artifactId>
+        </dependency>
+
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/AccessingBillingAction.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/AccessingBillingAction.java b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/AccessingBillingAction.java
new file mode 100644
index 0000000..e668040
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/AccessingBillingAction.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+package org.wso2.carbon.db.keep.alive.actions;
+
+import org.wso2.carbon.billing.core.BillingEngine;
+
+public class AccessingBillingAction {
+    BillingEngine billingEngine;
+    public AccessingBillingAction(BillingEngine billingEngine) {
+        this.billingEngine = billingEngine;
+    }
+    public void execute() throws Exception {
+        billingEngine.beginTransaction();
+        boolean succeeded = false;
+        try {
+            billingEngine.getCustomersWithName("some-non-existance-customer");
+            succeeded = true;
+        } finally {
+            if (succeeded) {
+                billingEngine.commitTransaction();
+            } else {
+                billingEngine.rollbackTransaction();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/AccessingRegistryAction.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/AccessingRegistryAction.java b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/AccessingRegistryAction.java
new file mode 100644
index 0000000..e48ecc5
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/AccessingRegistryAction.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+package org.wso2.carbon.db.keep.alive.actions;
+
+import org.wso2.carbon.registry.core.Collection;
+import org.wso2.carbon.registry.core.Registry;
+
+import java.util.Date;
+
+public class AccessingRegistryAction {
+    private static final String KEEP_ALIVE_RESOURCE =
+            "/repository/components/org.wso2.carbon.keep-alive-resource";
+    Registry registry;
+    public AccessingRegistryAction(Registry registry) {
+        this.registry = registry;
+    }
+    public void execute() throws Exception {
+        Collection c;
+        if (registry.resourceExists(KEEP_ALIVE_RESOURCE)) {
+            c = (Collection)registry.get(KEEP_ALIVE_RESOURCE);
+        } else {
+            c = registry.newCollection();
+        }
+        long currentTime = new Date().getTime();
+        c.setProperty("currentTime", String.valueOf(currentTime));
+        registry.put(KEEP_ALIVE_RESOURCE, c);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/UserMgtAction.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/UserMgtAction.java b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/UserMgtAction.java
new file mode 100644
index 0000000..0eb2b21
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/actions/UserMgtAction.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.wso2.carbon.db.keep.alive.actions;
+
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.core.AuthorizationManager;
+import org.wso2.carbon.user.core.Permission;
+import org.wso2.carbon.user.core.UserRealm;
+import org.wso2.carbon.user.core.UserStoreManager;
+import org.wso2.carbon.user.core.service.RealmService;
+
+public class UserMgtAction {
+    UserRealm realm;
+    public UserMgtAction(RegistryService registryService) throws RegistryException {
+        realm = registryService.getUserRealm(0);
+    }
+    public void execute() throws Exception {
+        UserStoreManager userStoreManager = realm.getUserStoreManager();
+        if (!userStoreManager.isExistingUser("tracker")) {
+            userStoreManager.addUser("tracker", "tracker123", null, null, null, false);
+            Permission[] permisions = new Permission[] { new Permission("high security", "read")};
+            userStoreManager.addRole("tracker_role", new String[] {"tracker"}, permisions);
+        }
+        userStoreManager.updateCredentialByAdmin("tracker", "tracker123");
+        // do some authorizations
+        AuthorizationManager authManager = realm.getAuthorizationManager();
+        authManager.authorizeRole("tracker_role", "tracker_obj", "read");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/internal/DBKeepAliveServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/internal/DBKeepAliveServiceComponent.java b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/internal/DBKeepAliveServiceComponent.java
new file mode 100644
index 0000000..c208845
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/internal/DBKeepAliveServiceComponent.java
@@ -0,0 +1,81 @@
+/*
+*  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.
+*/
+package org.wso2.carbon.db.keep.alive.internal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.billing.core.BillingManager;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.db.keep.alive.util.Util;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.user.mgt.UserMgtConstants;
+
+/**
+ * @scr.component name="org.wso2.carbon.db.keep.alive"
+ * 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="billingManager.service"
+ * interface="org.wso2.carbon.billing.core.BillingManager" cardinality="1..1"
+ * policy="dynamic" bind="setBillingManager" unbind="unsetBillingManager"
+ */
+public class DBKeepAliveServiceComponent {
+    private static Log log = LogFactory.getLog(DBKeepAliveServiceComponent.class);
+
+
+    protected void activate(ComponentContext context) {
+        Util.registerJob();
+        log.debug("******* DBKeepAlive bundle is activated ******* ");
+    }
+
+    protected void deactivate(ComponentContext context) {
+        log.debug("******* DBKeepAlive is deactivated ******* ");
+    }
+
+    protected void setRegistryService(RegistryService registryService) {
+        Util.setRegistryService(registryService);
+    }
+
+    protected void unsetRegistryService(RegistryService registryService) {
+        Util.setRegistryService(null);
+    }
+
+    protected void setRealmService(RealmService realmService) {
+        Util.setRealmService(realmService);
+    }
+
+    protected void unsetRealmService(RealmService realmService) {
+        Util.setRealmService(null);
+    }
+
+    public void setBillingManager(BillingManager billingManager) {
+        log.debug("Receiving billingManager service");
+        Util.setBillingManager(billingManager);
+    }
+
+    public void unsetBillingManager(BillingManager billingManager) {
+        log.debug("Unsetting billingManager service");
+        Util.setBillingManager(null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/util/KeepAliveJob.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/util/KeepAliveJob.java b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/util/KeepAliveJob.java
new file mode 100644
index 0000000..550bfc5
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/util/KeepAliveJob.java
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+package org.wso2.carbon.db.keep.alive.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.db.keep.alive.actions.AccessingBillingAction;
+import org.wso2.carbon.db.keep.alive.actions.AccessingRegistryAction;
+import org.wso2.carbon.db.keep.alive.actions.UserMgtAction;
+
+public class KeepAliveJob implements Job {
+    private static final Log log = LogFactory.getLog(KeepAliveJob.class);
+
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        log.debug("-------------Running the db keep alive job------------------");
+        RegistryService registryService = Util.getRegistryService();
+        try {
+            new AccessingRegistryAction(registryService.getLocalRepository()).execute();
+            new AccessingRegistryAction(registryService.getConfigSystemRegistry()).execute();
+            new AccessingRegistryAction(registryService.getGovernanceSystemRegistry()).execute();
+        } catch (Exception e) {
+            String msg = "Error in running registry actions.";
+            log.error(msg, e);
+            throw new JobExecutionException(msg, e);
+        }
+        try {
+            new AccessingBillingAction(Util.getBillingEngine()).execute();
+        } catch (Exception e) {
+            String msg = "Error in running billing engine action.";
+            log.error(msg, e);
+            throw new JobExecutionException(msg, e);
+        }
+        try {
+            new UserMgtAction(registryService).execute();
+        } catch (Exception e) {
+            String msg = "Error in running user manager actions.";
+            log.error(msg, e);
+            throw new JobExecutionException(msg, e);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/util/Util.java b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/util/Util.java
new file mode 100644
index 0000000..7af5c72
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.db.keep.alive/2.1.0/src/main/java/org/wso2/carbon/db/keep/alive/util/Util.java
@@ -0,0 +1,115 @@
+/*
+ *  Copyright (c) 2005-2008, 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.wso2.carbon.db.keep.alive.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.task.TaskDescription;
+import org.apache.synapse.task.TaskScheduler;
+import org.apache.synapse.task.TaskSchedulerFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.wso2.carbon.billing.core.BillingEngine;
+import org.wso2.carbon.billing.core.BillingManager;
+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.registry.core.utils.UUIDGenerator;
+import org.wso2.carbon.user.core.UserRealm;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.stratos.common.constants.StratosConstants;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class Util {
+
+    private static final Log log = LogFactory.getLog(Util.class);
+    private static int JOB_INTERVAL = 15; // in mins
+    private static String TASK_ID = "taskId"; 
+
+    private static RegistryService registryService;
+    private static RealmService realmService;
+    private static ServiceRegistration redirectorServiceRegistration = null;
+    private static BillingManager billingManager;
+
+    public static synchronized void setRegistryService(RegistryService service) {
+        if (registryService == null) {
+            registryService = service;
+        }
+    }
+
+    public static synchronized void setRealmService(RealmService service) {
+        if (realmService == null) {
+            realmService = service;
+        }
+    }
+
+    public static RealmService getRealmService() {
+        return realmService;
+    }
+
+    public static RegistryService getRegistryService() {
+        return registryService;
+    }
+
+    public static BillingManager getBillingManager() {
+        return billingManager;
+    }
+
+    public static void setBillingManager(BillingManager billingManager) {
+        Util.billingManager = billingManager;
+    }
+
+    public static UserRealm getUserRealm(int tenantId) throws RegistryException {
+        return registryService.getUserRealm(tenantId);     
+    }
+
+    public static UserRegistry getSuperTenantGovernanceSystemRegistry() throws RegistryException {
+        return registryService.getGovernanceSystemRegistry();
+    }
+
+    public static BillingEngine getBillingEngine() {
+        return billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);
+    }
+
+    public static void registerJob() {
+
+        String taskName = UUIDGenerator.generateUUID();
+        String groupId = UUIDGenerator.generateUUID();
+
+        TaskDescription taskDescription = new TaskDescription();
+        taskDescription.setName(taskName);
+        taskDescription.setGroup(groupId);
+        // we are triggering only at the period
+
+        //taskDescription.setInterval(200);
+        taskDescription.setInterval(JOB_INTERVAL * 60 * 1000L);
+
+        Map<String, Object> resources = new HashMap<String, Object>();
+
+        TaskScheduler taskScheduler =
+                TaskSchedulerFactory.getTaskScheduler(TASK_ID);
+        if (!taskScheduler.isInitialized()) {
+            Properties properties = new Properties();
+            taskScheduler.init(properties);
+        }        
+        taskScheduler.scheduleTask(taskDescription, resources, KeepAliveJob.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.email.sender/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.email.sender/2.1.0/pom.xml b/components/stratos/org.wso2.carbon.email.sender/2.1.0/pom.xml
new file mode 100644
index 0000000..6d28e10
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.email.sender/2.1.0/pom.xml
@@ -0,0 +1,86 @@
+<!--
+# 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.wso2.carbon</groupId>
+        <artifactId>stratos-components</artifactId>
+        <version>2.1.0</version>
+<relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.wso2.carbon.email.sender</artifactId>
+    <packaging>bundle</packaging>
+    <name>WSO2 Stratos - Email Sender Component</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>
+                        <Bundle-Name>${project.artifactId}</Bundle-Name>
+                        <Private-Package>
+                            org.wso2.carbon.email.sender.internal.*,
+                            org.wso2.carbon.email.sender.util.*,
+                        </Private-Package>
+                        <Export-Package>
+                            org.wso2.carbon.email.sender.api.*
+                        </Export-Package>
+                        <Import-Package>
+                            !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}",
+                            *;resolution:=optional
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</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>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/BulkEmailSender.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/BulkEmailSender.java b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/BulkEmailSender.java
new file mode 100644
index 0000000..f30aaa6
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/BulkEmailSender.java
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+package org.wso2.carbon.email.sender.api;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.transport.base.BaseConstants;
+import org.apache.axis2.transport.mail.MailConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.email.sender.util.Util;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The class that handles the bulk email sending logic for stratos.
+ */
+public class BulkEmailSender extends EmailSender{
+    private static Log log = LogFactory.getLog(BulkEmailSender.class);
+
+    public BulkEmailSender(EmailSenderConfiguration config) {
+        super(config);
+    }
+
+    /**
+     * Sends the email
+     * @param bulkEmailData List of email data holder objects
+     * @throws Exception, if sending the email notification failed.
+     */
+    public void sendBulkEmails(List<EmailDataHolder> bulkEmailData) throws Exception {
+
+        final List<EmailDataHolder> emailDataHolderList = bulkEmailData;
+
+        final ServiceClient serviceClient;
+        ConfigurationContext configContext = Util.getConfigurationContext();
+        if (configContext != null) {
+            serviceClient = new ServiceClient(configContext, null);
+        } else {
+            serviceClient = new ServiceClient();
+        }
+
+        new Thread() {
+            public void run() {
+
+                for(EmailDataHolder dataHolder : emailDataHolderList){
+
+                    String subject = getMessageTitle(dataHolder.getEmailParameters());
+                    String body = getMessageBody(dataHolder.getEmailParameters());
+                    String email = dataHolder.getEmail(); // no change in here,
+
+                    Map<String, String> headerMap = new HashMap<String, String>();
+                    headerMap.put(MailConstants.MAIL_HEADER_SUBJECT, subject);
+                    OMElement payload = OMAbstractFactory.getOMFactory().createOMElement(
+                            BaseConstants.DEFAULT_TEXT_WRAPPER, null);
+                    payload.setText(body);
+
+                    try {
+                        Options options = new Options();
+                        options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
+                        options.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap);
+                        options.setProperty(MailConstants.TRANSPORT_MAIL_FORMAT,
+                                MailConstants.TRANSPORT_FORMAT_TEXT);
+                        options.setTo(new EndpointReference("mailto:" + email));
+                        serviceClient.setOptions(options);
+                        serviceClient.fireAndForget(payload);
+                        serviceClient.cleanup();
+                    } catch (AxisFault e) {
+                        String msg = "Error in delivering the message, " +
+                                "subject: " + subject + ", to: " + email + ".";
+                        log.error(msg);
+                    }
+                }
+
+            }
+        }.start();
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailDataHolder.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailDataHolder.java b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailDataHolder.java
new file mode 100644
index 0000000..32ab7f9
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailDataHolder.java
@@ -0,0 +1,26 @@
+package org.wso2.carbon.email.sender.api;
+
+import java.util.Map;
+
+//This holds the email address and email parameter map
+public class EmailDataHolder {
+
+    private String email;
+    private Map<String, String> emailParameters;
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public Map<String, String> getEmailParameters() {
+        return emailParameters;
+    }
+
+    public void setEmailParameters(Map<String, String> emailParameters) {
+        this.emailParameters = emailParameters;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailSender.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailSender.java b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailSender.java
new file mode 100644
index 0000000..aec1eef
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailSender.java
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+package org.wso2.carbon.email.sender.api;
+
+import org.wso2.carbon.email.sender.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.transport.mail.MailConstants;
+import org.apache.axis2.transport.base.BaseConstants;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axis2.Constants;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * The class that handles the email sending logic for stratos.
+ */
+public class EmailSender{
+    private static Log log = LogFactory.getLog(EmailSender.class);
+    private EmailSenderConfiguration config = null;
+
+    public EmailSender(EmailSenderConfiguration config) {
+        this.config = config;
+    }
+
+    /**
+     * Sends the email
+     * @param toEmail Email Address (To:)
+     * @param userParameters - map of user parameters
+     * @throws Exception, if sending the email notification failed.
+     */
+    public void sendEmail(String toEmail, Map<String, String>userParameters) throws Exception {
+        final String subject = getMessageTitle(userParameters);
+        final String body = getMessageBody(userParameters);
+        final String email = toEmail; // no change in here,
+        new Thread() {
+            public void run() {
+                Map<String, String> headerMap = new HashMap<String, String>();
+                headerMap.put(MailConstants.MAIL_HEADER_SUBJECT, subject);
+                OMElement payload = OMAbstractFactory.getOMFactory().createOMElement(
+                        BaseConstants.DEFAULT_TEXT_WRAPPER, null);
+                payload.setText(body);
+
+                try {
+                    ServiceClient serviceClient;
+                    ConfigurationContext configContext = Util.getConfigurationContext();
+                    if (configContext != null) {
+                        serviceClient = new ServiceClient(configContext, null);
+                    } else {
+                        serviceClient = new ServiceClient();
+                    }
+                    Options options = new Options();
+                    options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
+                    options.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap);
+                    options.setProperty(MailConstants.TRANSPORT_MAIL_FORMAT,
+                                        MailConstants.TRANSPORT_FORMAT_TEXT);
+                    options.setTo(new EndpointReference("mailto:" + email));
+                    serviceClient.setOptions(options);
+                    serviceClient.fireAndForget(payload);
+                    log.debug("Sending confirmation mail to " + email);
+                } catch (AxisFault e) {
+                    String msg = "Error in delivering the message, " +
+                                "subject: " + subject + ", to: " + email + ".";
+                    log.error(msg);
+                }
+            }
+        }.start();
+    }
+
+    /**
+     * gets the title of the message
+     * @param userParameters - map of user parameters
+     * @return the title of the message
+     */
+    protected String getMessageTitle(Map<String, String> userParameters) {
+        return Util.replacePlaceHolders(config.getSubject(), userParameters);
+    }
+
+    /**
+     * gets the body of the message
+     * @param userParameters - map of user parameters
+     * @return the body of the message
+     */
+    protected String getMessageBody(Map<String, String> userParameters) {
+        return Util.replacePlaceHolders(config.getBody(), userParameters);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailSenderConfiguration.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailSenderConfiguration.java b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailSenderConfiguration.java
new file mode 100644
index 0000000..faaf2d9
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/api/EmailSenderConfiguration.java
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+package org.wso2.carbon.email.sender.api;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * The class that handles the configuration of the email sender for Stratos
+ */
+public class EmailSenderConfiguration {
+    private static Log log = LogFactory.getLog(EmailSenderConfiguration.class);
+
+    public final static String DEFAULT_VALUE_SUBJECT = "EmailSender";
+    public final static String DEFAULT_VALUE_MESSAGE = "Sent form WSO2 Carbon";
+
+    private String fromEmail;
+    private String subject = DEFAULT_VALUE_SUBJECT;
+    private String body = DEFAULT_VALUE_MESSAGE;
+    private Map<String, String> customParameters;
+
+    public Map<String, String> getCustomParameters() {
+        return customParameters;
+    }
+
+    public void setCustomParameters(Map<String, String> customParameters) {
+        this.customParameters = customParameters;
+    }
+
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject.trim();
+    }
+
+    public String getBody() {
+        return body;
+    }
+
+    public void setBody(String emailMessage) {
+        this.body = emailMessage.trim();
+    }
+
+    public String getFromEmail() {
+        return fromEmail;
+    }
+
+    public void setFromEmail(String fromEmail) {
+        this.fromEmail = fromEmail;
+    }
+
+    /**
+     * Loads the email sender configuration
+     * @param configFilename configuration file name
+     * @return EmailSenderConfiguration.
+     */    
+    public static EmailSenderConfiguration loadEmailSenderConfiguration(String configFilename) {
+        File configFile = new File(configFilename);
+        if (!configFile.exists()) {
+            log.error("Email sender configuration File is not present at: " + configFilename);
+            return null;
+        }
+        EmailSenderConfiguration config = new EmailSenderConfiguration();
+        FileInputStream ip = null;
+        try {
+            ip = new FileInputStream(configFile);
+            XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(ip);
+            StAXOMBuilder builder = new StAXOMBuilder(parser);
+            OMElement documentElement = builder.getDocumentElement();
+            Iterator it = documentElement.getChildElements();
+            while (it.hasNext()) {
+                OMElement element = (OMElement) it.next();
+                if ("subject".equals(element.getLocalName())) {
+                    config.setSubject(element.getText());
+                } else if ("body".equals(element.getLocalName())) {
+                    config.setBody(element.getText());
+                } else if ("customParameters".equals(element.getLocalName())) {
+                    Map<String, String> customParameters = new HashMap<String, String>();
+                    Iterator customParamIt = element.getChildElements();
+                    while (customParamIt.hasNext()) {
+                        OMElement customElement = (OMElement) it.next();
+                        customParameters.put(customElement.getLocalName(), customElement.getText());
+                    }
+                    config.setCustomParameters(customParameters);
+                }
+            }
+            return config;
+        } catch (Exception e) {
+            String msg = "Error in loading configuration for email verification: " +
+                         configFilename + ".";
+            log.error(msg, e);
+            return null;
+        } finally {
+            if (ip != null) {
+                try {
+                    ip.close();
+                } catch (IOException e) {
+                    log.warn("Could not close InputStream for file " + configFile.getAbsolutePath());
+                }
+            }
+
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/internal/EmailSenderServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/internal/EmailSenderServiceComponent.java b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/internal/EmailSenderServiceComponent.java
new file mode 100644
index 0000000..d7ad8bb
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/internal/EmailSenderServiceComponent.java
@@ -0,0 +1,82 @@
+/*
+*  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.
+*/
+package org.wso2.carbon.email.sender.internal;
+
+import org.wso2.carbon.email.sender.util.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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.CarbonUtils;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+/**
+ * @scr.component name="org.wso2.carbon.email.sender"
+ * 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="configuration.context.service"
+ * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1"
+ * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
+ */
+public class EmailSenderServiceComponent {
+    private static Log log = LogFactory.getLog(EmailSenderServiceComponent.class);
+
+    protected void activate(ComponentContext context) {
+        try {
+            log.debug("******* Email Sender bundle is activated ******* ");
+        } catch (Exception e) {
+            log.error("******* Email Sender bundle failed activating ****", e);
+        }
+    }
+
+    protected void deactivate(ComponentContext context) {
+        log.debug("******* Email Sender bundle is deactivated ******* ");
+    }
+    protected void setRegistryService(RegistryService registryService) {
+        Util.setRegistryService(registryService);
+    }
+
+    protected void unsetRegistryService(RegistryService registryService) {
+        Util.setRegistryService(null);
+    }
+
+    protected void setRealmService(RealmService realmService) {
+        Util.setRealmService(realmService);
+    }
+
+    protected void unsetRealmService(RealmService realmService) {
+        Util.setRealmService(null);
+    }
+
+    protected void setConfigurationContextService(ConfigurationContextService configurationContextService){
+        log.debug("Receiving ConfigurationContext Service");
+        Util.setConfigurationContextService(configurationContextService);
+
+    }
+
+    protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService){
+        log.debug("Unsetting ConfigurationContext Service");
+        Util.setConfigurationContextService(null);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/util/Util.java b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/util/Util.java
new file mode 100644
index 0000000..d83eebf
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.email.sender/2.1.0/src/main/java/org/wso2/carbon/email/sender/util/Util.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+package org.wso2.carbon.email.sender.util;
+
+import org.apache.axis2.context.ConfigurationContext;
+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.api.RealmConfiguration;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+import java.util.Map;
+import java.util.regex.Matcher;
+
+/**
+ * Utility methods for the email sender component
+ */
+public class Util {
+
+    private static RegistryService registryService;
+    private static RealmService realmService;
+    private static ConfigurationContextService configurationContextService;
+
+
+    public static ConfigurationContextService getConfigurationContextService() {
+        return configurationContextService;
+    }
+
+    public static void setConfigurationContextService(
+            ConfigurationContextService configurationContextService) {
+        Util.configurationContextService = configurationContextService;
+    }
+
+    public static ConfigurationContext getConfigurationContext() {
+        if (configurationContextService.getServerConfigContext() == null) {
+            return null;
+        }
+        return configurationContextService.getServerConfigContext();
+    }
+
+    public static synchronized void setRegistryService(RegistryService service) {
+        if (registryService == null) {
+            registryService = service;
+        }
+    }
+
+    public static RegistryService getRegistryService() {
+        return registryService;
+    }
+
+    public static synchronized void setRealmService(RealmService service) {
+        if (realmService == null) {
+            realmService = service;
+        }
+    }
+
+    public static RealmService getRealmService() {
+        return realmService;
+    }
+
+    public static TenantManager getTenantManager() {
+        return realmService.getTenantManager();
+    }
+
+    public static RealmConfiguration getBootstrapRealmConfiguration() {
+        return realmService.getBootstrapRealmConfiguration();
+    }
+
+    public static UserRegistry getGovernanceSystemRegistry(int tenantId) throws RegistryException {
+        return registryService.getGovernanceSystemRegistry(tenantId);
+    }
+
+    /**
+     * Replace the {place-holders} with the respective value provided
+     * @param text string
+     * @param userParameters - map of user parameters
+     * @return replaced text for the email {title or body}
+     */
+    public static String replacePlaceHolders(String text, Map<String, String> userParameters) {
+        if (userParameters != null) {
+            for (Map.Entry<String, String> entry : userParameters.entrySet()) {
+                String key = entry.getKey();
+                text = text.replaceAll("\\{" + key + "\\}", Matcher.quoteReplacement(entry.getValue()));
+            }
+        }
+        return text;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.gapp.registration.ui/2.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.gapp.registration.ui/2.1.0/pom.xml b/components/stratos/org.wso2.carbon.gapp.registration.ui/2.1.0/pom.xml
new file mode 100644
index 0000000..0b1b170
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.gapp.registration.ui/2.1.0/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (c) WSO2 Inc. (http://wso2.com) 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.wso2.carbon</groupId>
+        <artifactId>stratos-components</artifactId>
+        <version>2.1.0</version>
+<relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.wso2.carbon.gapp.registration.ui</artifactId>
+    <packaging>bundle</packaging>
+    <name>WSO2 Carbon - Google Apps Registration UI</name>
+    <description>Provides Google Apps Provisioning via Marketplace</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.logging</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.json.wso2</groupId>
+            <artifactId>json</artifactId>
+            <version>1.0.0.wso2v1</version>
+        </dependency>
+	<dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.stratos.common</artifactId>
+            <version>2.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.stratos.common.stub</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.rampart.wso2</groupId>
+            <artifactId>rampart-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.security.wso2</groupId>
+            <artifactId>wss4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.tenant.register.gapp.stub</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                         <Bundle-Name>${project.artifactId}</Bundle-Name>
+                         <Export-Package>
+                            org.wso2.carbon.gapp.registration.ui.*
+                         </Export-Package>
+                         <Import-Package>
+                             !org.wso2.carbon.gapp.registration.ui.*,
+                             javax.xml.namespace.*;version="0.0.0",
+                             *;resolution:=optional
+                         </Import-Package>
+                         <Carbon-Component>UIBundle</Carbon-Component>
+                     </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/384b3de9/components/stratos/org.wso2.carbon.gapp.registration.ui/2.1.0/src/main/java/org/wso2/carbon/gapp/registration/ui/GAppRegistrationUIConstants.java
----------------------------------------------------------------------
diff --git a/components/stratos/org.wso2.carbon.gapp.registration.ui/2.1.0/src/main/java/org/wso2/carbon/gapp/registration/ui/GAppRegistrationUIConstants.java b/components/stratos/org.wso2.carbon.gapp.registration.ui/2.1.0/src/main/java/org/wso2/carbon/gapp/registration/ui/GAppRegistrationUIConstants.java
new file mode 100644
index 0000000..d3a6f49
--- /dev/null
+++ b/components/stratos/org.wso2.carbon.gapp.registration.ui/2.1.0/src/main/java/org/wso2/carbon/gapp/registration/ui/GAppRegistrationUIConstants.java
@@ -0,0 +1,6 @@
+package org.wso2.carbon.gapp.registration.ui;
+
+public class GAppRegistrationUIConstants {
+    
+    public static final String AUTH_SESSION_ATTRIBUTE = "gapp.setup.authentication";
+}