Skip to content

Commit

Permalink
Revert "Use constructor injection for web services"
Browse files Browse the repository at this point in the history
This reverts commit 2a9174b.

Autowiring via constructor with CGLIB does not work in Spring 3. That
will require moving to Spring 3.

See #508.
  • Loading branch information
arteymix committed Dec 13, 2022
1 parent 649f363 commit c28023e
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Endpoint for {@link ubic.gemma.model.analysis.AnalysisResultSet}
Expand All @@ -61,18 +62,17 @@ public class AnalysisResultSetsWebService {

private static final String TEXT_TAB_SEPARATED_VALUE_Q9_MEDIA_TYPE = MediaTypeUtils.TEXT_TAB_SEPARATED_VALUES_UTF8 + "; q=0.9";

private final ExpressionAnalysisResultSetService expressionAnalysisResultSetService;
private final ExpressionExperimentService expressionExperimentService;
private final DatabaseEntryService databaseEntryService;
private final ExpressionAnalysisResultSetFileService expressionAnalysisResultSetFileService;
@Autowired
private ExpressionAnalysisResultSetService expressionAnalysisResultSetService;

@Autowired
public AnalysisResultSetsWebService( ExpressionAnalysisResultSetService expressionAnalysisResultSetService, ExpressionExperimentService expressionExperimentService, DatabaseEntryService databaseEntryService, ExpressionAnalysisResultSetFileService expressionAnalysisResultSetFileService ) {
this.expressionAnalysisResultSetService = expressionAnalysisResultSetService;
this.expressionExperimentService = expressionExperimentService;
this.databaseEntryService = databaseEntryService;
this.expressionAnalysisResultSetFileService = expressionAnalysisResultSetFileService;
}
private ExpressionExperimentService expressionExperimentService;

@Autowired
private DatabaseEntryService databaseEntryService;

@Autowired
private ExpressionAnalysisResultSetFileService expressionAnalysisResultSetFileService;

/**
* Retrieve all {@link AnalysisResultSet} matching a set of criteria.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,17 @@ public class AnnotationsWebService {

private static final String URL_PREFIX = "http://";

private final OntologyService ontologyService;
private final SearchService searchService;
private final CharacteristicService characteristicService;
private final ExpressionExperimentService expressionExperimentService;
private final TaxonService taxonService;
private OntologyService ontologyService;
private SearchService searchService;
private CharacteristicService characteristicService;
private ExpressionExperimentService expressionExperimentService;
private TaxonService taxonService;

/**
* Required by spring
*/
public AnnotationsWebService() {
}

/**
* Constructor for service autowiring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,24 @@ public class DatasetsWebService {
private static final String ERROR_DATA_FILE_NOT_AVAILABLE = "Data file for experiment %s can not be created.";
private static final String ERROR_DESIGN_FILE_NOT_AVAILABLE = "Design file for experiment %s can not be created.";

private final ExpressionExperimentService service;
private final ExpressionExperimentService expressionExperimentService;
private final ExpressionDataFileService expressionDataFileService;
private final ArrayDesignService arrayDesignService;
private final BioAssayService bioAssayService;
private final ProcessedExpressionDataVectorService processedExpressionDataVectorService;
private final GeneService geneService;
private final SVDService svdService;
private final DifferentialExpressionAnalysisService differentialExpressionAnalysisService;
private final AuditEventService auditEventService;
private final OutlierDetectionService outlierDetectionService;
private final QuantitationTypeService quantitationTypeService;
private ExpressionExperimentService service;
private ExpressionExperimentService expressionExperimentService;
private ExpressionDataFileService expressionDataFileService;
private ArrayDesignService arrayDesignService;
private BioAssayService bioAssayService;
private ProcessedExpressionDataVectorService processedExpressionDataVectorService;
private GeneService geneService;
private SVDService svdService;
private DifferentialExpressionAnalysisService differentialExpressionAnalysisService;
private AuditEventService auditEventService;
private OutlierDetectionService outlierDetectionService;
private QuantitationTypeService quantitationTypeService;

/**
* Required by spring
*/
public DatasetsWebService() {
}

/**
* Constructor for service autowiring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@
@Path("/genes")
public class GeneWebService {

private final GeneService geneService;
private final GeneOntologyService geneOntologyService;
private final CompositeSequenceService compositeSequenceService;
private final PhenotypeAssociationManagerService phenotypeAssociationManagerService;
private final GeneCoexpressionSearchService geneCoexpressionSearchService;
private GeneService geneService;
private GeneOntologyService geneOntologyService;
private CompositeSequenceService compositeSequenceService;
private PhenotypeAssociationManagerService phenotypeAssociationManagerService;
private GeneCoexpressionSearchService geneCoexpressionSearchService;

/**
* Required by spring
*/
public GeneWebService() {
}

/**
* Constructor for service autowiring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
@Path("/phenotypes")
public class PhenotypeWebService {

private final PhenotypeAssociationManagerService phenotypeAssociationManagerService;
private PhenotypeAssociationManagerService phenotypeAssociationManagerService;

/**
* Required by spring
*/
public PhenotypeWebService() {
}

/**
* Constructor for service autowiring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ public class PlatformsWebService {
private static final Log log = LogFactory.getLog( PlatformsWebService.class.getName() );
private static final String ERROR_ANNOTATION_FILE_NOT_AVAILABLE = "Annotation file for platform %s does not exist or can not be accessed.";

private final GeneService geneService;
private final ArrayDesignService arrayDesignService;
private final ExpressionExperimentService expressionExperimentService;
private final CompositeSequenceService compositeSequenceService;
private final ArrayDesignAnnotationService annotationFileService;
private GeneService geneService;
private ArrayDesignService arrayDesignService;
private ExpressionExperimentService expressionExperimentService;
private CompositeSequenceService compositeSequenceService;
private ArrayDesignAnnotationService annotationFileService;

/**
* Required by spring
*/
public PlatformsWebService() {
}

/**
* Constructor for service autowiring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.models.OpenAPI;
import lombok.Getter;
import lombok.Value;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import org.springframework.web.util.UriComponentsBuilder;
import ubic.gemma.core.security.authentication.UserManager;
import ubic.gemma.model.common.auditAndSecurity.User;
import ubic.gemma.model.common.description.ExternalDatabaseValueObject;
Expand Down Expand Up @@ -56,14 +58,11 @@ public class RootWebService {
*/
private static final String[] EXTERNAL_DATABASE_NAMES = Settings.getStringArray( "gemma.externalDatabases.featured" );

private final ExternalDatabaseService externalDatabaseService;
private final UserManager userManager;
@Autowired
private ExternalDatabaseService externalDatabaseService;

@Autowired
public RootWebService( ExternalDatabaseService externalDatabaseService, UserManager userManager ) {
this.externalDatabaseService = externalDatabaseService;
this.userManager = userManager;
}
private UserManager userManager;

/**
* Returns an object with API information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,12 @@ public class SearchWebService {
*/
public static final int MAX_SEARCH_RESULTS = 1000;

private final SearchService searchService;
private final TaxonService taxonService;
private final ArrayDesignService arrayDesignService;

@Autowired
public SearchWebService( SearchService searchService, TaxonService taxonService, ArrayDesignService arrayDesignService ) {
this.searchService = searchService;
this.taxonService = taxonService;
this.arrayDesignService = arrayDesignService;
}
private SearchService searchService;
@Autowired
private TaxonService taxonService;
@Autowired
private ArrayDesignService arrayDesignService;

/**
* Search everything subject to taxon and platform constraints.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,17 @@
public class TaxaWebService {

protected static final Log log = LogFactory.getLog( TaxaWebService.class.getName() );
private final TaxonService taxonService;
private final GeneService geneService;
private final ExpressionExperimentService expressionExperimentService;
private final PhenotypeAssociationManagerService phenotypeAssociationManagerService;
private final ChromosomeService chromosomeService;
private TaxonService taxonService;
private GeneService geneService;
private ExpressionExperimentService expressionExperimentService;
private PhenotypeAssociationManagerService phenotypeAssociationManagerService;
private ChromosomeService chromosomeService;

/**
* Required by spring
*/
public TaxaWebService() {
}

/**
* Constructor for service autowiring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class SearchWebServiceTest extends AbstractJUnit4SpringContextTests {
public static class SearchWebServiceTestContextConfiguration {

@Bean
public SearchWebService searchWebService( SearchService searchService, TaxonService taxonService, ArrayDesignService arrayDesignService ) {
return new SearchWebService( searchService, taxonService, arrayDesignService );
public SearchWebService searchWebService() {
return new SearchWebService();
}

@Bean
Expand Down

0 comments on commit c28023e

Please sign in to comment.