Fix osgi reference addings in Service components

remotes/1725333865317989910/master
Pasindu Rupasinghe 9 months ago
parent 67975ea5f8
commit d938195373

@ -27,19 +27,14 @@ import org.wso2.carbon.apimgt.integration.client.configs.APIMConfigReader;
import org.wso2.carbon.apimgt.integration.client.service.IntegrationClientService;
import io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService;
/**
* @scr.component name="org.wso2.carbon.api.integration.client" immediate="true"
* @scr.reference name="api.integration.client.service"
* interface="io.entgra.device.mgt.core.identity.jwt.client.extension.service.JWTClientManagerService"
* cardinality="1..1"
* policy="dynamic"
* bind="setJWTClientManagerService"
* unbind="unsetJWTClientManagerService"
*/
@Component(
name = "org.wso2.carbon.api.integration.client",
immediate = true)
public class APIIntegrationClientServiceComponent {
private static Log log = LogFactory.getLog(APIIntegrationClientServiceComponent.class);
@Activate
protected void activate(ComponentContext componentContext) {
try {
if (log.isDebugEnabled()) {
@ -59,10 +54,18 @@ public class APIIntegrationClientServiceComponent {
}
}
@Deactivate
protected void deactivate(ComponentContext componentContext) {
//do nothing
}
@Reference(
name = "api.integration.client.service",
service = org.wso2.carbon.apimgt.impl.APIManagerConfigurationService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setJWTClientManagerService",
unbind = "unsetJWTClientManagerService")
protected void setJWTClientManagerService(JWTClientManagerService jwtClientManagerService) {
if (jwtClientManagerService != null) {
log.debug("jwtClientManagerService service is initialized");

@ -29,34 +29,17 @@ import io.entgra.device.mgt.core.cea.mgt.core.task.CEAPolicyMonitoringTaskManage
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.*;
import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.ntask.core.service.TaskService;
/**
* @scr.component name="io.entgra.device.mgt.core.cea.mgt.core.CEAManagementServiceComponent" immediate="true"
* @scr.reference name="org.wso2.carbon.ndatasource"
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDataSourceService"
* unbind="unsetDataSourceService"
* @scr.reference name="io.entgra.device.mgt.core.cea.mgt.enforcementServiceManager"
* interface="io.entgra.device.mgt.core.cea.mgt.common.service.EnforcementServiceManager"
* cardinality="1..1"
* policy="dynamic"
* bind="setEnforcementServiceManager"
* unbind="unsetEnforcementServiceManager"
* @scr.reference name="ntask.component"
* interface="org.wso2.carbon.ntask.core.service.TaskService"
* cardinality="1..1"
* policy="dynamic"
* bind="setTaskService"
* unbind="unsetTaskService"
*/
@Component(
name = "io.entgra.device.mgt.core.cea.mgt.core.CEAManagementServiceComponent",
immediate = true)
public class CEAManagementServiceComponent {
private static final Log log = LogFactory.getLog(CEAManagementServiceComponent.class);
@Activate
protected void activate(ComponentContext componentContext) {
try {
CEAConfigManager ceaConfigManager = CEAConfigManager.getInstance();
@ -72,6 +55,13 @@ public class CEAManagementServiceComponent {
}
}
@Reference(
name = "org.wso2.carbon.ndatasource",
service = org.wso2.carbon.ndatasource.core.DataSourceService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setDataSourceService",
unbind = "unsetDataSourceService")
protected void setDataSourceService(DataSourceService dataSourceService) {
// This is to avoid cea management component getting initialized before the underlying datasource registered
}
@ -80,6 +70,13 @@ public class CEAManagementServiceComponent {
// Do nothing
}
@Reference(
name = "io.entgra.device.mgt.core.cea.mgt.enforcementServiceManager",
service = io.entgra.device.mgt.core.cea.mgt.common.service.EnforcementServiceManager.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setEnforcementServiceManager",
unbind = "unsetEnforcementServiceManager")
protected void setEnforcementServiceManager(EnforcementServiceManager enforcementServiceManager) {
CEAManagementDataHolder.getInstance().setEnforcementServiceManager(enforcementServiceManager);
if (log.isDebugEnabled()) {
@ -94,6 +91,13 @@ public class CEAManagementServiceComponent {
}
}
@Reference(
name = "ntask.component",
service = org.wso2.carbon.ntask.core.service.TaskService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setTaskService",
unbind = "unsetTaskService")
protected void setTaskService(TaskService taskService) {
CEAManagementDataHolder.getInstance().setTaskService(taskService);
if (log.isDebugEnabled()) {

@ -25,27 +25,16 @@ import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProvide
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.*;
import org.wso2.carbon.user.core.service.RealmService;
/**
* @scr.component name="io.entgra.device.mgt.core.cea.mgt.enforcementServiceManager" immediate="true"
* @scr.reference name="org.wso2.carbon.device.manager"
* interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDeviceManagementServiceProviderService"
* unbind="unsetDeviceManagementServiceProviderService"
* @scr.reference name="user.realmservice.default"
* interface="org.wso2.carbon.user.core.service.RealmService"
* cardinality="1..1"
* policy="dynamic"
* bind="setRealmService"
* unbind="unsetRealmService"
*/
@Component(
name = "io.entgra.device.mgt.core.cea.mgt.enforcementServiceManager",
immediate = true)
public class EnforcementServiceComponent {
private static final Log log = LogFactory.getLog(EnforcementServiceComponent.class);
@Activate
protected void activate(ComponentContext componentContext) {
try {
EnforcementServiceManager enforcementServiceManager = new EnforcementServiceManagerImpl();
@ -60,6 +49,13 @@ public class EnforcementServiceComponent {
}
}
@Reference(
name = "org.wso2.carbon.device.manager",
service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setDeviceManagementServiceProviderService",
unbind = "unsetDeviceManagementServiceProviderService")
protected void setDeviceManagementServiceProviderService(DeviceManagementProviderService deviceManagementProviderService) {
EnforcementServiceComponentDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
if (log.isDebugEnabled()) {
@ -74,6 +70,13 @@ public class EnforcementServiceComponent {
}
}
@Reference(
name = "user.realmservice.default",
service = org.wso2.carbon.user.core.service.RealmService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setRealmService",
unbind = "unsetRealmService")
protected void setRealmService(RealmService realmService) {
EnforcementServiceComponentDataHolder.getInstance().setRealmService(realmService);
if (log.isDebugEnabled()) {

@ -95,6 +95,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.ds-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>

@ -31,28 +31,11 @@ import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.registry.core.service.RegistryService;
import org.osgi.service.component.annotations.*;
/**
* @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.device.organization.internal.DeviceOrganizationMgtServiceComponent" immediate="true"
* @scr.reference name="org.wso2.carbon.device.manager"
* interface="io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDeviceManagementService"
* unbind="unsetDeviceManagementService"
* @scr.reference name="org.wso2.carbon.ndatasource"
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDataSourceService"
* unbind="unsetDataSourceService"
* @scr.reference name="registry.service"
* interface="org.wso2.carbon.registry.core.service.RegistryService"
* cardinality="0..1"
* policy="dynamic"
* bind="setRegistryService"
* unbind="unsetRegistryService"
*/
@Component(
name = "io.entgra.device.mgt.core.device.mgt.extensions.device.organization.internal.DeviceOrganizationMgtServiceComponent",
immediate = true)
public class DeviceOrganizationMgtServiceComponent {
private static final Log log = LogFactory.getLog(DeviceOrganizationMgtServiceComponent.class);
@ -60,6 +43,7 @@ public class DeviceOrganizationMgtServiceComponent {
/**
* @param componentContext
*/
@Activate
protected void activate(ComponentContext componentContext) {
if (log.isDebugEnabled()) {
@ -87,6 +71,7 @@ public class DeviceOrganizationMgtServiceComponent {
/**
* @param componentContext
*/
@Deactivate
protected void deactivate(ComponentContext componentContext) {
if (log.isDebugEnabled()) {
log.debug("De-activating Device Organization Management Service Component");
@ -94,6 +79,13 @@ public class DeviceOrganizationMgtServiceComponent {
}
@SuppressWarnings("unused")
@Reference(
name = "org.wso2.carbon.device.manager",
service = io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setDeviceManagementService",
unbind = "unsetDeviceManagementService")
protected void setDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) {
if (log.isDebugEnabled()) {
log.debug("Setting Device Management Service to Device Organization Mgt SC");
@ -112,6 +104,14 @@ public class DeviceOrganizationMgtServiceComponent {
/**
* @param dataSourceService
*/
@Reference(
name = "org.wso2.carbon.ndatasource",
service = org.wso2.carbon.ndatasource.core.DataSourceService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setDataSourceService",
unbind = "unsetDataSourceService")
protected void setDataSourceService(DataSourceService dataSourceService) {
if (log.isDebugEnabled()) {
log.debug("Data source service set to Device Organization Mgt component");
@ -128,7 +128,13 @@ public class DeviceOrganizationMgtServiceComponent {
}
}
@Reference(
name = "registry.service",
service = org.wso2.carbon.registry.core.service.RegistryService.class,
cardinality = ReferenceCardinality.OPTIONAL,
policy = ReferencePolicy.DYNAMIC,
bind = "setRegistryService",
unbind = "unsetRegistryService")
protected void setRegistryService(RegistryService registryService) {
if (log.isDebugEnabled()) {
log.debug("RegistryService set to Device Organization Mgt component");
@ -143,5 +149,4 @@ public class DeviceOrganizationMgtServiceComponent {
DeviceOrganizationMgtDataHolder.getInstance().setRegistryService(null);
}
}

@ -25,36 +25,19 @@ 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.osgi.service.component.annotations.*;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.ConfigurationContextService;
/**
* @scr.component name="io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal.UserStoreRoleMappingServiceComponent"
* 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="config.context.service"
* interface="org.wso2.carbon.utils.ConfigurationContextService"
* cardinality="0..1"
* policy="dynamic"
* bind="setConfigurationContextService"
* unbind="unsetConfigurationContextService"
* @scr.reference name="entgra.heart.beat.service"
* interface="io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService"
* cardinality="0..1"
* policy="dynamic"
* bind="setHeartBeatService"
* unbind="unsetHeartBeatService"
*/
@Component(
name = "io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper.internal.UserStoreRoleMappingServiceComponent",
immediate = true)
public class UserStoreRoleMappingServiceComponent {
private static final Log log = LogFactory.getLog(UserStoreRoleMappingServiceComponent.class);
@Activate
protected void activate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("Activating Role Management Service Component");
@ -72,12 +55,19 @@ public class UserStoreRoleMappingServiceComponent {
}
}
@Deactivate
protected void deactivate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("De-activating Role Manager Service Component");
}
}
@Reference(
name = "user.realmservice.default",
service = org.wso2.carbon.user.core.service.RealmService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetRealmService")
protected void setConfigurationContextService(ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Setting ConfigurationContextService");
@ -86,6 +76,12 @@ public class UserStoreRoleMappingServiceComponent {
UserStoreRoleMappingDataHolder.getInstance().setConfigurationContextService(configurationContextService);
}
@Reference(
name = "config.context.service",
service = org.wso2.carbon.utils.ConfigurationContextService.class,
cardinality = ReferenceCardinality.OPTIONAL,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetConfigurationContextService")
protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Un-setting ConfigurationContextService");
@ -118,6 +114,12 @@ public class UserStoreRoleMappingServiceComponent {
}
@SuppressWarnings("unused")
@Reference(
name = "entgra.heart.beat.service",
service = io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService.class,
cardinality = ReferenceCardinality.OPTIONAL,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetHeartBeatService")
protected void setHeartBeatService(HeartBeatManagementService heartBeatService) {
if (log.isDebugEnabled()) {
log.debug("Setting heart beat service");

@ -27,10 +27,9 @@ import org.wso2.carbon.device.mgt.analytics.data.publisher.config.AnalyticsConfi
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherServiceImpl;
/**
* @scr.component name="org.wso2.carbon.device.mgt.analytics.data.publisher.internal.DataPublisherServiceComponent"
* immediate="true"
*/
@Component(
name = "org.wso2.carbon.device.mgt.analytics.data.publisher.internal.DataPublisherServiceComponent",
immediate = true)
public class DataPublisherServiceComponent {
private ServiceRegistration analyticsServiceRef;

@ -26,20 +26,15 @@ import org.wso2.carbon.core.services.authentication.CarbonServerAuthenticator;
import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticator;
import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService;
/**
* @scr.component name="org.wso2.carbon.identity.backend.oauth.authenticator" immediate="true"
* @scr.reference name="identity.oauth2.validation.service"
* interface="org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService"
* cardinality="1..1"
* policy="dynamic"
* bind="setOAuth2ValidationService"
* unbind="unsetOAuth2ValidationService"
*/
@Component(
name = "org.wso2.carbon.identity.backend.oauth.authenticator",
immediate = true)
public class OAuthAuthenticatorServiceComponent {
private static final Log log = LogFactory.getLog(OAuthAuthenticatorServiceComponent.class);
@SuppressWarnings("unused")
@Activate
protected void activate(ComponentContext componentContext) {
if (log.isDebugEnabled()) {
log.debug("Starting Backend OAuthAuthenticator Framework Bundle");
@ -47,6 +42,7 @@ public class OAuthAuthenticatorServiceComponent {
}
@SuppressWarnings("unused")
@Deactivate
protected void deactivate(ComponentContext componentContext) {
//do nothing
}
@ -57,6 +53,13 @@ public class OAuthAuthenticatorServiceComponent {
* @param tokenValidationService An instance of OAuth2TokenValidationService.
*/
@SuppressWarnings("unused")
@Reference(
name = "identity.oauth2.validation.service",
service = org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
bind = "setOAuth2ValidationService",
unbind = "unsetOAuth2ValidationService")
protected void setOAuth2ValidationService(OAuth2TokenValidationService tokenValidationService) {
if (log.isDebugEnabled()) {
log.debug("Setting OAuth2TokenValidationService Service");

Loading…
Cancel
Save