diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/pom.xml index e5da0d262c..9acdb49961 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/pom.xml @@ -51,11 +51,6 @@ javax.ws.rs-api provided - - org.springframework - spring-web - provided - org.wso2.carbon org.wso2.carbon.admin.advisory.mgt diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/AdminAdvisoryManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/AdminAdvisoryManagementServiceHolder.java index 0986b6b9f2..b80e14fa1a 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/AdminAdvisoryManagementServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/AdminAdvisoryManagementServiceHolder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-2024, WSO2 LLC. (http://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -19,34 +19,26 @@ package org.wso2.carbon.identity.api.server.admin.advisory.management.common; import org.wso2.carbon.admin.advisory.mgt.service.AdminAdvisoryManagementService; +import org.wso2.carbon.context.PrivilegedCarbonContext; /** * Service holder class for admin advisory management. */ public class AdminAdvisoryManagementServiceHolder { - private static AdminAdvisoryManagementService adminAdvisoryManagementService; + public AdminAdvisoryManagementServiceHolder() {} - /** - * Get admin advisory management service. - */ - public static AdminAdvisoryManagementService getAdminAdvisoryManagementService() { + private static class AdminAdvisoryServiceHolder { - return adminAdvisoryManagementService; + static final AdminAdvisoryManagementService SERVICE = (AdminAdvisoryManagementService) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(AdminAdvisoryManagementService.class, null); } /** - * Set admin advisory management service. - * - * @param adminAdvisoryManagementService the admin advisory management service + * Get admin advisory management service. */ - public static void setAdminAdvisoryManagementService - (AdminAdvisoryManagementService adminAdvisoryManagementService) { - - AdminAdvisoryManagementServiceHolder.adminAdvisoryManagementService = adminAdvisoryManagementService; - } - - private AdminAdvisoryManagementServiceHolder() { + public static AdminAdvisoryManagementService getAdminAdvisoryManagementService() { + return AdminAdvisoryServiceHolder.SERVICE; } } diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/factory/OSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/factory/OSGIServiceFactory.java deleted file mode 100644 index 12c37cccf0..0000000000 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/factory/OSGIServiceFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). - * - * WSO2 LLC. 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.identity.api.server.admin.advisory.management.common.factory; - -import org.springframework.beans.factory.config.AbstractFactoryBean; -import org.wso2.carbon.admin.advisory.mgt.service.AdminAdvisoryManagementService; -import org.wso2.carbon.context.PrivilegedCarbonContext; - -/** - * Factory Beans serve as a factory for creating other beans within the IOC container. This factory bean is used to - * instantiate the AdminAdvisoryManagementService type of object inside the container. - */ -public class OSGIServiceFactory extends AbstractFactoryBean { - - private AdminAdvisoryManagementService adminAdvisoryManagementService; - - @Override - public Class getObjectType() { - - return Object.class; - } - - @Override - protected AdminAdvisoryManagementService createInstance() throws Exception { - - if (this.adminAdvisoryManagementService == null) { - AdminAdvisoryManagementService taskOperationService = - (AdminAdvisoryManagementService) PrivilegedCarbonContext - .getThreadLocalCarbonContext() - .getOSGiService(AdminAdvisoryManagementService.class, null); - if (taskOperationService != null) { - this.adminAdvisoryManagementService = taskOperationService; - } else { - throw new Exception("Unable to retrieve AdminAdvisoryManagementService service."); - } - } - return this.adminAdvisoryManagementService; - } -} diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/pom.xml index 2d894a8b43..cee755ad80 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/pom.xml @@ -107,11 +107,6 @@ cxf-rt-rs-service-description provided - - org.springframework - spring-web - provided - javax.ws.rs javax.ws.rs-api diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/AdminAdvisoryManagementApi.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/AdminAdvisoryManagementApi.java index 340b530ae4..65685629ef 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/AdminAdvisoryManagementApi.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/AdminAdvisoryManagementApi.java @@ -22,8 +22,8 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; -import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.factories.AdminAdvisoryManagementApiServiceFactory; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.model.AdminAdvisoryConfig; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.model.Error; @@ -44,8 +44,12 @@ public class AdminAdvisoryManagementApi { - @Autowired - private AdminAdvisoryManagementApiService delegate; + private final AdminAdvisoryManagementApiService delegate; + + public AdminAdvisoryManagementApi() { + + this.delegate = AdminAdvisoryManagementApiServiceFactory.getAdminAdvisoryManagementApi(); + } @Valid @GET diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/AdminAdvisoryManagementApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/AdminAdvisoryManagementApiServiceFactory.java index b9c3de6c66..3dff7b4415 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/AdminAdvisoryManagementApiServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/gen/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/AdminAdvisoryManagementApiServiceFactory.java @@ -26,10 +26,16 @@ */ public class AdminAdvisoryManagementApiServiceFactory { - private static final AdminAdvisoryManagementApiService service = new AdminAdvisoryManagementApiServiceImpl(); + private static final AdminAdvisoryManagementApiService SERVICE = new AdminAdvisoryManagementApiServiceImpl(); + /** + * Get admin advisory management service. + * + * @return AdminAdvisoryManagementApiService + */ public static AdminAdvisoryManagementApiService getAdminAdvisoryManagementApi() { - return service; + + return SERVICE; } private AdminAdvisoryManagementApiServiceFactory() { diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/core/ServerAdminAdvisoryManagementService.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/core/ServerAdminAdvisoryManagementService.java index ae09572e39..8c50d54db7 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/core/ServerAdminAdvisoryManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/core/ServerAdminAdvisoryManagementService.java @@ -26,7 +26,6 @@ import org.wso2.carbon.admin.advisory.mgt.exception.AdminAdvisoryMgtException; import org.wso2.carbon.admin.advisory.mgt.service.AdminAdvisoryManagementService; import org.wso2.carbon.identity.api.server.admin.advisory.management.common.AdminAdvisoryConstants; -import org.wso2.carbon.identity.api.server.admin.advisory.management.common.AdminAdvisoryManagementServiceHolder; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.model.AdminAdvisoryConfig; import org.wso2.carbon.identity.api.server.common.error.APIError; import org.wso2.carbon.identity.api.server.common.error.ErrorResponse; @@ -38,8 +37,14 @@ */ public class ServerAdminAdvisoryManagementService { + private final AdminAdvisoryManagementService adminAdvisoryManagementService; private static final Log LOG = LogFactory.getLog(ServerAdminAdvisoryManagementService.class); + public ServerAdminAdvisoryManagementService(AdminAdvisoryManagementService adminAdvisoryManagementService) { + + this.adminAdvisoryManagementService = adminAdvisoryManagementService; + } + /** * Get admin advisory configuration. * @@ -48,8 +53,6 @@ public class ServerAdminAdvisoryManagementService { public AdminAdvisoryConfig getAdminAdvisoryConfig() { try { - AdminAdvisoryManagementService adminAdvisoryManagementService = AdminAdvisoryManagementServiceHolder - .getAdminAdvisoryManagementService(); AdminAdvisoryBannerDTO adminAdvisoryBannerDTO = adminAdvisoryManagementService.getAdminAdvisoryConfig(); return buildAdminAdvisoryConfigResponse(adminAdvisoryBannerDTO); @@ -70,8 +73,6 @@ public AdminAdvisoryConfig getAdminAdvisoryConfig() { public void saveAdminAdvisoryConfig(AdminAdvisoryConfig adminAdvisoryConfig) { try { - AdminAdvisoryManagementService adminAdvisoryManagementService = AdminAdvisoryManagementServiceHolder - .getAdminAdvisoryManagementService(); AdminAdvisoryBannerDTO modifiedAdminAdvisoryBannerDTO = createModifiedAdminAdvisoryBannerDTO( adminAdvisoryManagementService.getAdminAdvisoryConfig(), adminAdvisoryConfig); diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/ServerAdminAdvisoryManagementServiceFactory.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/ServerAdminAdvisoryManagementServiceFactory.java new file mode 100644 index 0000000000..ee8aeb4ad7 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/ServerAdminAdvisoryManagementServiceFactory.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. 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.identity.api.server.admin.advisory.management.v1.factories; + +import org.wso2.carbon.admin.advisory.mgt.service.AdminAdvisoryManagementService; +import org.wso2.carbon.identity.api.server.admin.advisory.management.common.AdminAdvisoryManagementServiceHolder; +import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.core.ServerAdminAdvisoryManagementService; + +/** + * Service factory class for admin advisory management API. + */ +public class ServerAdminAdvisoryManagementServiceFactory { + + private static final ServerAdminAdvisoryManagementService SERVICE; + + static { + AdminAdvisoryManagementService adminAdvisoryManagementService = AdminAdvisoryManagementServiceHolder + .getAdminAdvisoryManagementService(); + + if (adminAdvisoryManagementService == null) { + throw new IllegalStateException("AdminAdvisoryManagementService is not available from OSGi context."); + } + + SERVICE = new ServerAdminAdvisoryManagementService(adminAdvisoryManagementService); + } + + /** + * Get admin advisory management service. + * + * @return ServerAdminAdvisoryManagementService + */ + public static ServerAdminAdvisoryManagementService getServerAdminAdvisoryManagementService() { + + return SERVICE; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/impl/AdminAdvisoryManagementApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/impl/AdminAdvisoryManagementApiServiceImpl.java index ee7ee466c8..e79784edd3 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/impl/AdminAdvisoryManagementApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/impl/AdminAdvisoryManagementApiServiceImpl.java @@ -18,9 +18,9 @@ package org.wso2.carbon.identity.api.server.admin.advisory.management.v1.impl; -import org.springframework.beans.factory.annotation.Autowired; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.AdminAdvisoryManagementApiService; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.core.ServerAdminAdvisoryManagementService; +import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.factories.ServerAdminAdvisoryManagementServiceFactory; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.model.AdminAdvisoryConfig; import javax.ws.rs.core.Response; @@ -30,8 +30,17 @@ **/ public class AdminAdvisoryManagementApiServiceImpl implements AdminAdvisoryManagementApiService { - @Autowired - private ServerAdminAdvisoryManagementService adminAdvisoryManagementService; + private final ServerAdminAdvisoryManagementService adminAdvisoryManagementService; + + public AdminAdvisoryManagementApiServiceImpl() { + + try { + this.adminAdvisoryManagementService = ServerAdminAdvisoryManagementServiceFactory + .getServerAdminAdvisoryManagementService(); + } catch (Exception e) { + throw new RuntimeException("Error occurred while initiating admin advisory management service.", e); + } + } /** * Endpoint to get the admin advisory banner configuration. diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/resources/META-INF/cxf/admin-advisory-management-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/resources/META-INF/cxf/admin-advisory-management-server-v1-cxf.xml deleted file mode 100644 index c541681d44..0000000000 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/resources/META-INF/cxf/admin-advisory-management-server-v1-cxf.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - -