@Override public M getComponentModel() { return decorated.getComponentModel(); }
private Object streamingContent(Object value, ExecutionContextAdapter operationContext, CursorProviderFactory cursorProviderFactory, BaseEventContext eventContext) { if (value instanceof InputStream) { ConnectionHandler connectionHandler = (ConnectionHandler) operationContext.getVariable(CONNECTION_PARAM); if (connectionHandler != null && supportsStreaming(operationContext.getComponentModel())) { value = new ConnectedInputStreamWrapper((InputStream) value, connectionHandler); } } return StreamingUtils.streamingContent(value, cursorProviderFactory, eventContext); }
@Override public Supplier<NotificationEmitter> resolve(ExecutionContext executionContext) { return () -> { ExecutionContextAdapter adaptedExecutionContext = (ExecutionContextAdapter) executionContext; return new DefaultNotificationEmitter(adaptedExecutionContext.getMuleContext().getNotificationManager(), adaptedExecutionContext.getEvent(), adaptedExecutionContext.getComponent(), adaptedExecutionContext.getComponentModel()); }; }
private Collection<Object> toLazyMessageCollection(Collection<Result> values, ExecutionContextAdapter operationContext, CursorProviderFactory cursorProviderFactory, MediaType mediaType, CoreEvent event) { Collection<Object> lazyMessageCollection = new ArrayList<>(); values.forEach(value -> { if (value.getOutput() instanceof InputStream) { ConnectionHandler connectionHandler = (ConnectionHandler) operationContext.getVariable(CONNECTION_PARAM); if (connectionHandler != null && supportsStreaming(operationContext.getComponentModel())) { value = value.copy() .output(new ConnectedInputStreamWrapper((InputStream) value.getOutput(), connectionHandler)) .build(); } Message message = MessageUtils.toMessage(value, mediaType, cursorProviderFactory, event); lazyMessageCollection.add(message); } else { lazyMessageCollection.add(value); } }); return lazyMessageCollection; }
@Before public void before() throws Exception { when(operationContext.getConfiguration()).thenReturn(Optional.of(configurationInstance)); when(operationContext.getComponentModel()).thenReturn(operationModel); when(operationModel.getModelProperty(PagedOperationModelProperty.class)).thenReturn(empty()); when(configurationInstance.getValue()).thenReturn(config); Map<String, Object> contextVariables = new HashMap<>(); when(operationContext.getVariable(any())).thenAnswer( invocationOnMock -> contextVariables .get(invocationOnMock.getArguments()[0])); when(operationContext.setVariable(any(), any())).thenAnswer(invocationOnMock -> { final Object[] arguments = invocationOnMock.getArguments(); return contextVariables.put((String) arguments[0], arguments[1]); }); when(operationContext.removeVariable(any())) .thenAnswer(invocationOnMock -> contextVariables.remove(invocationOnMock.getArguments()[0])); when(operationContext.getTransactionConfig()).thenReturn(empty()); interceptor = new ConnectionInterceptor(); setupConnectionSupplier(); }
private <T extends TransactionalConnection> ConnectionHandler<T> getTransactedConnectionHandler( ExecutionContextAdapter<? extends ComponentModel> executionContext, TransactionConfig transactionConfig) throws ConnectionException, TransactionException { if (!transactionConfig.isTransacted()) { return getTransactionlessConnectionHandler(executionContext); } ExtensionModel extensionModel = executionContext.getExtensionModel(); ComponentModel componentModel = executionContext.getComponentModel(); ConfigurationInstance configuration = executionContext.getConfiguration() .orElseThrow(() -> new IllegalStateException(format( "%s '%s' of extension '%s' cannot participate in a transaction because it doesn't have a config", getComponentModelTypeName(componentModel), componentModel.getName(), extensionModel.getName()))); final ExtensionTransactionKey txKey = new ExtensionTransactionKey(configuration); TransactionBindingDelegate transactionBindingDelegate = new TransactionBindingDelegate(extensionModel, componentModel); return transactionBindingDelegate.getBoundResource(transactionConfig, txKey, () -> getTransactionlessConnectionHandler(executionContext)); }
.debug(format("AccessToken for resourceOwner '%s' expired while executing operation '%s:%s' using config '%s'. " + "Will attempt to refresh token and retry operation", connectionProvider.getResourceOwnerId(), getExtensionModel().getName(), operationContext.getComponentModel().getName(), operationContext.getConfiguration().get().getName())); connectionProvider.getResourceOwnerId(), getExtensionModel().getName(), operationContext.getComponentModel().getName(), operationContext.getConfiguration().get() .getName())),
@Before public void before() throws MuleException { streamingManager = new DefaultStreamingManager(); LifecycleUtils.initialiseIfNeeded(streamingManager, muleContext); event = eventBuilder(muleContext).message(Message.builder().value("").attributesValue(attributes).build()).build(); when(outputModel.getType()).thenReturn(BaseTypeBuilder.create(JAVA).voidType().build()); when(outputModel.getModelProperty(any())).thenReturn(empty()); when(outputModel.getModelProperties()).thenReturn(emptySet()); when(outputModel.getDescription()).thenReturn(""); when(componentModel.getModelProperty(MediaTypeModelProperty.class)).thenReturn(empty()); when(componentModel.getOutput()).thenReturn(outputModel); delegate = createReturnDelegate(); when(operationContext.getEvent()).thenReturn(event); when(operationContext.getMuleContext()).thenReturn(muleContext); when(operationContext.getComponentModel()).thenReturn(componentModel); when(operationContext.getVariable(contains(CONNECTION_PARAM))).thenReturn(connectionHandler); }
@Override public M getComponentModel() { return decorated.getComponentModel(); }
if (resultValue.getOutput() instanceof InputStream) { ConnectionHandler connectionHandler = (ConnectionHandler) operationContext.getVariable(CONNECTION_PARAM); if (connectionHandler != null && supportsStreaming(operationContext.getComponentModel())) { resultValue = resultValue.copy() .output(new ConnectedInputStreamWrapper((InputStream) resultValue.getOutput(), connectionHandler))
private <T extends TransactionalConnection> ConnectionHandler<T> getTransactedConnectionHandler( ExecutionContextAdapter<? extends ComponentModel> executionContext, TransactionConfig transactionConfig) throws ConnectionException, TransactionException { if (!transactionConfig.isTransacted()) { return getTransactionlessConnectionHandler(executionContext); } ExtensionModel extensionModel = executionContext.getExtensionModel(); ComponentModel componentModel = executionContext.getComponentModel(); ConfigurationInstance configuration = executionContext.getConfiguration() .orElseThrow(() -> new IllegalStateException(format( "%s '%s' of extension '%s' cannot participate in a transaction because it doesn't have a config", getComponentModelTypeName(componentModel), componentModel.getName(), extensionModel.getName()))); final ExtensionTransactionKey txKey = new ExtensionTransactionKey(configuration); TransactionBindingDelegate transactionBindingDelegate = new TransactionBindingDelegate(extensionModel, componentModel); return transactionBindingDelegate.getBoundResource(transactionConfig, txKey, () -> getTransactionlessConnectionHandler(executionContext)); }
@Override public LazyValue<NotificationEmitter> resolve(ExecutionContext executionContext) { return new LazyValue<>(() -> { ExecutionContextAdapter adaptedExecutionContext = (ExecutionContextAdapter) executionContext; return new DefaultNotificationEmitter(adaptedExecutionContext.getMuleContext().getNotificationManager(), adaptedExecutionContext.getEvent(), adaptedExecutionContext.getComponent(), adaptedExecutionContext.getComponentModel()); }); }
.debug(format("AccessToken for resourceOwner '%s' expired while executing operation '%s:%s' using config '%s'. " + "Will attempt to refresh token and retry operation", connectionProvider.getResourceOwnerId(), getExtensionModel().getName(), operationContext.getComponentModel().getName(), operationContext.getConfiguration().get().getName())); connectionProvider.getResourceOwnerId(), getExtensionModel().getName(), operationContext.getComponentModel().getName(), operationContext.getConfiguration().get() .getName())),