{
// Find the ultimate parent context for the tree of SFSBs the target
// bean is part of. This "tree" could just be the bean itself, or
// a multi-layer tree of nested SFSBs.
StatefulContainerInvocation ejbInv = (StatefulContainerInvocation) invocation;
StatefulBeanContext ctx = (StatefulBeanContext) ejbInv.getBeanContext();
StatefulBeanContext root = ctx.getUltimateContainedIn();
// Find out if the ultimate parent is clustered
boolean clustered = false;
StatefulContainer container = (StatefulContainer) root.getContainer();
ClusteredStatefulCache clusteredCache = null;
if (container.getCache() instanceof ClusteredStatefulCache)
{
clustered = true;
clusteredCache = (ClusteredStatefulCache) container.getCache();