Class DefaultCloneComponentContextProvider
- java.lang.Object
-
- de.hybris.platform.cmsfacades.cmsitems.impl.DefaultCloneComponentContextProvider
-
- All Implemented Interfaces:
CloneComponentContextProvider,CMSItemContextProvider<java.util.Map.Entry<java.lang.String,java.lang.Object>>
public class DefaultCloneComponentContextProvider extends java.lang.Object implements CloneComponentContextProvider
Default implementation ofCloneComponentContextProviderresponsible for storing (in a stack-like data structure) context information per transaction when cloning a component.
-
-
Constructor Summary
Constructors Constructor Description DefaultCloneComponentContextProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfinalizeItem()Finalizes the latest instance for this transaction.java.lang.ObjectfindItemForKey(java.lang.String key)Read value fromMap.Entrywithout removing it from the stackjava.util.Map.Entry<java.lang.String,java.lang.Object>getCurrentItem()Provides the current instance for this transaction.protected SessionServicegetSessionService()protected java.lang.ObjectgetValueFromSession(boolean shouldThrowException)Get the value stored in the session associated to the keySESSION_CLONE_COMPONENT_CONTEXTprotected java.util.Deque<java.util.Map.Entry<java.lang.String,java.lang.Object>>getWrappedStack(java.lang.Object rawValue)Values stored in the session service must be wrapped in AtomicReference objects to protect them from being altered during serialization.voidinitializeItem(java.util.Map.Entry<java.lang.String,java.lang.Object> entry)Initializes and stores a new instance for this transaction.booleanisInitialized()Verify that the clone component operation is being executed by checking if some clone component information has been saved in the session.voidsetSessionService(SessionService sessionService)
-
-
-
Method Detail
-
initializeItem
public void initializeItem(java.util.Map.Entry<java.lang.String,java.lang.Object> entry)
Description copied from interface:CMSItemContextProviderInitializes and stores a new instance for this transaction.- Specified by:
initializeItemin interfaceCMSItemContextProvider<java.util.Map.Entry<java.lang.String,java.lang.Object>>- Parameters:
entry- the value to store
-
isInitialized
public boolean isInitialized()
Description copied from interface:CloneComponentContextProviderVerify that the clone component operation is being executed by checking if some clone component information has been saved in the session.- Specified by:
isInitializedin interfaceCloneComponentContextProvider- Returns:
- TRUE when clone component information was stored in session; FALSE otherwise
-
getCurrentItem
public java.util.Map.Entry<java.lang.String,java.lang.Object> getCurrentItem()
Description copied from interface:CMSItemContextProviderProvides the current instance for this transaction.- Specified by:
getCurrentItemin interfaceCMSItemContextProvider<java.util.Map.Entry<java.lang.String,java.lang.Object>>- Returns:
- the current item
-
findItemForKey
public java.lang.Object findItemForKey(java.lang.String key)
Description copied from interface:CloneComponentContextProviderRead value fromMap.Entrywithout removing it from the stack- Specified by:
findItemForKeyin interfaceCloneComponentContextProvider- Parameters:
key- the key of theMap.Entry- Returns:
- the value associated to the given key in the
Map.Entry; can be null when the key is not found
-
finalizeItem
public void finalizeItem()
Description copied from interface:CMSItemContextProviderFinalizes the latest instance for this transaction.- Specified by:
finalizeItemin interfaceCMSItemContextProvider<java.util.Map.Entry<java.lang.String,java.lang.Object>>
-
getValueFromSession
protected java.lang.Object getValueFromSession(boolean shouldThrowException)
Get the value stored in the session associated to the keySESSION_CLONE_COMPONENT_CONTEXT- Parameters:
shouldThrowException- when set to TRUE, anIllegalStateExceptionis thrown if no value is found in the session- Returns:
- the value stored in the session
-
getWrappedStack
protected java.util.Deque<java.util.Map.Entry<java.lang.String,java.lang.Object>> getWrappedStack(java.lang.Object rawValue)
Values stored in the session service must be wrapped in AtomicReference objects to protect them from being altered during serialization. When values are read from the session service, they must be unwrapped. Thus, this method is used to retrieve the original value (stack) stored in the AtomicReference wrapper.- Parameters:
rawValue- Object retrieved from the session service. The object must be an AtomicReference. Otherwise, an IllegalStateException is thrown.- Returns:
- stack stored within the AtomicReference.
-
getSessionService
protected SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
-