Documentation Center

DXA Java configuration

The following changes have been introduced to the DXA Java

  • Spring context is configured fully using the Java Configuration. No XML for Spring is used in DXA.
  • Default values for services, like the redirect link for the Experience Optimization are taken from the existing configuration for such services with a fallback to an option property in dxa*.properties, and possible further fallback to hardcoded value (if possible).
  • New properties files:
    • DXA has dxa.defaults.properties with default values.
    • DXA checks classpath for the dxa.properties file.
    • Order of properties files import:
      • dxa.defaults.properties
      • dxa.modules.*.properties
      • dxa.properties
    • If you wrote your own module, its dxa.modules.*.properties and dxa.addons.*.properties files will be picked up automatically by DXA.

Spring Profiles

Use case:

Different beans are defined across DXA and modules. If a bean is defined in DXA and imported into module, then the latter tends to replace the former if other behavior is not required. For example, in case a module has two implementations of the same bean, the implementation is chosen using a Spring profile. This is the main use case for Spring profiles but others are still possible.

Spring profile nameDescriptionAdditional information
search.aws Activates AWS in SearchNot compatible with search.solr
search.solr Activates SOLR in SearchNot compatible with search.aws
adf.context.provider Activates ADF instead of ContextService in Web8Does not affect SDL Tridion 2013 SP1
51degrees.context.providerActivates 51Degrees Context ProviderRequires dxa-51degrees-module.
dxa.no-cacheMakes DXA use NoCacheProvider in Tridion
testActivates Testing contextOnly affects unit testing. Activated in Tests by default. Does not affect the application.

Spring Profiles is something you must set explicitly for your web application. This is typically done using one of the following:

  • You can use the <init-param> or <context-param> in your web.xml.
    <context-param>
        <param-name>spring.profiles.active</param-name>
        <param-value>search.aws, adf.context.provider</param-value>
    </context-param>
  • You can provide a system parameter at application startup -Dspring.profiles.active="search.aws, adf.context.provider".

In DXA Example web application, if you have <init-param> or <context-param> set, its values have a priority over any other configuration. If you do not have these parameters set, the web application searches for spring.profiles.active and spring.profiles.include in dxa.**.properties files and adds them all to active profiles. This is the preferable way for DXA to configure Spring Profiles.

Properties

Here is list of all DXA properties:
## DXA

# Web Properties
#dxa.web.views.folder=/META-INF/resources/ 
#dxa.web.views.prefix=/WEB-INF/Views/
#dxa.web.views.suffix=.jsp
# Enabling registration of Preview and ADF filters
#dxa.web.adf.enabled=true   /*To enable ADF for filter for Web8, you also need to enable related Spring profile*/

#DXA Tridion 2013 Provider
#dxa.tridion.2013.context.repository.url=https://context.sdl.com/seed 
#dxa.tridion.2013.context.repository.location=../repository 
#dxa.tridion.2013.context.repository.load.enabled=true 
 
# Possible profiles:
# search.aws - Activates AWS in Search, Not compatible with search.solr
# search.solr - Activates SOLR in Search, Not compatible with search.aws
# adf.context.provider - Activates ADF instead of ContextService in Web8, Doesn’t affect 2013SP1
# 51degrees.context.provider - Activates 51Degrees Context Provider, Requires dxa-51degrees-module. 
# dxa.no-cache - Makes DXA use NoCacheProvider in Tridion
# test Activates - Testing context, Only affects unit testing. Activated in Tests by default. Doesn’t affect application.
#spring.profiles.active=search.solr
 
#dxa.context.deviceFamilies.file=device-families.xml NEW
 
## Modules
# - All commented are optional
 
# Mapping for CID resolver (Filter or Servlet)
#dxa.modules.cid.mapping=/cid/*
 
# Class to use as a resolver for CID images
dxa.modules.cid.className=com.sdl.delivery.image.filter.ContextualImageFilter
 
# External path to the server which runs DXA for back-mapping for CID Service
#dxa.modules.cid.appHostMapping=localhost:8088
 
# Redirect link for XO GA client
#dxa.modules.xo.fallbackRedirectUrl=/redirect/
 
 
# 51degrees module
#dxa.modules.51degrees.file.locationPattern=..\\Temp\\51degrees\\%s\\51degrees-device-data.dat
#dxa.modules.51degrees.file.lite.location=..\\Temp\\51degrees\\51degrees-device-data-lite.dat
#dxa.modules.51degrees.file.lite.url=https://github.com/51Degrees/Java-Device-Detection/blob/master/data/51Degrees-LiteV3.2.dat?raw=true
#dxa.modules.51degrees.file.lite.timeout.mins=10
#dxa.modules.51degrees.file.reattempt.delay.mins=30
 
# Context Expressions Module
dxa.modules.contextexpr.extension_data_map_key=ContextExpressions NEW
  
Example module
  
dxa.modules.example.UnknownLocalizationHandler.exception=html
#dxa.modules.example.UnknownLocalizationHandler.exception=json
#dxa.modules.example.UnknownLocalizationHandler.exception=400
#dxa.modules.example.UnknownLocalizationHandler.exception=500
#dxa.modules.example.UnknownLocalizationHandler.exception=404.inline
#dxa.modules.example.UnknownLocalizationHandler.exception=500.inline
#dxa.modules.example.UnknownLocalizationHandler.exception=default.handling
#dxa.modules.example.UnknownLocalizationHandler.exception=any.incorrect.scenario