All Implemented Interfaces:
JaloOnlyItem, Serializable, Comparable
Direct Known Subclasses:
GeneratedMultiAddressInMemoryCart

public class InMemoryCart extends GeneratedInMemoryCart implements JaloOnlyItem
A in-memory implementation of Cart. This item is not backed by the database and will therefore not survive the end of JaloSession. Apart from that it can be used as normal cart including order creation and saved carts.

There are several options to make JaloSession use this kind of cart:

Set as default cart type

Change your local.properties like this:

 # Default session cart type
 # Specifies which type of cart is being created on demand by
 # each JaloSession. Use 'InMemoryCart' if you don't need a
 # database backed session cart.
 default.session.cart.type = InMemoryCart
 

Specify per session

For each session which has no cart yet you may specify the cart type via session context:
        JaloSession js = ...

        js.getSessionContext().setAttribute("InMemoryCart");
        // or
        js.getSessionContext().setAttribute(CoreConstants.TC.INMEMORYCART);
        // or even
        js.getSessionContext().setAttribute(
                TypeManager.getInstance().getComposedType( InMemoryCart.class )
        );

        InMemoryCart newCart = (InMemoryCart)js.getCart();
 

Please note: Due to its non-persistent nature this cart usually does not survive the end of its owning JaloSession! Special care should be taken when using session replication across a cluster: although this cart is serializable and should therefore be transfered to all other nodes we suggest to verify if updates onto the cart and its entries are really synchronized. This may depend upon the chose session replication technology.
See Also: