Skip to content

Commit

Permalink
Merge pull request #34 from hmrc/SINGLETON
Browse files Browse the repository at this point in the history
Annotated classes with Singleton where this was missing.
  • Loading branch information
anjumabbas5 authored Jun 26, 2019
2 parents 116b319 + 817efe9 commit 2ba1ca1
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ package uk.gov.hmrc.thirdpartyapplication.connector

import java.util.UUID

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import uk.gov.hmrc.http.{HeaderCarrier, HttpReads}
import uk.gov.hmrc.thirdpartyapplication.models.ApiDefinition
import uk.gov.hmrc.play.bootstrap.http.HttpClient

import scala.concurrent.{ExecutionContext, Future}

@Singleton
class ApiDefinitionConnector @Inject()(httpClient: HttpClient, config: ApiDefinitionConfig)(implicit val ec: ExecutionContext) {

def fetchAllAPIs(applicationId: UUID)(implicit rds: HttpReads[Seq[ApiDefinition]], hc: HeaderCarrier, ec: ExecutionContext): Future[Seq[ApiDefinition]] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

package uk.gov.hmrc.thirdpartyapplication.connector

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import uk.gov.hmrc.http.{HeaderCarrier, NotFoundException}
import uk.gov.hmrc.play.bootstrap.http.HttpClient
import uk.gov.hmrc.thirdpartyapplication.models.HasSucceeded

import scala.concurrent.{ExecutionContext, Future}

@Singleton
class ApiSubscriptionFieldsConnector @Inject()(httpClient: HttpClient, config: ApiSubscriptionFieldsConfig)(implicit val ec: ExecutionContext) {

def deleteSubscriptions(clientId: String)(implicit hc: HeaderCarrier): Future[HasSucceeded] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package uk.gov.hmrc.thirdpartyapplication.connector

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.Logger
import play.api.http.ContentTypes.JSON
import play.api.http.HeaderNames.CONTENT_TYPE
Expand All @@ -29,6 +29,7 @@ import uk.gov.hmrc.thirdpartyapplication.models.RateLimitTier.RateLimitTier
import scala.concurrent.{ExecutionContext, Future}
import scala.util.control.NonFatal

@Singleton
class AwsApiGatewayConnector @Inject()(http: HttpClient, config: AwsApiGatewayConfig)
(implicit val ec: ExecutionContext) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package uk.gov.hmrc.thirdpartyapplication.connector

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.Logger
import play.api.libs.json.Json
import play.mvc.Http.Status._
Expand All @@ -37,6 +37,7 @@ object SendEmailRequest {
implicit val sendEmailRequestFmt = Json.format[SendEmailRequest]
}

@Singleton
class EmailConnector @Inject()(httpClient: HttpClient, config: EmailConfig)(implicit val ec: ExecutionContext) {
val serviceUrl = config.baseUrl
val devHubBaseUrl = config.devHubBaseUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

package uk.gov.hmrc.thirdpartyapplication.connector

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import uk.gov.hmrc.http.{HeaderCarrier, NotFoundException}
import uk.gov.hmrc.play.bootstrap.http.HttpClient
import uk.gov.hmrc.thirdpartyapplication.models.HasSucceeded

import scala.concurrent.{ExecutionContext, Future}

@Singleton
class ThirdPartyDelegatedAuthorityConnector @Inject()(httpClient: HttpClient, config: ThirdPartyDelegatedAuthorityConfig)(implicit val ec: ExecutionContext) {

def revokeApplicationAuthorities(clientId: String)(implicit hc: HeaderCarrier): Future[HasSucceeded] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package uk.gov.hmrc.thirdpartyapplication.connector

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.http.Status.CREATED
import uk.gov.hmrc.http.{HeaderCarrier, HttpReads, HttpResponse}
import uk.gov.hmrc.play.bootstrap.http.HttpClient
Expand All @@ -25,6 +25,7 @@ import uk.gov.hmrc.thirdpartyapplication.models.Totp

import scala.concurrent.{ExecutionContext, Future}

@Singleton
class TotpConnector @Inject()(httpClient: HttpClient, config: TotpConfig)(implicit val ec: ExecutionContext) {

def generateTotp()(implicit rds: HttpReads[HttpResponse], hc: HeaderCarrier, ec: ExecutionContext): Future[Totp] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package uk.gov.hmrc.thirdpartyapplication.connector

import com.google.common.base.Charsets
import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.Logger
import play.api.http.ContentTypes.FORM
import play.api.http.HeaderNames.{CONTENT_TYPE, COOKIE, SET_COOKIE}
Expand All @@ -34,6 +34,7 @@ import scala.concurrent._
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}

@Singleton
class Wso2ApiStoreConnector @Inject()(httpClient: HttpClient, config: Wso2ApiStoreConfig)(implicit val ec: ExecutionContext) {

val serviceUrl = s"${config.baseUrl}/store/site/blocks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package uk.gov.hmrc.thirdpartyapplication.controllers

import java.util.UUID
import javax.inject.Inject

import javax.inject.{Inject, Singleton}
import play.api.libs.json.Json.toJson
import play.api.mvc.BodyParsers.parse.json
import uk.gov.hmrc.thirdpartyapplication.connector.{AuthConfig, AuthConnector}
Expand All @@ -27,6 +27,7 @@ import uk.gov.hmrc.thirdpartyapplication.services.{AccessService, ApplicationSer

import scala.concurrent.ExecutionContext.Implicits.global

@Singleton
class AccessController @Inject()(accessService: AccessService,
val authConnector: AuthConnector,
val applicationService: ApplicationService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package uk.gov.hmrc.thirdpartyapplication.controllers

import java.util.UUID

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.libs.json.Json.toJson
import play.api.libs.json._
import play.api.mvc._
Expand All @@ -35,6 +35,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.util.{Failure, Success, Try}

@Singleton
class ApplicationController @Inject()(val applicationService: ApplicationService,
val authConnector: AuthConnector,
credentialService: CredentialService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package uk.gov.hmrc.thirdpartyapplication.controllers

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.mvc.Action
import uk.gov.hmrc.thirdpartyapplication.services.AwsRestoreService

import scala.concurrent.ExecutionContext.Implicits.global

@Singleton
class AwsRestoreController @Inject()(awsRestoreService: AwsRestoreService) extends CommonController {

def restoreAwsData() = Action.async { implicit request =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

package uk.gov.hmrc.thirdpartyapplication.controllers

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.libs.json.Json.toJson
import play.api.mvc._
import uk.gov.hmrc.thirdpartyapplication.services.SubscriptionService
import uk.gov.hmrc.thirdpartyapplication.util.http.HttpHeaders._

import scala.concurrent.ExecutionContext.Implicits.global

@Singleton
class CollaboratorController @Inject()(subscriptionService: SubscriptionService) extends CommonController {

override implicit def hc(implicit request: RequestHeader) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
package uk.gov.hmrc.thirdpartyapplication.controllers

import controllers.AssetsBuilder
import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.Configuration
import play.api.http.HttpErrorHandler
import play.api.mvc.Action
import uk.gov.hmrc.thirdpartyapplication.models.ApiAccess
import uk.gov.hmrc.play.bootstrap.controller.BaseController
import uk.gov.hmrc.thirdpartyapplication.views.txt

@Singleton
class DocumentationController @Inject()(httpErrorHandler: HttpErrorHandler, config: DocumentationConfig)
extends AssetsBuilder(httpErrorHandler) with BaseController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package uk.gov.hmrc.thirdpartyapplication.controllers

import java.util.UUID
import javax.inject.Inject

import javax.inject.{Inject, Singleton}
import play.api.libs.json.Json
import uk.gov.hmrc.thirdpartyapplication.connector.{AuthConfig, AuthConnector}
import uk.gov.hmrc.thirdpartyapplication.controllers.ErrorCode._
Expand All @@ -28,6 +28,7 @@ import uk.gov.hmrc.thirdpartyapplication.services.{ApplicationService, Gatekeepe

import scala.concurrent.ExecutionContext.Implicits.global

@Singleton
class GatekeeperController @Inject()(val authConnector: AuthConnector, val applicationService: ApplicationService,
gatekeeperService: GatekeeperService, val authConfig: AuthConfig) extends CommonController with AuthorisationWrapper {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package uk.gov.hmrc.thirdpartyapplication.controllers

import javax.inject.Inject

import javax.inject.{Inject, Singleton}
import play.api.mvc.Action
import uk.gov.hmrc.thirdpartyapplication.services.Wso2RestoreService

import scala.concurrent.ExecutionContext.Implicits.global

@Singleton
class Wso2RestoreController @Inject()(wso2RestoreService: Wso2RestoreService) extends CommonController {

def restoreWso2Data() = Action.async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package uk.gov.hmrc.thirdpartyapplication.services

import java.util.UUID
import javax.inject.Inject

import javax.inject.{Inject, Singleton}
import uk.gov.hmrc.thirdpartyapplication.controllers.{OverridesRequest, OverridesResponse, ScopeRequest, ScopeResponse}
import uk.gov.hmrc.http.{HeaderCarrier, NotFoundException}
import uk.gov.hmrc.thirdpartyapplication.models.AccessType.{PRIVILEGED, ROPC}
Expand All @@ -30,6 +30,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.Future.{failed, sequence, successful}

@Singleton
class AccessService @Inject()(applicationRepository: ApplicationRepository, auditService: AuditService) {

def readScopes(applicationId: UUID): Future[ScopeResponse] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ class ApplicationService @Inject()(applicationRepository: ApplicationRepository,
private def loggedInUser(implicit hc: HeaderCarrier) = hc.headers find (_._1 == LOGGED_IN_USER_EMAIL_HEADER) map (_._2) getOrElse ""
}

@Singleton
class ApplicationLockKeeper @Inject()(reactiveMongoComponent: ReactiveMongoComponent) extends LockKeeper {
override def repo: LockRepository = {
LockMongoRepository(reactiveMongoComponent.mongoConnector.db)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ import java.net.URLDecoder
import java.nio.charset.StandardCharsets
import java.util.UUID

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import uk.gov.hmrc.http.HeaderCarrier
import uk.gov.hmrc.thirdpartyapplication.models.{ApplicationData, Collaborator, OverrideFlag, Standard}
import uk.gov.hmrc.play.audit.AuditExtensions.auditHeaderCarrier
import uk.gov.hmrc.play.audit.http.connector.{AuditConnector, AuditResult}
import uk.gov.hmrc.play.audit.model.DataEvent
import uk.gov.hmrc.thirdpartyapplication.models.{ApplicationData, Collaborator, OverrideFlag, Standard}
import uk.gov.hmrc.thirdpartyapplication.services.AuditAction.{AppNameChanged, AppPrivacyPolicyUrlChanged, AppRedirectUrisChanged, AppTermsAndConditionsUrlChanged}
import uk.gov.hmrc.thirdpartyapplication.util.http.HttpHeaders._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

@Singleton
class AuditService @Inject()(val auditConnector: AuditConnector) {

def audit(action: AuditAction, data: Map[String, String])(implicit hc: HeaderCarrier): Future[AuditResult] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package uk.gov.hmrc.thirdpartyapplication.services

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.Logger
import uk.gov.hmrc.http.HeaderCarrier
import uk.gov.hmrc.thirdpartyapplication.connector.{AwsApiGatewayConnector, UpsertApplicationRequest}
Expand All @@ -27,6 +27,7 @@ import uk.gov.hmrc.thirdpartyapplication.repository.{ApplicationRepository, Subs
import scala.concurrent.Future.sequence
import scala.concurrent.{ExecutionContext, Future}

@Singleton
class AwsRestoreService @Inject()(awsApiGatewayConnector: AwsApiGatewayConnector,
applicationRepository: ApplicationRepository,
subscriptionRepository: SubscriptionRepository) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package uk.gov.hmrc.thirdpartyapplication.services

import java.util.UUID
import javax.inject.Inject

import javax.inject.{Inject, Singleton}
import uk.gov.hmrc.thirdpartyapplication.controllers.{ClientSecretRequest, ValidationRequest}
import uk.gov.hmrc.http.{HeaderCarrier, NotFoundException}
import uk.gov.hmrc.thirdpartyapplication.models.Environment._
Expand All @@ -29,6 +29,7 @@ import uk.gov.hmrc.thirdpartyapplication.services.AuditAction._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

@Singleton
class CredentialService @Inject()(applicationRepository: ApplicationRepository,
auditService: AuditService,
trustedApplications: TrustedApplications,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package uk.gov.hmrc.thirdpartyapplication.services

import java.util.UUID

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.Logger
import uk.gov.hmrc.thirdpartyapplication.connector.{ApiSubscriptionFieldsConnector, EmailConnector, ThirdPartyDelegatedAuthorityConnector}
import uk.gov.hmrc.thirdpartyapplication.controllers.{DeleteApplicationRequest, RejectUpliftRequest}
Expand All @@ -36,6 +36,7 @@ import scala.concurrent.Future
import scala.concurrent.Future._
import scala.util.Failure

@Singleton
class GatekeeperService @Inject()(applicationRepository: ApplicationRepository,
stateHistoryRepository: StateHistoryRepository,
subscriptionRepository: SubscriptionRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package uk.gov.hmrc.thirdpartyapplication.services

import java.util.UUID

import javax.inject.Inject
import javax.inject.{Inject, Singleton}
import play.api.Logger
import uk.gov.hmrc.http.{HeaderCarrier, NotFoundException}
import uk.gov.hmrc.thirdpartyapplication.connector.ApiDefinitionConnector
Expand All @@ -31,6 +31,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.Future.{failed, sequence, successful}

@Singleton
class SubscriptionService @Inject()(applicationRepository: ApplicationRepository,
subscriptionRepository: SubscriptionRepository,
apiDefinitionConnector: ApiDefinitionConnector,
Expand Down

0 comments on commit 2ba1ca1

Please sign in to comment.