http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/docs/userguide.html ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/docs/userguide.html b/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/docs/userguide.html deleted file mode 100755 index a228b4a..0000000 --- a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/docs/userguide.html +++ /dev/null @@ -1,57 +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. - --> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> -<head> - <title>Services Status Monitor - User Guide</title> - <link href="../../admin/css/documentation.css" rel="stylesheet" type="text/css" media="all" /> -</head> - -<body> - - - <h1>View the Status of the Services</h1> - - - <h2> <b> View Service Status</b></h2> - -<p> - In this page, you can see the status of the services. A service instance can be 'Up & Running', - 'Broken', 'Down', and 'Resolved'. -</p> - <img src="images/view-status.png" alt="View Status Page"/> - <div><strong>Figure1: View Services Status</strong></div> - - - - -<h2><b>View Status Details</b></h2> - - -<p> - - This page lists the service status logs. Hence, here you can view the details behind the service status. - -<img src="images/view-details.png" alt="View Status Details Page"/> -<div><strong>Figure2: View Services Status Details</strong></div> - - -</body> - -</html>
http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/images/services.gif ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/images/services.gif b/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/images/services.gif deleted file mode 100755 index 9883116..0000000 Binary files a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/images/services.gif and /dev/null differ http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/images/services1.gif ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/images/services1.gif b/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/images/services1.gif deleted file mode 100755 index d40a7a3..0000000 Binary files a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/images/services1.gif and /dev/null differ http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/service-status.jsp ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/service-status.jsp b/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/service-status.jsp deleted file mode 100644 index 6edfaa2..0000000 --- a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/service-status.jsp +++ /dev/null @@ -1,127 +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. - --%> -<%@ page import="org.apache.axis2.context.ConfigurationContext" %> -<%@ page import="org.wso2.carbon.CarbonConstants" %> -<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %> -<%@ page import="org.wso2.carbon.status.monitor.stub.beans.xsd.ServiceStateInfoBean" %> -<%@ page import="org.wso2.carbon.status.monitor.ui.clients.HealthMonitorServiceClient" %> -<%@ page import="org.wso2.carbon.status.monitor.ui.utils.StatusMonitorUtil" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@ page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="java.text.SimpleDateFormat" %> -<%@ page import="java.util.Calendar" %> -<%@ page import="java.util.Date" %> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/> -<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script> -<script type="text/javascript" src="../registry_common/js/registry_common.js"></script> -<script type="text/javascript" src="../ajax/js/prototype.js"></script> -<script type="text/javascript" src="js/status_config.js"></script> - - -<carbon:jsi18n - resourceBundle="org.apache.stratos.status.monitor.ui.i18n.JSResources" - request="<%=request%>"/> - -<fmt:bundle basename="org.apache.stratos.status.monitor.ui.i18n.Resources"> - <carbon:breadcrumb - label="monitor.service_status.menu" - resourceBundle="org.apache.stratos.status.monitor.ui.i18n.Resources" - topPage="true" - request="<%=request%>"/> - - - <div id="middle"> - - <% - 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); - HealthMonitorServiceClient client; - ServiceStateInfoBean[] serviceStateInfoBeanArr; - try { - client = new HealthMonitorServiceClient(cookie, backendServerURL, configContext); - - serviceStateInfoBeanArr = client.retrieveStatuses(); - - } catch (UIException e) { - String error1 = "Error in retrieving service status"; - request.setAttribute(CarbonUIMessage.ID, new CarbonUIMessage(error1, error1, null)); - %> - - <jsp:forward page="../admin/error.jsp"/> - - <% - return; - } - %> - - <br/> - - <h2><fmt:message key="services.list"/></h2> - - <div id="workArea"> - <table cellpadding="0" cellspacing="0" border="0" style="width:100%" class="styledLeft"> - <thead> - <tr> - <th style="padding-left:5px;text-align:left;"><fmt:message - key="service.name"/></th> - <th style="padding-left:5px;text-align:left;"><fmt:message - key="service.state"/></th> - <th style="padding-left:5px;text-align:left;"><fmt:message key="logged.time"/></th> - </tr> - </thead> - <tbody> - <% - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - - if (serviceStateInfoBeanArr != null) { - for (ServiceStateInfoBean serviceStateInfoBean : serviceStateInfoBeanArr) { - if (serviceStateInfoBean == null) { - continue; - } - - String service = serviceStateInfoBean.getService(); - String state = serviceStateInfoBean.getServiceState(); - Date loggedDate = new Date(serviceStateInfoBean.getDate()); - String loggedDateStr = dateFormat.format(loggedDate); - %> - <tr id="1"> - <td style="padding-left:5px;padding-top:3px;text-align:left;"><%=service%> - </td> - <td style="padding-left:5px;padding-top:3px;text-align:left;"><%=state%> - </td> - <td style="padding-left:5px;padding-top:3px;text-align:left;"><%=loggedDateStr%> - </td> - </tr> - <% } - } - %> - </tbody> - </table> - </div> - </div> -</fmt:bundle> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/status-details.jsp ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/status-details.jsp b/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/status-details.jsp deleted file mode 100644 index f77696f..0000000 --- a/components/org.apache.stratos.status.monitor.ui/src/main/resources/web/status-monitor/status-details.jsp +++ /dev/null @@ -1,138 +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. - --%> -<%@ page import="org.apache.axis2.context.ConfigurationContext" %> -<%@ page import="org.wso2.carbon.CarbonConstants" %> -<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %> -<%@ page import="org.wso2.carbon.status.monitor.stub.beans.xsd.ServiceStateDetailInfoBean" %> -<%@ page import="org.wso2.carbon.status.monitor.ui.clients.HealthMonitorServiceClient" %> -<%@ page import="org.wso2.carbon.status.monitor.ui.utils.StatusMonitorUtil" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %> -<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %> -<%@ page import="org.wso2.carbon.utils.ServerConstants" %> -<%@ page import="java.text.SimpleDateFormat" %> -<%@ page import="java.util.Calendar" %> -<%@ page import="java.util.Date" %> -<%@ page contentType="text/html;charset=UTF-8" language="java" %> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> -<jsp:include page="../registry_common/registry_common-i18n-ajaxprocessor.jsp"/> -<script type="text/javascript" src="../registry_common/js/registry_validation.js"></script> -<script type="text/javascript" src="../registry_common/js/registry_common.js"></script> -<script type="text/javascript" src="../ajax/js/prototype.js"></script> -<script type="text/javascript" src="js/status_config.js"></script> - - -<carbon:jsi18n - resourceBundle="org.apache.stratos.status.monitor.ui.i18n.JSResources" - request="<%=request%>"/> - -<fmt:bundle basename="org.apache.stratos.status.monitor.ui.i18n.Resources"> - <carbon:breadcrumb - label="monitor.status_details.menu" - resourceBundle="org.apache.stratos.status.monitor.ui.i18n.Resources" - topPage="true" - request="<%=request%>"/> - - - <div id="middle"> - - <% - 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); - HealthMonitorServiceClient client; - - ServiceStateDetailInfoBean[] serviceStateDetailInfoBeanArr; - try { - client = new HealthMonitorServiceClient(cookie, backendServerURL, configContext); - - serviceStateDetailInfoBeanArr = client.retrieveStateDetails(); - - } catch (UIException e) { - String error1 = "Error in retrieving service state details"; - request.setAttribute(CarbonUIMessage.ID, new CarbonUIMessage(error1, error1, null)); - %> - - <jsp:forward page="../admin/error.jsp"/> - - <% - return; - } - %> - - <br/> - - <h2><fmt:message key="services.state.details"/></h2> - - <div id="workArea"> - <table cellpadding="0" cellspacing="0" border="0" style="width:100%" class="styledLeft"> - <thead> - <tr> - <th style="padding-left:5px;text-align:left;"><fmt:message - key="service.name"/></th> - <th style="padding-left:5px;text-align:left;"><fmt:message - key="state.logged.time"/></th> - <th style="padding-left:5px;text-align:left;"><fmt:message - key="service.state.details"/></th> - <th style="padding-left:5px;text-align:left;"><fmt:message - key="details.logged.time"/></th> - </tr> - </thead> - <tbody> - <% - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - - if (serviceStateDetailInfoBeanArr != null) { - for (ServiceStateDetailInfoBean - serviceStateDetailInfoBean : serviceStateDetailInfoBeanArr) { - if (serviceStateDetailInfoBean == null) { - continue; - } - - String service = serviceStateDetailInfoBean.getService(); - String stateDetail = serviceStateDetailInfoBean.getServiceStateDetail(); - Date stateLoggedTime = new Date( - serviceStateDetailInfoBean.getStateLoggedTime()); - Date detailLoggedTime = new Date( - serviceStateDetailInfoBean.getDetailLoggedTime()); - String stateLoggedTimeStr = dateFormat.format(stateLoggedTime); - String detailLoggedTimeStr = dateFormat.format(detailLoggedTime); - %> - <tr id="1"> - <td style="padding-left:5px;padding-top:3px;text-align:left;"><%=service%> - </td> - <td style="padding-left:5px;padding-top:3px;text-align:left;"><%=stateLoggedTimeStr%> - </td> - <td style="padding-left:5px;padding-top:3px;text-align:left;"><%=stateDetail%> - </td> - <td style="padding-left:5px;padding-top:3px;text-align:left;"><%=detailLoggedTimeStr%> - </td> - </tr> - <% } - } - %> - </tbody> - </table> - </div> - </div> -</fmt:bundle> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor/pom.xml b/components/org.apache.stratos.status.monitor/pom.xml deleted file mode 100644 index 8ae36b2..0000000 --- a/components/org.apache.stratos.status.monitor/pom.xml +++ /dev/null @@ -1,80 +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. - --> -<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>4.1.0-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.status.monitor</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Status Monitor Back-End</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.apache.stratos.status.monitor.internal.*, - </Private-Package> - <Export-Package> - org.apache.stratos.status.monitor.beans.*, - org.apache.stratos.status.monitor.services.*, - </Export-Package> - <Import-Package> - org.wso2.carbon.registry.core.*;version=1.0.1, - 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.stratos.status.monitor.core.*, - *;resolution:=optional - </Import-Package> - <DynamicImport-Package>*</DynamicImport-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.status.monitor.core</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/beans/ServiceStateDetailInfoBean.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/beans/ServiceStateDetailInfoBean.java b/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/beans/ServiceStateDetailInfoBean.java deleted file mode 100644 index e31746d..0000000 --- a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/beans/ServiceStateDetailInfoBean.java +++ /dev/null @@ -1,62 +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.status.monitor.beans; - -/** - * Service State Details, includes the log information - */ -public class ServiceStateDetailInfoBean { - private String service; - private String serviceStateDetail; - private long stateLoggedTime; - private long detailLoggedTime; - - public String getService() { - return service; - } - - public void setService(String service) { - this.service = service; - } - - public String getServiceStateDetail() { - return serviceStateDetail; - } - - public void setServiceStateDetail(String serviceStateDetail) { - this.serviceStateDetail = serviceStateDetail; - } - - public long getStateLoggedTime() { - return stateLoggedTime; - } - - public void setStateLoggedTime(long stateLoggedTime) { - this.stateLoggedTime = stateLoggedTime; - } - - public long getDetailLoggedTime() { - return detailLoggedTime; - } - - public void setDetailLoggedTime(long detailLoggedTime) { - this.detailLoggedTime = detailLoggedTime; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/beans/ServiceStateInfoBean.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/beans/ServiceStateInfoBean.java b/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/beans/ServiceStateInfoBean.java deleted file mode 100644 index 2e97b8c..0000000 --- a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/beans/ServiceStateInfoBean.java +++ /dev/null @@ -1,61 +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.status.monitor.beans; - -/** - * Service State Information. - */ -public class ServiceStateInfoBean { - private int serviceID; - private String service; - private String serviceState; - private long date; - - public int getServiceID() { - return serviceID; - } - - public void setServiceID(int serviceID) { - this.serviceID = serviceID; - } - - public String getService() { - return service; - } - - public void setService(String service) { - this.service = service; - } - - public String getServiceState() { - return serviceState; - } - - public void setServiceState(String serviceState) { - this.serviceState = serviceState; - } - - public long getDate() { - return date; - } - - public void setDate(long date) { - this.date = date; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/internal/StatusMonitorServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/internal/StatusMonitorServiceComponent.java b/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/internal/StatusMonitorServiceComponent.java deleted file mode 100644 index e33df54..0000000 --- a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/internal/StatusMonitorServiceComponent.java +++ /dev/null @@ -1,103 +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.status.monitor.internal; - -import org.apache.axis2.context.ConfigurationContext; -import org.apache.stratos.status.monitor.internal.core.MySQLConnector; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; -import org.apache.stratos.status.monitor.core.exception.StatusMonitorException; -import org.apache.stratos.status.monitor.core.util.StatusMonitorUtil; -import org.wso2.carbon.utils.ConfigurationContextService; - -/** - * @scr.component name="org.apache.stratos.status.monitor" immediate="true" - * @scr.reference name="configuration.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="1..1" policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ -public class StatusMonitorServiceComponent { - private static Log log = LogFactory.getLog( - StatusMonitorServiceComponent.class); - - private static BundleContext bundleContext; - private static ConfigurationContextService configurationContextService; - - protected void activate(ComponentContext context) { - try { - bundleContext = context.getBundleContext(); - if (StatusMonitorUtil.getStatusMonitorConfiguration() == null) { - StatusMonitorUtil.initStatusMonitor(context.getBundleContext()); - if (log.isDebugEnabled()) { - log.debug("Status Monitor Agent initialized"); - } - } - initConnector(); - log.debug("******* Status Monitor bundle is activated ******* "); - } catch (Exception e) { - log.error("******* Status Monitor bundle failed activating ****", e); - } - } - - private void initConnector() throws StatusMonitorException { - try { - MySQLConnector.initialize(); - } catch (Exception e) { - String msg = "Error in initializing the mysql connection for the health monitoring"; - log.error(msg, e); - throw new StatusMonitorException(msg, e); - } - } - - protected void deactivate(ComponentContext context) { - log.debug("******* Status Monitor bundle is deactivated ******* "); - } - - protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { - log.debug("Receiving ConfigurationContext Service"); - StatusMonitorServiceComponent. - configurationContextService = configurationContextService; - - } - - protected void unsetConfigurationContextService( - ConfigurationContextService configurationContextService) { - log.debug("Unsetting ConfigurationContext Service"); - setConfigurationContextService(null); - } - - public static BundleContext getBundleContext() { - return bundleContext; - } - - public static ConfigurationContextService getConfigurationContextService() { - return configurationContextService; - } - - public static ConfigurationContext getConfigurationContext() { - if (configurationContextService.getServerConfigContext() == null) { - return null; - } - return configurationContextService.getServerConfigContext(); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/internal/core/MySQLConnector.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/internal/core/MySQLConnector.java b/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/internal/core/MySQLConnector.java deleted file mode 100644 index 0571a65..0000000 --- a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/internal/core/MySQLConnector.java +++ /dev/null @@ -1,171 +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.status.monitor.internal.core; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.status.monitor.beans.ServiceStateDetailInfoBean; -import org.apache.stratos.status.monitor.beans.ServiceStateInfoBean; -import org.apache.stratos.status.monitor.core.constants.StatusMonitorConstants; -import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; - -/** - * The class connecting with the mysql database for the Status Monitor Back end - */ -public class MySQLConnector { - private static Connection conn; - private static final Log log = LogFactory.getLog(MySQLConnector.class); - - private static List<String> serviceList = new ArrayList<String>(); - private static List<String> statusList = new ArrayList<String>(); - - /** - * gets the sql connection and initializes the MySQLConnectionInitializer. - * - * @return Static Connection - * @throws Exception, throws exception - */ - public static Connection initialize() throws Exception { - //gets the sql connection. - conn = MySQLConnectionInitializer.initialize(); - - //initializes the service and state lists. - serviceList = MySQLConnectionInitializer.getServiceList(); - statusList = MySQLConnectionInitializer.getStatusList(); - - if (log.isDebugEnabled()) { - log.debug("Connection to the status database is initialized from status.monitor"); - } - - return conn; - } - - /** - * Gets the service state ID from the service ID - * - * @param serviceID: int - * @return service state ID - * @throws java.sql.SQLException, if the retrieval of the service state failed. - */ - public static ServiceStateInfoBean getServiceState(int serviceID) throws SQLException { - ResultSet rs; - Statement stmtCon = conn.createStatement(); - String sql = StatusMonitorConstants.GET_SERVICE_STATE_SQL + serviceID + - StatusMonitorConstants.ORDER_BY_TIMESTAMP_SQL; - - stmtCon.executeQuery(sql); - rs = stmtCon.getResultSet(); - int stateID; - Timestamp date; - ServiceStateInfoBean serviceStateInfoBean = new ServiceStateInfoBean(); - - try { - while (rs.next()) { - stateID = rs.getInt(StatusMonitorConstants.STATE_ID); - date = rs.getTimestamp(StatusMonitorConstants.TIMESTAMP); - serviceStateInfoBean.setDate(date.getTime()); - serviceStateInfoBean.setService(serviceList.get(serviceID - 1)); - serviceStateInfoBean.setServiceID(serviceID); - serviceStateInfoBean.setServiceState(statusList.get(stateID - 1)); - } - } catch (SQLException e) { - String msg = "Getting the service state failed"; - log.error(msg, e); - throw new SQLException(msg, e); - } finally { - rs.close(); - stmtCon.close(); - } - return serviceStateInfoBean; - } - - /** - * Gets the list of all the service state details. - * - * @return the list of the service state details. - * @throws Exception, if the retrieval of the service state details failed. - */ - public static List<ServiceStateDetailInfoBean> getAllServiceStateDetail() throws Exception { - List<ServiceStateDetailInfoBean> stateDetailList = new ArrayList<ServiceStateDetailInfoBean>(); - - ResultSet rs; - Statement stmtCon = conn.createStatement(); - String sql = StatusMonitorConstants.GET_ALL_STATE_DETAIL_SQL; - stmtCon.executeQuery(sql); - rs = stmtCon.getResultSet(); - String service; - String serviceStateDetail; - Timestamp stateLoggedTime; - Timestamp detailLoggedTime; - - ServiceStateDetailInfoBean serviceStateDetailInfoBean; - - try { - while (rs.next()) { - serviceStateDetailInfoBean = new ServiceStateDetailInfoBean(); - - service = rs.getString(StatusMonitorConstants.SERVICE_WSL_NAME); - stateLoggedTime = rs.getTimestamp(StatusMonitorConstants.SERVICE_STATE_WSL_TIMESTAMP); - detailLoggedTime = - rs.getTimestamp(StatusMonitorConstants.SERVICE_STATE_DETAIL_WSL_TIMESTAMP); - serviceStateDetail = rs.getString(StatusMonitorConstants.SERVICE_STATE_DETAIL); - - serviceStateDetailInfoBean.setService(service); - serviceStateDetailInfoBean.setStateLoggedTime(stateLoggedTime.getTime()); - serviceStateDetailInfoBean.setServiceStateDetail(serviceStateDetail); - serviceStateDetailInfoBean.setDetailLoggedTime(detailLoggedTime.getTime()); - - stateDetailList.add(serviceStateDetailInfoBean); - } - } catch (SQLException e) { - String msg = "Getting the serviceID failed"; - log.error(msg, e); - throw new SQLException(msg, e); - } finally { - rs.close(); - stmtCon.close(); - } - return stateDetailList; - } - - /** - * Gets the list of all the service state. - * - * @return list of ServiceStateInfoBean. - * @throws Exception, if the retrieval of the list of service state infobean failed. - */ - public static List<ServiceStateInfoBean> getAllServiceState() throws Exception { - List<ServiceStateInfoBean> serviceStateInfoBeanList = new ArrayList<ServiceStateInfoBean>(); - for (int serviceID = 1; serviceID <= serviceList.size(); serviceID++) { - serviceStateInfoBeanList.add(getServiceState(serviceID)); - } - return serviceStateInfoBeanList; - } -} - - http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/services/HealthMonitorService.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/services/HealthMonitorService.java b/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/services/HealthMonitorService.java deleted file mode 100644 index f04ec4d..0000000 --- a/components/org.apache.stratos.status.monitor/src/main/java/org/apache/stratos/status/monitor/services/HealthMonitorService.java +++ /dev/null @@ -1,68 +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.status.monitor.services; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.core.AbstractAdmin; -import org.apache.stratos.status.monitor.beans.ServiceStateDetailInfoBean; -import org.apache.stratos.status.monitor.beans.ServiceStateInfoBean; -import org.apache.stratos.status.monitor.core.jdbc.MySQLConnectionInitializer; -import org.apache.stratos.status.monitor.internal.core.MySQLConnector; - -import java.util.List; - -/** - * This is the admin Web service which is used for health monitoring of the services - */ -public class HealthMonitorService extends AbstractAdmin { - private static final Log log = LogFactory.getLog( - HealthMonitorService.class); - - /** - * Get the status of all the services - * - * @return serviceStateInfoBean[] - * @throws Exception if failed to get Tenant Manager - */ - public ServiceStateInfoBean[] getAllServiceStatus() throws Exception { - List<ServiceStateInfoBean> serviceStatusList = MySQLConnector.getAllServiceState(); - return serviceStatusList.toArray(new ServiceStateInfoBean[serviceStatusList.size()]); - } - - /** - * Get the status of a specific service - * - * @param ServiceName: String - * @return ServiceInfoBean: Service Information - * @throws Exception, if the retrieval of the service status failed. - */ - public ServiceStateInfoBean getServiceStatus(String ServiceName) throws Exception { - int serviceID = MySQLConnectionInitializer.getServiceID(ServiceName); - return MySQLConnector.getServiceState(serviceID); - } - - public ServiceStateDetailInfoBean[] getAllServiceStateDetail() throws Exception { - List<ServiceStateDetailInfoBean> serviceStatusDetailList = - MySQLConnector.getAllServiceStateDetail(); - return serviceStatusDetailList.toArray( - new ServiceStateDetailInfoBean[serviceStatusDetailList.size()]); - } -} - http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor/src/main/resources/META-INF/component.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.status.monitor/src/main/resources/META-INF/component.xml deleted file mode 100755 index e396e5b..0000000 --- a/components/org.apache.stratos.status.monitor/src/main/resources/META-INF/component.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<component xmlns="http://products.wso2.org/carbon"> - <ManagementPermissions> - <ManagementPermission> - <DisplayName>Manage</DisplayName> - <ResourceId>/permission/protected/manage</ResourceId> - </ManagementPermission> - <ManagementPermission> - <DisplayName>Monitor</DisplayName> - <ResourceId>/permission/protected/manage/monitor</ResourceId> - </ManagementPermission> - <ManagementPermission> - <DisplayName>Tenants</DisplayName> - <ResourceId>/permission/protected/manage/monitor/tenants</ResourceId> - </ManagementPermission> - <ManagementPermission> - <DisplayName>Modify</DisplayName> - <ResourceId>/permission/protected/manage/modify</ResourceId> - </ManagementPermission> - <ManagementPermission> - <DisplayName>Tenants</DisplayName> - <ResourceId>/permission/protected/manage/modify/tenants</ResourceId> - </ManagementPermission> - </ManagementPermissions> -</component> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.status.monitor/src/main/resources/META-INF/services.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.status.monitor/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.status.monitor/src/main/resources/META-INF/services.xml deleted file mode 100755 index 132648a..0000000 --- a/components/org.apache.stratos.status.monitor/src/main/resources/META-INF/services.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> -<serviceGroup> - - <service name="HealthMonitorService" scope="transportsession"> - <transports> - <transport>https</transport> - </transports> - <parameter name="ServiceClass" locked="false"> - org.apache.stratos.status.monitor.services.HealthMonitorService - </parameter> - <operation name="getServiceStatus"> - </operation> - <operation name="getAllServiceStatus"> - </operation> - <parameter name="hiddenService" locked="true">true</parameter> - <parameter name="adminService" locked="true">true</parameter> - </service> -</serviceGroup> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.dispatcher/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.dispatcher/pom.xml b/components/org.apache.stratos.tenant.dispatcher/pom.xml deleted file mode 100644 index ad7a8de..0000000 --- a/components/org.apache.stratos.tenant.dispatcher/pom.xml +++ /dev/null @@ -1,90 +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. - --> -<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>4.1.0-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.tenant.dispatcher</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Tenant Dispatcher</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.apache.stratos.tenant.dispatcher.*, - </Private-Package> - <Export-Package> - !org.apache.stratos.tenant.dispatcher.internal.*, - org.apache.stratos.tenant.dispatcher.* - </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>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.utils</artifactId> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.core</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.dispatcher/src/main/java/org/apache/stratos/tenant/dispatcher/MultitenantDispatcher.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.dispatcher/src/main/java/org/apache/stratos/tenant/dispatcher/MultitenantDispatcher.java b/components/org.apache.stratos.tenant.dispatcher/src/main/java/org/apache/stratos/tenant/dispatcher/MultitenantDispatcher.java deleted file mode 100644 index beed246..0000000 --- a/components/org.apache.stratos.tenant.dispatcher/src/main/java/org/apache/stratos/tenant/dispatcher/MultitenantDispatcher.java +++ /dev/null @@ -1,68 +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.tenant.dispatcher; - -import org.apache.axis2.AxisFault; -import org.apache.axis2.context.MessageContext; -import org.apache.axis2.description.AxisOperation; -import org.apache.axis2.description.AxisService; -import org.apache.axis2.description.HandlerDescription; -import org.apache.axis2.engine.AbstractDispatcher; -import org.apache.axis2.engine.AxisConfiguration; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import javax.xml.namespace.QName; - -/** - * If none of the dispatcher were able to find an Axis2 service or operation, this dispatcher will - * be reached, and it will dispatch to the MultitenantService, which is associated with the - * {@link org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver} - */ -public class MultitenantDispatcher extends AbstractDispatcher { - - public static final String NAME = "MultitenantDispatcher"; - - public void initDispatcher() { - QName qn = new QName("http://wso2.org/projects/carbon", NAME); - HandlerDescription hd = new HandlerDescription(qn.getLocalPart()); - super.init(hd); - } - - public AxisService findService(MessageContext mc) throws AxisFault { - AxisService service = mc.getAxisService(); - if (service == null) { - String to = mc.getTo().getAddress(); - - int tenantDelimiterIndex = to.indexOf("/t/"); - if (tenantDelimiterIndex != -1) { - AxisConfiguration ac = mc.getConfigurationContext().getAxisConfiguration(); - return ac.getService(MultitenantConstants.MULTITENANT_DISPATCHER_SERVICE); - } - } - return service; - } - - public AxisOperation findOperation(AxisService svc, MessageContext mc) throws AxisFault { - AxisOperation operation = mc.getAxisOperation(); - if (operation == null) { - return svc.getOperation(MultitenantConstants.MULTITENANT_DISPATCHER_OPERATION); - } - return operation; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.dispatcher/src/main/java/org/apache/stratos/tenant/dispatcher/internal/TenantDispatcherServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.dispatcher/src/main/java/org/apache/stratos/tenant/dispatcher/internal/TenantDispatcherServiceComponent.java b/components/org.apache.stratos.tenant.dispatcher/src/main/java/org/apache/stratos/tenant/dispatcher/internal/TenantDispatcherServiceComponent.java deleted file mode 100644 index 4d4b9cb..0000000 --- a/components/org.apache.stratos.tenant.dispatcher/src/main/java/org/apache/stratos/tenant/dispatcher/internal/TenantDispatcherServiceComponent.java +++ /dev/null @@ -1,146 +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.tenant.dispatcher.internal; - -import org.apache.axis2.AxisFault; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.description.AxisOperation; -import org.apache.axis2.description.AxisService; -import org.apache.axis2.description.AxisServiceGroup; -import org.apache.axis2.description.HandlerDescription; -import org.apache.axis2.description.InOutAxisOperation; -import org.apache.axis2.description.PhaseRule; -import org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher; -import org.apache.axis2.engine.AxisConfiguration; -import org.apache.axis2.engine.Handler; -import org.apache.axis2.engine.Phase; -import org.apache.axis2.phaseresolver.PhaseException; -import org.apache.axis2.phaseresolver.PhaseMetadata; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.core.multitenancy.MultitenantDispatcher; -import org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver; -import org.wso2.carbon.utils.ConfigurationContextService; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -import java.util.List; - -/** - * @scr.component - * name="org.apache.stratos.tenant.dispatcher.internal.TenantDispatcherServiceComponent" - * immediate="true" - * @scr.reference name="org.wso2.carbon.configurationContextService" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="1..1" policy="dynamic" - * bind="setConfigurationContext" - * unbind="unsetConfigurationContext" - */ -public class TenantDispatcherServiceComponent { - private Log log = LogFactory.getLog(TenantDispatcherServiceComponent.class); - - private ConfigurationContext configCtx; - - protected void activate(ComponentContext ctxt) { - try { - deployMultitenantService(configCtx.getAxisConfiguration()); - addDispatchers(configCtx.getAxisConfiguration()); - } catch (Throwable e) { - log.error("Failed to activate the TenantDispatcherServiceComponent", e); - } - } - - - private void deployMultitenantService(AxisConfiguration axisCfg) throws AxisFault { - AxisService service = new AxisService(MultitenantConstants.MULTITENANT_DISPATCHER_SERVICE); - AxisOperation operation = - new InOutAxisOperation(MultitenantConstants.MULTITENANT_DISPATCHER_OPERATION); - operation.setMessageReceiver(new MultitenantMessageReceiver()); - service.addOperation(operation); - AxisServiceGroup multitenantSvcGroup = new AxisServiceGroup(axisCfg); - multitenantSvcGroup.setServiceGroupName(MultitenantConstants.MULTITENANT_DISPATCHER_SERVICE); - multitenantSvcGroup.addParameter(CarbonConstants.HIDDEN_SERVICE_PARAM_NAME, "true"); - multitenantSvcGroup.addService(service); - axisCfg.addServiceGroup(multitenantSvcGroup); - if(log.isDebugEnabled()){ - log.debug("Deployed " + MultitenantConstants.MULTITENANT_DISPATCHER_SERVICE); - } - } - - /** - * Add the MultitenantDispatcher to the inFlow phase. - * - * @param mainAxisConfig super-tenant AxisConfiguration - * @throws org.apache.axis2.AxisFault if an error occurs while adding the dispatcher - */ - private void addDispatchers(AxisConfiguration mainAxisConfig) throws AxisFault { - HandlerDescription handlerDescription = new HandlerDescription(MultitenantDispatcher.NAME); - PhaseRule rule = new PhaseRule(PhaseMetadata.PHASE_DISPATCH); - rule.setAfter(HTTPLocationBasedDispatcher.NAME); - rule.setBefore("SynapseDispatcher"); - handlerDescription.setRules(rule); - - MultitenantDispatcher multitenantDispatcher = new MultitenantDispatcher(); - multitenantDispatcher.initDispatcher(); - handlerDescription.setHandler(multitenantDispatcher); - - List<Phase> inflowPhases - = mainAxisConfig.getInFlowPhases(); - for (Phase inPhase : inflowPhases) { - // we are interested about the Dispatch phase in the inflow - if (PhaseMetadata.PHASE_DISPATCH.equals(inPhase.getPhaseName())) { - boolean handlerFound = false; - for (Handler handler : inPhase.getHandlers()) { - if (handler.getHandlerDesc().getName() != null && - handler.getHandlerDesc().getName().equals(MultitenantDispatcher.NAME)) { - handlerFound = true; - } - } - if (!handlerFound) { - try { - inPhase.addHandler(handlerDescription); - } catch (PhaseException e) { - String msg = "Couldn't start Carbon, Cannot add " + - "the required Carbon handlers"; - log.fatal(msg, e); - throw new AxisFault(msg); - } - } - } - } - if (log.isDebugEnabled()) { - log.info("Added multitenant dispatchers"); - } - } - - protected void deactivate(ComponentContext ctxt) { - if (log.isDebugEnabled()) { - log.debug("Deactivated TenantDispatcherServiceComponent"); - } - } - - protected void setConfigurationContext(ConfigurationContextService configCtx) { - this.configCtx = configCtx.getServerConfigContext(); - } - - protected void unsetConfigurationContext(ConfigurationContextService configCtx) { - this.configCtx = null; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.core/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.core/pom.xml b/components/org.apache.stratos.tenant.mgt.core/pom.xml deleted file mode 100644 index 018f633..0000000 --- a/components/org.apache.stratos.tenant.mgt.core/pom.xml +++ /dev/null @@ -1,86 +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. - --> -<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>4.1.0-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>org.apache.stratos.tenant.mgt.core</artifactId> - <packaging>bundle</packaging> - <name>Apache Stratos - Tenant Managment Core</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.apache.stratos.tenant.mgt.core.internal.*;-split-package:=merge-last, - </Private-Package> - <Import-Package> - org.apache.stratos.common.*, - org.wso2.carbon.registry.core.*, - !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> - <Export-Package> - org.apache.stratos.tenant.mgt.core.*, - </Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.core</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.wso2.carbon</groupId> - <artifactId>org.wso2.carbon.registry.core</artifactId> - <version>${wso2carbon.version}</version> - </dependency> - <dependency> - <groupId>org.apache.stratos</groupId> - <artifactId>org.apache.stratos.common</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/TenantPersistor.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/TenantPersistor.java b/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/TenantPersistor.java deleted file mode 100644 index 86d7e41..0000000 --- a/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/TenantPersistor.java +++ /dev/null @@ -1,347 +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.tenant.mgt.core; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.CarbonConstants; -import org.wso2.carbon.registry.core.RegistryConstants; -import org.wso2.carbon.registry.core.Resource; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.session.UserRegistry; -import org.apache.stratos.common.config.CloudServiceConfigParser; -import org.apache.stratos.common.config.CloudServicesDescConfig; -import org.apache.stratos.common.constants.StratosConstants; -import org.apache.stratos.common.util.CloudServicesUtil; -import org.apache.stratos.common.util.CommonUtil; -import org.apache.stratos.tenant.mgt.core.internal.TenantMgtCoreServiceComponent; -import org.apache.stratos.tenant.mgt.core.util.TenantCoreUtil; -import org.wso2.carbon.user.api.RealmConfiguration; -import org.wso2.carbon.user.api.TenantMgtConfiguration; -import org.wso2.carbon.user.core.*; -import org.wso2.carbon.user.core.config.multitenancy.MultiTenantRealmConfigBuilder; -import org.wso2.carbon.user.core.service.RealmService; -import org.wso2.carbon.user.core.tenant.Tenant; -import org.wso2.carbon.user.core.tenant.TenantManager; -import org.wso2.carbon.user.mgt.UserMgtConstants; -import org.wso2.carbon.utils.multitenancy.MultitenantConstants; - -/** - * TenantPersistenceManager - Methods related to persisting the tenant. - */ -public class TenantPersistor { - - private static final Log log = LogFactory.getLog(TenantPersistor.class); - private static final String ILLEGAL_CHARACTERS_FOR_PATH = ".*[~!#$;%^*()+={}\\[\\]\\|\\\\<>].*"; - - private static CloudServicesDescConfig cloudServicesDesc = null; - - - /** - * Persists the given tenant - * @param tenant - tenant to be persisted - * @param checkDomainValidation - true, if domain is validated. - * @param successKey - successKey - * @param originatedService - The Service that the tenant registration was originated. - * @return tenant Id - the tenant id - * @throws Exception, if persisting tenant failed. - */ - public int persistTenant(Tenant tenant, boolean checkDomainValidation, String successKey, - String originatedService,boolean isSkeleton) throws Exception { - int tenantId = 0; - if(!isSkeleton){ - tenantId=persistTenantInUserStore(tenant,checkDomainValidation,successKey); - }else { - tenantId=tenant.getId(); - } - - try { - doPostTenantCreationActions(tenant, originatedService); - } catch (Exception e) { - String msg = "Error performing post tenant creation actions"; - throw new Exception(msg, e); - } - - return tenantId; - } - - private int persistTenantInUserStore(Tenant tenant, boolean checkDomainValidation, String successKey) throws Exception { - int tenantId; - validateAdminUserName(tenant); - String tenantDomain = tenant.getDomain(); - - boolean isDomainAvailable = CommonUtil.isDomainNameAvailable(tenantDomain); - if (!isDomainAvailable) { - throw new Exception("Domain is not available to register"); - } - - RealmService realmService = TenantMgtCoreServiceComponent.getRealmService(); - RealmConfiguration realmConfig = realmService.getBootstrapRealmConfiguration(); - TenantMgtConfiguration tenantMgtConfiguration = realmService.getTenantMgtConfiguration(); - MultiTenantRealmConfigBuilder builder = TenantMgtCoreServiceComponent. - getRealmService().getMultiTenantRealmConfigBuilder(); - RealmConfiguration realmConfigToPersist = - builder.getRealmConfigForTenantToPersist(realmConfig, tenantMgtConfiguration, - tenant, -1); - tenant.setRealmConfig(realmConfigToPersist); - tenantId = addTenant(tenant); - tenant.setId(tenantId); - - if (checkDomainValidation) { - if (successKey != null) { - if (CommonUtil.validateDomainFromSuccessKey(TenantMgtCoreServiceComponent. - getGovernanceSystemRegistry(MultitenantConstants.SUPER_TENANT_ID), - tenant.getDomain(), successKey)) { - storeDomainValidationFlagToRegistry(tenant); - } else { - String msg = "Failed to validate domain"; - throw new Exception(msg); - } - } - } else { - storeDomainValidationFlagToRegistry(tenant); - } - - updateTenantAdminPassword(tenant); - return tenantId; - } - - private void doPostTenantCreationActions(Tenant tenant, - String originatedService) throws Exception { - - TenantMgtCoreServiceComponent.getRegistryLoader().loadTenantRegistry(tenant.getId()); - copyUIPermissions(tenant.getId()); - - TenantCoreUtil.setOriginatedService(tenant.getId(), originatedService); - setActivationFlags(tenant.getId(), originatedService); - - TenantCoreUtil.initializeRegistry(tenant.getId()); - - } - - /** - * Store the domain validation flag in the registry if the domain has been - * validated. - * - * @param tenant - the tenant - * @throws RegistryException, if storing the domain validation flag failed. - */ - protected void storeDomainValidationFlagToRegistry(Tenant tenant) throws RegistryException { - - try { - String domainValidationPath = StratosConstants.TENANT_DOMAIN_VERIFICATION_FLAG_PATH + - RegistryConstants.PATH_SEPARATOR + tenant.getId(); - UserRegistry superTenantRegistry = TenantMgtCoreServiceComponent. - getGovernanceSystemRegistry(MultitenantConstants.SUPER_TENANT_ID); - Resource validationFlagR = superTenantRegistry.newResource(); - validationFlagR.setProperty(tenant.getDomain(), "true"); - superTenantRegistry.put(domainValidationPath, validationFlagR); - - } catch (RegistryException e) { - String msg = "Error in storing the domain validation flag to the registry"; - log.error(msg, e); - throw new RegistryException(msg, e); - } - if (log.isDebugEnabled()) { - log.debug("Domain Validation Flag is stored to the registry."); - } - } - - /** - * Adds a tenant to the tenant manager - * - * @param tenant - the tenant - * @return tenantId - the tenant id - * @throws Exception - UserStoreException - */ - private int addTenant(Tenant tenant) throws Exception { - int tenantId; - TenantManager tenantManager = TenantMgtCoreServiceComponent.getTenantManager(); - try { - tenantId = tenantManager.addTenant(tenant); - if (log.isDebugEnabled()) { - log.debug("Tenant is successfully added: " + tenant.getDomain()); - } - } catch (UserStoreException e) { - String msg = "Error in adding tenant with domain: " + tenant.getDomain(); - log.error(msg, e); - throw new Exception(msg, e); - } - return tenantId; - } - - /** - * Sets the password for the tenant - * - * @param tenant - the tenant - * @throws Exception - UserStoreException - */ - private void updateTenantAdminPassword(Tenant tenant) throws Exception { - RealmService realmService = TenantMgtCoreServiceComponent.getRealmService(); - UserRealm userRealm; - try { - userRealm = (UserRealm) realmService.getTenantUserRealm(tenant.getId()); - } catch (UserStoreException e) { - String msg = "Error in creating Realm for tenant: " + tenant.getDomain(); - throw new Exception(msg, e); - } - try { - UserStoreManager userStoreManager = userRealm.getUserStoreManager(); - if (!userStoreManager.isReadOnly()) { - userStoreManager.updateCredentialByAdmin(tenant.getAdminName(), - tenant.getAdminPassword()); - if (log.isDebugEnabled()) { - log.debug("Successfully set the password for the tenant."); - } - } - } catch (UserStoreException e) { - String msg = "Error in changing the tenant admin password for tenant domain: " + - tenant.getDomain() + "."; - log.error(msg, e); - throw new Exception(msg, e); - } - } - - /** - * Authorize the role - * - * @param tenantId - tenant id - * @throws Exception - UserStoreException - */ - protected void copyUIPermissions(int tenantId) throws Exception { - try { - UserRealm realm = (UserRealm) TenantMgtCoreServiceComponent. - getRealmService().getTenantUserRealm(tenantId); - String adminRole = realm.getRealmConfiguration().getAdminRoleName(); - AuthorizationManager authMan = realm.getAuthorizationManager(); - // Authorize the admin role, if not authorized yet. - if (!authMan.isRoleAuthorized(adminRole, - CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION, - UserMgtConstants.EXECUTE_ACTION)) { - authMan.authorizeRole(adminRole, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION, - UserMgtConstants.EXECUTE_ACTION); - } - } catch (UserStoreException e) { - String msg = "Error in authorizing the admin role."; - log.error(msg, e); - throw new Exception(msg, e); - } - if (log.isDebugEnabled()) { - log.debug("Role has successfully been authorized."); - } - } - - protected void setActivationFlags(int tenantId, String originalService) throws Exception { - - boolean useDefaultConfig = true; - try { - - if(cloudServicesDesc == null ) { - cloudServicesDesc = CloudServiceConfigParser.loadCloudServicesConfiguration(); - } - - if (originalService != null && - !originalService.equals(StratosConstants.CLOUD_MANAGER_SERVICE) ) { - CloudServicesUtil.activateOriginalAndCompulsoryServices(cloudServicesDesc, - originalService, tenantId); - useDefaultConfig = false; - } - - if (useDefaultConfig) { - CloudServicesUtil.activateAllServices(cloudServicesDesc, tenantId); - } - } catch (Exception e) { - log.error("Error registering the originated service", e); - throw e; - } - - } - - /** - * Validates that the chosen AdminUserName is valid. - * - * @param tenant - * tenant information - * @throws Exception - * UserStoreException - */ - private void validateAdminUserName(Tenant tenant) throws Exception { - UserRealm superTenantUserRealm = - TenantMgtCoreServiceComponent.getRealmService(). - getBootstrapRealm(); - RealmConfiguration realmConfig = TenantMgtCoreServiceComponent. - getBootstrapRealmConfiguration(); - String uniqueAcrossTenants = realmConfig.getUserStoreProperty( - UserCoreConstants.RealmConfig.PROPERTY_USERNAME_UNIQUE); - if ("true".equals(uniqueAcrossTenants)) { - try { - if (superTenantUserRealm.getUserStoreManager().isExistingUser( - tenant.getAdminName())) { - throw new Exception("User name : " + tenant.getAdminName() + - " exists in the system. " + - "Please pick another user name for tenant Administrator."); - } - } catch (UserStoreException e) { - String msg = "Error in checking whether the user already exists in the system"; - log.error(msg, e); - throw new Exception(msg, e); - } - } - if (tenant.getAdminName().matches(TenantPersistor.ILLEGAL_CHARACTERS_FOR_PATH)) { - String msg = "The tenant admin ' " + tenant.getAdminName() + - " ' contains one or more illegal characters" + - " (~!@#$;%^*()+={}[]|\\<>)"; - log.error(msg); - throw new Exception(msg); - } - if (log.isDebugEnabled()) { - log.debug("Admin User Name has been validated."); - } - } - - /** - * Persists the given tenant - * @param tenant - tenant to be persisted - * @return tenant Id - * @throws Exception, if persisting tenant failed. - */ - public int persistTenant(Tenant tenant) throws Exception { - String tenantDomain = tenant.getDomain(); - int tenantId; - validateAdminUserName(tenant); - boolean isDomainAvailable = CommonUtil.isDomainNameAvailable(tenantDomain); - if (!isDomainAvailable) { - throw new Exception("Domain is not available to register"); - } - - tenantId = addTenant(tenant); - tenant.setId(tenantId); - - try { - doPostTenantCreationActions(tenant, null); - } catch (Exception e) { - String msg = "Error performing post tenant creation actions"; - if(log.isDebugEnabled()) { - log.debug(msg, e); - } - throw new Exception(msg); - } - return tenantId; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/ee5e9639/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/internal/TenantMgtCoreServiceComponent.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/internal/TenantMgtCoreServiceComponent.java b/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/internal/TenantMgtCoreServiceComponent.java deleted file mode 100644 index 8ab917d..0000000 --- a/components/org.apache.stratos.tenant.mgt.core/src/main/java/org/apache/stratos/tenant/mgt/core/internal/TenantMgtCoreServiceComponent.java +++ /dev/null @@ -1,125 +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.tenant.mgt.core.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.wso2.carbon.registry.core.service.RegistryService; -import org.wso2.carbon.registry.core.service.TenantRegistryLoader; -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; - -/** - * @scr.component name="org.apache.stratos.tenant.mgt.core" 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="tenant.registryloader" - * interface="org.wso2.carbon.registry.core.service.TenantRegistryLoader" - * cardinality="1..1" policy="dynamic" bind="setTenantRegistryLoader" - * unbind="unsetTenantRegistryLoader" - */ -public class TenantMgtCoreServiceComponent { - private static Log log = LogFactory.getLog(TenantMgtCoreServiceComponent.class); - - private static BundleContext bundleContext; - private static RealmService realmService; - private static RegistryService registryService; - private static TenantRegistryLoader registryLoader; - - protected void activate(ComponentContext context) { - try { - bundleContext = context.getBundleContext(); - log.debug("******* Tenant Core bundle is activated ******* "); - } catch (Exception e) { - log.error("Error occurred while activating tenant.mgt.core bundle. " + e); - } - } - - protected void setTenantRegistryLoader(TenantRegistryLoader tenantRegLoader) { - TenantMgtCoreServiceComponent.registryLoader = tenantRegLoader; - } - - protected void unsetTenantRegistryLoader(TenantRegistryLoader tenantRegLoader) { - TenantMgtCoreServiceComponent.registryLoader = null; - } - - protected void deactivate(ComponentContext context) { - log.debug("******* Tenant Core bundle is deactivated ******* "); - } - - protected void setRegistryService(RegistryService registryService) { - TenantMgtCoreServiceComponent.registryService = registryService; - } - - protected void unsetRegistryService(RegistryService registryService) { - setRegistryService(null); - } - - protected void setRealmService(RealmService realmService) { - TenantMgtCoreServiceComponent.realmService = realmService; - } - - protected void unsetRealmService(RealmService realmService) { - setRealmService(null); - } - - public static BundleContext getBundleContext() { - return bundleContext; - } - - public static RegistryService getRegistryService() { - return registryService; - } - - - 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); - } - - public static UserRegistry getConfigSystemRegistry(int tenantId) throws RegistryException { - return registryService.getConfigSystemRegistry(tenantId); - } - - public static TenantRegistryLoader getRegistryLoader() { - return registryLoader; - } -}