From 60e98f12b2009502f4c678c17a86a186c1db6d39 Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Fri, 13 Feb 2015 19:46:08 +0530 Subject: [PATCH] Adding the bundle activator for PIP --- .../pom.xml | 1 + ...PolicyInformationPointBundleActivator.java | 66 +++++++++++++++++++ .../PolicyManagementServiceComponent.java | 22 ++++++- .../pom.xml | 21 ++++-- pom.xml | 7 +- 5 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/internal/PolicyInformationPointBundleActivator.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 79cb29e195..a0c41a2e6f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -37,6 +37,7 @@ ${carbon.device.mgt.version} Policy Information Point Bundle org.wso2.carbon.policy.information.point.internal + org.wso2.carbon.policy.information.point.internal.PolicyInformationPointBundleActivator org.wso2.carbon.policy.information.point.* diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/internal/PolicyInformationPointBundleActivator.java b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/internal/PolicyInformationPointBundleActivator.java new file mode 100644 index 0000000000..c25b2855db --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/internal/PolicyInformationPointBundleActivator.java @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2015 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.policy.information.point.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.wso2.carbon.policy.information.point.PolicyInformationServiceImpl; +import org.wso2.carbon.policy.mgt.common.PolicyInformationService; + +public class PolicyInformationPointBundleActivator implements BundleActivator { + + private ServiceRegistration pipServiceRegRef; + private static final Log log = LogFactory.getLog(PolicyInformationPointBundleActivator.class); + + @Override + public void start(BundleContext bundleContext) throws Exception { + try { + if (log.isDebugEnabled()) { + log.debug("Activating Policy information Point bundle."); + } + + pipServiceRegRef = bundleContext.registerService(PolicyInformationService.class.getName(), + new PolicyInformationServiceImpl(), null); + + if (log.isDebugEnabled()) { + log.debug("Policy information Point bundle is activated."); + } + + } catch (Exception ex) { + log.error("Error occurred while activating the Policy Information Point bundle.", ex); + } + + } + + @Override + public void stop(BundleContext bundleContext) throws Exception { + try { + if (log.isDebugEnabled()) { + log.debug("Policy information Point bundle is deactivated."); + } + pipServiceRegRef.unregister(); + } catch (Exception ex) { + log.error("Error occurred while de-activating the Policy Information Point bundle.", ex); + } + + } +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java index 573cdc4797..16255d95dc 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java @@ -21,6 +21,7 @@ package org.wso2.carbon.policy.mgt.core.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.policy.mgt.common.PolicyInformationService; import org.wso2.carbon.policy.mgt.core.config.PolicyConfigurationManager; import org.wso2.carbon.policy.mgt.core.config.PolicyManagementConfig; import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; @@ -28,13 +29,19 @@ import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; import org.wso2.carbon.user.core.service.RealmService; /** - * @scr.component name="org.wso2.carbon.policy.manager" immediate="true" + * @scr.component name="org.wso2.carbon.devicemgt.policy.manager" immediate="true" * @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="org.wso2.carbon.devicemgt.policy.information.point.default" + * interface="org.wso2.carbon.policy.mgt.common.PolicyInformationService" + * cardinality="1..1" + * policy="dynamic" + * bind="setPIPService" + * unbind="unsetPIPService" */ public class PolicyManagementServiceComponent { @@ -81,4 +88,17 @@ public class PolicyManagementServiceComponent { PolicyManagementDataHolder.getInstance().setRealmService(null); } + + protected void setPIPService(PolicyInformationService policyInformationService) { + if (log.isDebugEnabled()) { + log.debug("Setting Policy Information Service"); + } + } + + protected void unsetPIPService(PolicyInformationService policyInformationService) { + if (log.isDebugEnabled()) { + log.debug("Unsetting Policy Information Service"); + } + } + } diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index a13e7f0ccd..903a0a5630 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -18,7 +18,8 @@ ~ under the License. --> - + org.wso2.carbon.devicemgt @@ -47,7 +48,11 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.policy.evaluator + org.wso2.carbon.complex.policy.decision.point + + + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.information.point @@ -99,11 +104,17 @@ - org.wso2.carbon.devicemgt:org.wso2.carbon.policy.mgt.core:${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt:org.wso2.carbon.policy.mgt.core:${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt:org.wso2.carbon.policy.mgt.common:${carbon.device.mgt.version} - org.wso2.carbon.devicemgt:org.wso2.carbon.policy.mgt.common:${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt:org.wso2.carbon.complex.policy.decision.point:${carbon.device.mgt.version} - org.wso2.carbon.devicemgt:org.wso2.carbon.policy.evaluator:${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt:org.wso2.carbon.policy.information.point:${carbon.device.mgt.version} diff --git a/pom.xml b/pom.xml index 8ae2f0e636..ee307fb047 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,12 @@ org.wso2.carbon.devicemgt - org.wso2.carbon.policy.evaluator + org.wso2.carbon.complex.policy.decision.point + ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + org.wso2.carbon.policy.information.point ${carbon.device.mgt.version}