Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spring Cleanup] Remove Spring dependencies in API resource management API #686

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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
Expand Down Expand Up @@ -43,11 +43,6 @@
</build>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,6 +18,7 @@

package org.wso2.carbon.identity.api.server.api.resource.common;

import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.api.resource.collection.mgt.APIResourceCollectionManager;
import org.wso2.carbon.identity.api.resource.mgt.APIResourceManager;
import org.wso2.carbon.identity.oauth.OAuthAdminServiceImpl;
Expand All @@ -27,67 +28,53 @@
*/
public class APIResourceManagementServiceHolder {

private static APIResourceManager apiResourceManager;
private static APIResourceCollectionManager apiResourceCollectionManager;
private static OAuthAdminServiceImpl oAuthAdminServiceImpl;
private APIResourceManagementServiceHolder() {}

/**
* Get APIResourceManager osgi service.
*
* @return APIResourceManager.
*/
public static APIResourceManager getApiResourceManager() {
private static class APIResourceManagerHolder {

return apiResourceManager;
static final APIResourceManager SERVICE = (APIResourceManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(APIResourceManager.class, null);
}

/**
* Set APIResourceManager osgi service.
*
* @param apiResourceManager APIResourceManager.
*/
public static void setApiResourceManager(APIResourceManager apiResourceManager) {
private static class APIResourceCollectionManagerHolder {

APIResourceManagementServiceHolder.apiResourceManager = apiResourceManager;
static final APIResourceCollectionManager SERVICE = (APIResourceCollectionManager) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(APIResourceCollectionManager.class, null);
}

/**
* Get APIResourceCollectionManager osgi service.
*
* @return APIResourceCollectionManager.
*/
public static APIResourceCollectionManager getApiResourceCollectionManager() {
private static class OAuthAdminServiceImplHolder {

return apiResourceCollectionManager;
static final OAuthAdminServiceImpl SERVICE = (OAuthAdminServiceImpl) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(OAuthAdminServiceImpl.class, null);
}

/**
* Set APIResourceCollectionManager osgi service.
* Get APIResourceManager osgi service.
*
* @param apiResourceCollectionManager APIResourceCollectionManager.
* @return APIResourceManager.
*/
public static void setApiResourceCollectionManager(APIResourceCollectionManager apiResourceCollectionManager) {
public static APIResourceManager getApiResourceManager() {

APIResourceManagementServiceHolder.apiResourceCollectionManager = apiResourceCollectionManager;
return APIResourceManagerHolder.SERVICE;
}

/**
* Get OAuthAdminServiceImpl instance.
* Get APIResourceCollectionManager osgi service.
*
* @return OAuthAdminServiceImpl instance.
* @return APIResourceCollectionManager.
*/
public static OAuthAdminServiceImpl getOAuthAdminServiceImpl() {
public static APIResourceCollectionManager getApiResourceCollectionManager() {

return oAuthAdminServiceImpl;
return APIResourceCollectionManagerHolder.SERVICE;
}

/**
* Set OAuthAdminServiceImpl instance.
* Get OAuthAdminServiceImpl instance.
*
* @param oAuthAdminServiceImpl OAuthAdminServiceImpl instance.
* @return OAuthAdminServiceImpl instance.
*/
public static void setOAuthAdminServiceImpl(OAuthAdminServiceImpl oAuthAdminServiceImpl) {
public static OAuthAdminServiceImpl getOAuthAdminServiceImpl() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we having any use cases with this service(OAuthAdminServiceImpl)?


APIResourceManagementServiceHolder.oAuthAdminServiceImpl = oAuthAdminServiceImpl;
return OAuthAdminServiceImplHolder.SERVICE;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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
Expand Down Expand Up @@ -82,11 +82,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +18,6 @@

package org.wso2.carbon.identity.api.server.api.resource.v1;

import org.springframework.beans.factory.annotation.Autowired;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.io.InputStream;
Expand All @@ -38,6 +37,7 @@
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import io.swagger.annotations.*;
import org.wso2.carbon.identity.api.server.api.resource.v1.factories.ApiResourcesApiServiceFactory;

import javax.validation.constraints.*;

Expand All @@ -46,8 +46,12 @@

public class ApiResourcesApi {

@Autowired
private ApiResourcesApiService delegate;
private final ApiResourcesApiService delegate;

public ApiResourcesApi() {

this.delegate = ApiResourcesApiServiceFactory.getApiResourcesApi();
}

@Valid
@POST
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,7 +24,7 @@
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import org.springframework.beans.factory.annotation.Autowired;
import org.wso2.carbon.identity.api.server.api.resource.v1.factories.MetaApiServiceFactory;

import javax.validation.Valid;
import javax.ws.rs.GET;
Expand All @@ -39,8 +39,12 @@

public class MetaApi {

@Autowired
private MetaApiService delegate;
private final MetaApiService delegate;

public MetaApi() {

this.delegate = MetaApiServiceFactory.getMetaApi();
}

@Valid
@GET
Expand Down
Loading