@Override public MetadataType getOutputType(MetadataContext context, Object key) throws MetadataResolvingException, ConnectionException { return context.getTypeBuilder().anyType().build(); } }
ForwardingSoapClient getConnection(MetadataContext context) throws MetadataResolvingException, ConnectionException { return context.<ForwardingSoapClient>getConnection() .orElseThrow(() -> new MetadataResolvingException("Cannot obtain connection", CONNECTION_FAILURE)); } }
@Override public MetadataType getOutputType(MetadataContext context, Object key) throws MetadataResolvingException, ConnectionException { return context.getTypeLoader().load(Apple.class); } }
protected <R> MetadataResult<R> runWithMetadataContext(Function<MetadataContext, MetadataResult<R>> contextConsumer) throws MetadataResolvingException, ConnectionException { MetadataContext context = null; try { MetadataCacheId cacheId = getMetadataCacheId(); MetadataCache metadataCache = metadataService.getMetadataCache(cacheId.getValue()); context = withContextClassLoader(classLoader, () -> getMetadataContext(metadataCache)); MetadataResult<R> result = contextConsumer.apply(context); if (result.isSuccess()) { metadataService.saveCache(cacheId.getValue(), metadataCache); } return result; } catch (MuleRuntimeException e) { // TODO(MULE-13621) this should be deleted once the configuration is created lazily in the getMetadataContext method. try { throw e.getCause(); } catch (MetadataResolvingException | ConnectionException cause) { throw cause; } catch (Throwable t) { throw e; } } finally { if (context != null) { context.dispose(); } } }
@Override public MetadataType getOutputType(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException { return buildMetadataType(context.getCache().computeIfAbsent(BRAND, (k) -> BRAND_VALUE)); }
/** * {@inheritDoc} */ @Override public MetadataResult<MetadataKeysContainer> getMetadataKeys() throws MetadataResolvingException { MetadataKeysContainerBuilder keysBuilder = MetadataKeysContainerBuilder.getInstance(); try { MetadataContext metadataContext = getMetadataContext(); addComponentKeys(getConfigurationModel().getOperationModels(), metadataContext, keysBuilder); addComponentKeys(getConfigurationModel().getSourceModels(), metadataContext, keysBuilder); metadataContext.dispose(); } catch (Exception e) { return failure(newFailure(e).onKeys()); } return success(keysBuilder.build()); }
@Override public MetadataType getOutputType(MetadataContext context, Object key) throws MetadataResolvingException, ConnectionException { return context.getTypeBuilder().anyType().build(); } }
@Override public MetadataType getOutputType(MetadataContext context, Object key) throws MetadataResolvingException, ConnectionException { return context.getTypeLoader().load(Apple.class); } }
public static Set<MetadataKey> getKeys(MetadataContext context) throws ConnectionException { return context.getConnection().map(c -> { MetadataConnection connection = (MetadataConnection) c; return connection.getEntities().stream().map(e -> MetadataKeyBuilder.newKey(e).build()).collect(toSet()); }).orElse(emptySet()); }
@Override public MetadataType getInputMetadata(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException { MetadataCache cache = context.getCache(); Optional<? extends Serializable> element = cache.get(BRAND); if (!element.isPresent()) { throw new MetadataResolvingException(MISSING_ELEMENT_ERROR_MESSAGE, FailureCode.RESOURCE_UNAVAILABLE); } return buildMetadataType((String) element.get()); }
protected <R> R runWithMetadataContext(Function<MetadataContext, R> metadataContextFunction) throws MetadataResolvingException, ConnectionException { MetadataContext context = null; R result; try { context = withContextClassLoader(getClassLoader(this.extensionModel), this::getMetadataContext); result = metadataContextFunction.apply(context); } catch (MuleRuntimeException e) { // TODO(MULE-13621) this should be deleted once the configuration is created lazily in the getMetadataContext method. try { throw e.getCause(); } catch (MetadataResolvingException | ConnectionException cause) { throw cause; } catch (Throwable t) { throw e; } } finally { if (context != null) { context.dispose(); } } return result; }
@Override public MetadataType getOutputType(MetadataContext context, Object key) throws MetadataResolvingException, ConnectionException { return context.getTypeBuilder().anyType().build(); } }
@Override public MetadataType getOutputType(MetadataContext context, CorrelationInfo key) { return context.getTypeLoader().load(CorrelationInfo.class); }
public static Set<MetadataKey> getKeys(MetadataContext context) throws ConnectionException { return context.getConnection().map(c -> { MetadataConnection connection = (MetadataConnection) c; return connection.getEntities().stream().map(e -> MetadataKeyBuilder.newKey(e).build()).collect(toSet()); }).orElse(emptySet()); }
/** * {@inheritDoc} */ @Override public MetadataResult<MetadataKeysContainer> getMetadataKeys() throws MetadataResolvingException { MetadataKeysContainerBuilder keysBuilder = MetadataKeysContainerBuilder.getInstance(); ClassLoader classLoader = getClassLoader(getExtensionModel()); return withContextClassLoader(classLoader, () -> { MetadataContext metadataContext = null; try { metadataContext = getMetadataContext(classLoader); addComponentKeys(getConfigurationModel().getOperationModels(), metadataContext, keysBuilder); addComponentKeys(getConfigurationModel().getSourceModels(), metadataContext, keysBuilder); return success(keysBuilder.build()); } catch (Exception e) { return failure(newFailure(e).onKeys()); } finally { if (metadataContext != null) { metadataContext.dispose(); } } }); }
@Override public MetadataType getOutputType(MetadataContext context, Object key) throws MetadataResolvingException, ConnectionException { return context.getTypeBuilder().anyType().build(); } }
@Override public MetadataType getOutputType(MetadataContext context, Object key) throws MetadataResolvingException, ConnectionException { return context.getTypeLoader().load(Apple.class); } }
@Override public MetadataType getInputMetadata(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException { MetadataCache cache = context.getCache(); Optional<? extends Serializable> element = cache.get(BRAND); if (!element.isPresent()) { throw new MetadataResolvingException(MISSING_ELEMENT_ERROR_MESSAGE, FailureCode.RESOURCE_UNAVAILABLE); } return buildMetadataType((String) element.get()); }