/* * Means processor cache size exceeds {@link Constants.MAX_SLOT_CHAIN_SIZE}, so no * rule checking will be done. */ if (chain == null) { returnnewCtEntry(resourceWrapper, null, context); }
// Resolve the slot chain builder SPI. slotChainBuilder = SpiLoader.of(SlotChainBuilder.class).loadFirstInstanceOrDefault();
if (slotChainBuilder == null) { // Should not go through here. RecordLog.warn("[SlotChainProvider] Wrong state when resolving slot chain builder, using default"); slotChainBuilder = newDefaultSlotChainBuilder(); } else { RecordLog.info("[SlotChainProvider] Global slot chain builder resolved: {}", slotChainBuilder.getClass().getCanonicalName()); } return slotChainBuilder.build(); }
public ProcessorSlotChain build() { ProcessorSlotChainchain=newDefaultProcessorSlotChain();
List<ProcessorSlot> sortedSlotList = SpiLoader.of(ProcessorSlot.class).loadInstanceListSorted(); for (ProcessorSlot slot : sortedSlotList) { if (!(slot instanceof AbstractLinkedProcessorSlot)) { RecordLog.warn("The ProcessorSlot(" + slot.getClass().getCanonicalName() + ") is not an instance of AbstractLinkedProcessorSlot, can't be added into ProcessorSlotChain"); continue; }
protectedvoidexitForContext(Context context, int count, Object... args)throws ErrorEntryFreeException { if (context != null) { // Null context should exit without clean-up. if (context instanceof NullContext) { return; } if (context.getCurEntry() != this) { StringcurEntryNameInContext= context.getCurEntry() == null ? null : context.getCurEntry().getResourceWrapper().getName(); // Clean previous call stack. CtEntrye= (CtEntry) context.getCurEntry(); while (e != null) { e.exit(count, args); e = (CtEntry) e.parent; } StringerrorMessage= String.format("The order of entry exit can't be paired with the order of entry" + ", current entry in context: <%s>, but expected: <%s>", curEntryNameInContext, resourceWrapper.getName()); thrownewErrorEntryFreeException(errorMessage); } else { // Go through the onExit hook of all slots. if (chain != null) { chain.exit(context, resourceWrapper, count, args);(1) } // Go through the existing terminate handlers (associated to this invocation). callExitHandlersAndCleanUp(context); // Restore the call stack. context.setCurEntry(parent); if (parent != null) { ((CtEntry) parent).child = null; } if (parent == null) { // Default context (auto entered) will be exited automatically. if (ContextUtil.isDefaultContext(context)) { ContextUtil.exit(); } } // Clean the reference of context in current entry to avoid duplicate exit. clearEntryContext(); } } }