SAP Commerce (Hybris) interview questions with answers - Part 4 Configuration

image from wikimedia.org

Previous posts:
Part 1 - Data Model
Part 2 - IMPEX
Part 3 - Dynamic Attributes

Enumerate places of definition configurable properties.

  • global properties - local.properties file is located in ${HYBRIS_CONFIG_DIR}
  • extension-specific project.properties file in ${EXTENSION_DIR}
  • platform-specific project.properties file in ${HYBRIS_BIN_DIR}>/platform

You have the same properties in different extensions. What value will be set in the system?

extensionA/project.properties

1
property.legacymode=true

extensionB/project.properties

1
property.legacymode=false

We can’t explicitly define what the value will because Hybris doesn’t define a strict order for processing extensions. To override the value define it in config/local.properties:

1
property.legacymode=false

You have some properties. What is the best place to put it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
##############################################
# Set 1
##############################################
# Never used by the customer
very.special.property.use=false
extremely.special.property.number=-1


##############################################
# Set 2
##############################################
# tcserver's tomcat version
bundled.tcserver.tomcat.version=7.0.42.A.RELEASE

# Relative path to tcserver's tomcat
bundled.tcserver.tomcat.home=tomcat-${bundled.tcserver.tomcat.version}

# Name of an server instance
bundled.tcserver.instance=instance1


##############################################
# Set 3
##############################################
carsupplierstorefront.redirect.customer_and_cart=/cart
carsupplierstorefront.redirect.customer_only=/my-account
carsupplierstorefront.redirect.error=/


##############################################
# Set 4
##############################################
tomcat.development.mode=true
mail.smtp.server=localhost
mail.smtp.port=1025
mail.from=test-dev@carsupplier.com

Set 1 - looks like these are very special properties not typically used by a customer.
The official documentation recommends put very special properties in advanced.properties
Set 2 - looks like these are low-level platform properties.
The official documentation recommends put low-level platform properties in platform/project.properties
Set 3 - looks like these are extension-related properties.
The official documentation recommends put extension-related properties in extensions/project.properties
Set 4 - looks like these are project-related properties.
The official documentation recommends put project related properties in config/local.properties

What value will be set in the system?

config/local.properties

1
property.legacymode=false

extension/project.properties

1
property.legacymode=true

platform/project.properties

1
property.legacymode=

In the system will be set property.legacymode=false because local.properties overrides other properties.

I don’t want to store passwords/logins to establish a connection to the database in local.properties. What can I do?

config/local.properties

1
2
3
4
# I don't want to store it here
db.url=jdbc:oracle:thin:@amrood:1521:EMP
db.username=hybris
db.password=SoMePas5w00rD

You can use Environment Variables instead of storing values in properties files. Those variables always override variables from any properties file. Properties are defined as environment variables always override those from any properties file.
For to do this:

  1. Remove valid values from local.properties:
    1
    2
    3
    db.url=<CHANGE_ME>
    db.username=<CHANGE_ME>
    db.password=<CHANGE_ME>
  2. Pass values before start server:
    1
    2
    3
    4
    hybris-user$ export y_db_url=jdbc:oracle:thin:@amrood:1521:EMP
    hybris-user$ export y_db_username=hybris
    hybris-user$ export y_db_password=SoMePas5w00rD
    hybris-user$ ./hybrisserver.sh start

Created based on official documentation

Follow me in the group in telegram

Share