Skip to content

Commit

Permalink
Declare autowired controller class members lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Feb 27, 2024
1 parent b83b3f7 commit ff8b717
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -28,6 +29,7 @@
@RequestMapping("/registration")
public class RegistrationController {

@Lazy
@Autowired
private RegistrationService registrationService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.tamu.scholars.middleware.discovery.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -13,6 +14,7 @@
@RequestMapping("/index")
public class IndexingController {

@Lazy
@Autowired
private IndexService indexService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -22,6 +23,7 @@
@RequestMapping("/individual/analytics")
public class IndividualAnalyticsController {

@Lazy
@Autowired
private IndividualRepo repo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javax.persistence.EntityNotFoundException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.hateoas.PagedModel;
Expand All @@ -38,12 +39,15 @@
@RestController
public class IndividualController implements RepresentationModelProcessor<IndividualModel> {

@Lazy
@Autowired
private IndividualRepo repo;

@Lazy
@Autowired
private IndividualResourceAssembler assembler;

@Lazy
@Autowired
private DiscoveryPagedResourcesAssembler<Individual> pagedAssembler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.rest.webmvc.RepositorySearchesResource;
Expand Down Expand Up @@ -39,12 +40,15 @@
@RequestMapping("/individual")
public class IndividualSearchController implements RepresentationModelProcessor<RepositorySearchesResource> {

@Lazy
@Autowired
private IndividualRepo repo;

@Lazy
@Autowired
private IndividualResourceAssembler assembler;

@Lazy
@Autowired
private DiscoveryPagedResourcesAssembler<Individual> pagedAssembler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -17,6 +18,7 @@
@RestController
public class IndividualSearchCountController {

@Lazy
@Autowired
private IndividualRepo repo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.persistence.EntityNotFoundException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.hateoas.server.RepresentationModelProcessor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
Expand All @@ -34,9 +35,11 @@
@RestController
public class IndividualExportController implements RepresentationModelProcessor<IndividualModel> {

@Lazy
@Autowired
private IndividualRepo repo;

@Lazy
@Autowired
private ExporterRegistry exporterRegistry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.concurrent.ExecutionException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Sort;
import org.springframework.data.rest.webmvc.RepositorySearchesResource;
import org.springframework.data.web.SortDefault;
Expand All @@ -35,9 +36,11 @@
@RestController
public class IndividualSearchExportController implements RepresentationModelProcessor<RepositorySearchesResource> {

@Lazy
@Autowired
private IndividualRepo repo;

@Lazy
@Autowired
private ExporterRegistry exporterRegistry;

Expand Down

0 comments on commit ff8b717

Please sign in to comment.