Skip to content

Commit

Permalink
Fix @value not working in beans declared in gemma-servlet.xml (fix #1001
Browse files Browse the repository at this point in the history
)
  • Loading branch information
arteymix committed Jun 25, 2024
1 parent 1df06a7 commit 3fd1620
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
Expand All @@ -13,7 +14,6 @@
import ubic.basecode.ontology.model.OntologyTerm;
import ubic.gemma.core.ontology.FactorValueOntologyService;
import ubic.gemma.core.ontology.providers.GemmaOntologyService;
import ubic.gemma.core.config.Settings;
import ubic.gemma.web.util.EntityNotFoundException;
import ubic.gemma.web.util.ServiceUnavailableException;

Expand All @@ -40,12 +40,8 @@ public class OntologyController {

private static final MediaType RDF_XML = MediaType.parseMediaType( "application/rdf+xml" );

/**
* FIXME: use {@link org.springframework.beans.factory.annotation.Value} for injecting this, but I think injection
* is broken in controllers. See <a href="https://github.com/PavlidisLab/Gemma/issues/1001">#1001</a> for
* details.
*/
private static final String hostUrl = Settings.getHostUrl();
@Value("${gemma.hosturl}")
private String hostUrl;

@Autowired
private GemmaOntologyService gemmaOntologyService;
Expand Down
7 changes: 7 additions & 0 deletions gemma-web/src/main/webapp/WEB-INF/gemma-servlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
<context:exclude-filter type="annotation" expression="ubic.gemma.core.context.TestComponent"/>
</context:component-scan>

<!-- The servlet uses a different Spring context with gemma-core's context as parent -->
<!-- Unfortunately, bean post-processor do not get applied, so they must be redeclared here if we want them to apply
to controllers -->
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="propertySources" ref="settingsPropertySources"/>
</bean>

<!-- Mapping URLS to controllers -->


Expand Down

0 comments on commit 3fd1620

Please sign in to comment.