int maxSubpathId = Integer.MIN_VALUE;
for (Map.Entry<ContextStatePathKey, ContextStatePathValue> entry : childContexts.entrySet()) {
int categoryNumber = (Integer) factory.getBinding().byteArrayToObject(entry.getValue().getBlob(), null);
ContextDetailCategoryItem category = factory.getCategorySpec().getItems().get(categoryNumber);
// merge filter addendum, if any
ContextInternalFilterAddendum filterAddendumToUse = activationFilterAddendum;
if (factory.hasFiltersSpecsNestedContexts()) {
filterAddendumToUse = activationFilterAddendum != null ? activationFilterAddendum.deepCopy() : new ContextInternalFilterAddendum();
factory.populateContextInternalFilterAddendums(filterAddendumToUse, categoryNumber);
}
// check if exists already
if (controllerState.isImported()) {
ContextControllerInstanceHandle existingHandle = handleCategories.get(categoryNumber);
if (existingHandle != null) {
activationCallback.contextPartitionNavigate(existingHandle, this, controllerState, entry.getValue().getOptionalContextPartitionId(), filterAddendumToUse, agentInstanceSelector, entry.getValue().getBlob());
continue;
}
}
Map<String, Object> context = ContextPropertyEventType.getCategorizedBean(factory.getFactoryContext().getContextName(), 0, category.getName());
int contextPartitionId = entry.getValue().getOptionalContextPartitionId();
int assignedSubPathId = !controllerState.isImported() ? entry.getKey().getSubPath() : ++currentSubpathId;
ContextControllerInstanceHandle handle = activationCallback.contextPartitionInstantiate(contextPartitionId, assignedSubPathId, entry.getKey().getSubPath(), this, null, null, categoryNumber, context, controllerState, filterAddendumToUse, factory.getFactoryContext().isRecoveringResilient(), entry.getValue().getState());
handleCategories.put(categoryNumber, handle);