What is role of jalosession?

The Jalo layer in hybris is depreacted, not the jalosession.

Whenever a request is made to hybris server, it may need current user details, currency, language, timezone etc to serve that request efficiently. Since HttpSession does not hold all these details, hybris came up with the concept of JaloSession.

Whenever a request comes to Hybris, the filter HybrisInitFilter creates an object of JaloSession. Every JaloSession object is associated with a SessionContext object, which has current user, language, currency etc and the current httpSession object.

  • Cron jobs also run in a JaloSession.
  • Each JaloSession is bound to a tenant. This cannot be changed, after the instance of JaloSession is created.
  • JaloSession is never made persistent in database.

Why Hybris deprecated Jalo layer?

Or Explain difference between Jalo layer and Service layer?

Hybris 4.3.0, deprecated the Jalo layer for item types. This means, that hybris discouraged the usage of Jalo classes to serve as utility methods for performing business logics.

Prior to service layer, Jalo classes used to have both data model logics, methods and also business logic methods.

<itemtype code=”PickingCenter”
autocreate=”true” generate=”true”>
<deployment table=”PICKING_CENTER” typecode=”22113″/>
           <attribute qualifier=”warehouseForFresh” type=”Warehouse”>
           <persistence type=”property” />
           <modifiers read=”true” write=”true” optional=”true” />
           <description>Warehouse for fresh items</description>

A sample item type in items.xml

The build framework will generate below classed for this item type:

1) An abstract class : GeneratedPickingCenter –  This class is basically a data model class, which has getter/setter for accessing data model, like attributes of data model. 



2) PickingCenter.java

Non Abstract class : This class extends the Generated class, and can have other methods for accommodating business logic.

So what is the big deal?

1) Service layer comes with the idea of segregating business logic from data model. Service layer sits inside other extensions (not necessarily) and access data layer via DAOs.  This layer is much more flexible and loosely coupled with database.

2) Think of a scenario, where you are using a legacy code, you don’t have access to source code. Had it been all Jalo, How would you override a business logic? In service layer it is easy to override, since ever service is configured as a bean, which is more adaptable to spring MVC design pattern.

3) If there is a change in database design, you need not to change your service layer necessarily. This flexibility is not available in Jalo layers.

4) In Jalo, we use like below:                                                                                                VoucheManager vm = VoucherManager().getInstance();

In Service layer,                                                                                                          private VoucherService voucherService;

So we can inject any implementation of VoucherService in our custom code, but how do we do so in Jalo. We need to break into Jalo layers.

Source : Hybris Wiki