Wednesday 6 July 2016

Understanding concept of localextensions.xml and extensioninfo.xml

In this section, would like to explain how modules are loaded and how 1 module is dependent on others.

In localextensions.xml, if we notice we have the structure like this

<hybrisconfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="resources/schemas/extensions.xsd">
<extensions>

<path dir="${HYBRIS_BIN_DIR}" />

<extension name="acceleratorservices" />

<extension name="acceleratorfacades" />
        </extensions>

</hybrisconfig>

Now if we look how all extensions are loaded based on path mentioned "${HYBRIS_BIN_DIR}"

We will find a mapping mentioned below in file "env.properties" under hybris\bin\platform\env.properties

HYBRIS_BIN_DIR = ${platformhome}/../../bin

Now if we again look for platformhome, we will find that each module mentioned in localextensions.xml file has platformhome.properties which holds the mapping like mentioned below

platformhome = C:/hybristest/hybris/bin/platform

Now here comes how hybris loads modules which are dependent on multiple modules. The mapping of dependencies on 1 module on another module is mentioned in extensionsInfo.xml

Each module have its own extensionsInfo.xml file which looks something like this

<extensioninfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="extensioninfo.xsd">

<extension abstractclassprefix="Generated" classprefix="Payment" description="payment extension" managername="PaymentManager" managersuperclass="de.hybris.platform.jalo.extension.Extension" name="payment">
      
      <requires-extension name="basecommerce" version="5.0.0.0-          SNAPSHOT"/>
      <requires-extension name="hmc"/>

   </extension>

</extensioninfo>

So requires extension means the module depends on the modules which are mentioned as requires extension. Lets explain this with an example.

Lets we have a module called "A" , which is dependent on "B" and "C" and "B" itself is dependent on "D". So Hybris will first load "D" module, then "B", "C" and finally "A".

Note: The order in which the entries made in localextensions.xml is nothing to do with the order how hybris loads.