@Override public TypeBuilder<?> handle(Schema schema, BaseTypeBuilder root, HandlerManager handlerManager, ParsingContext parsingContext) { final EnumSchema enumSchema = (EnumSchema) schema; final StringTypeBuilder enumMetadataBuilder = root.stringType(); final Set<Object> possibleValues = enumSchema.getPossibleValues(); final String[] stringValues = possibleValues.stream().map((v) -> String.valueOf(v)).toArray(String[]::new); enumMetadataBuilder.enumOf(stringValues); return enumMetadataBuilder; } }
@Override public TypeBuilder<?> handleClass(Class<?> clazz, List<Type> genericTypes, TypeHandlerManager typeHandlerManager, ParsingContext context, BaseTypeBuilder<?> typeBuilder) { final StringTypeBuilder<?> enumType = typeBuilder.stringType(); enumType.id(clazz.getCanonicalName()); final Object[] enumConstants = clazz.getEnumConstants(); final String[] enumOf = new String[enumConstants.length]; for (int i = 0; i < enumConstants.length; i++) { final Object enumConstant = enumConstants[i]; enumOf[i] = String.valueOf(enumConstant); } enumType.enumOf(enumOf); return enumType; } }
@Override public TypeBuilder<?> handleClass(Class<?> clazz, List<Type> genericTypes, TypeHandlerManager typeHandlerManager, ParsingContext context, BaseTypeBuilder typeBuilder) { final StringTypeBuilder enumType = typeBuilder.stringType(); enumType.id(clazz.getCanonicalName()); final Object[] enumConstants = clazz.getEnumConstants(); final String[] enumOf = new String[enumConstants.length]; for (int i = 0; i < enumConstants.length; i++) { final Enum enumConstant = (Enum) enumConstants[i]; enumOf[i] = enumConstant.name(); } enumType.enumOf(enumOf); return enumType; } }
private void declareTry(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer tryScope = extensionDeclarer.withConstruct("try") .describedAs("Processes the nested list of message processors, " + "within a transaction and with it's own error handler if required."); tryScope.onDefaultParameterGroup() .withOptionalParameter("transactionalAction") .ofType(BaseTypeBuilder.create(JAVA).stringType() .enumOf("INDIFFERENT", "ALWAYS_BEGIN", "BEGIN_OR_JOIN").build()) .defaultingTo("INDIFFERENT") .withExpressionSupport(NOT_SUPPORTED) .withLayout(LayoutModel.builder().tabName("Transactions").build()) .describedAs("The action to take regarding transactions. By default nothing will be done."); tryScope.onDefaultParameterGroup() .withOptionalParameter("transactionType") .ofType(BaseTypeBuilder.create(JAVA).stringType().enumOf("LOCAL", "XA").build()) .defaultingTo("LOCAL") .withExpressionSupport(NOT_SUPPORTED) .describedAs("Transaction type supported. Availability will depend on the runtime version, " + "though LOCAL is always available."); tryScope.withChain(); tryScope.withOptionalComponent("errorHandler") .withAllowedStereotypes(ERROR_HANDLER); }
private void declareFlow(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { ConstructDeclarer flow = extensionDeclarer.withConstruct(FLOW_ELEMENT_IDENTIFIER) .allowingTopLevelDefinition() .withStereotype(FLOW); flow.onDefaultParameterGroup().withOptionalParameter("initialState").defaultingTo("started") .ofType(BaseTypeBuilder.create(JAVA).stringType().enumOf("started", "stopped").build()); flow.onDefaultParameterGroup().withOptionalParameter("maxConcurrency") .ofType(typeLoader.load(Integer.class)); flow.withComponent("source") .withAllowedStereotypes(MuleStereotypes.SOURCE); flow.withChain().setRequired(true); flow.withComponent("errorHandler") .withAllowedStereotypes(ERROR_HANDLER); }
private void declareLogger(ExtensionDeclarer extensionDeclarer, ClassTypeLoader typeLoader) { OperationDeclarer logger = extensionDeclarer.withOperation("logger") .describedAs("Performs logging using an expression that determines what should be logged. By default the current messages is logged " + "using the DEBUG level to the \u0027org.mule.runtime.core.api.processor.LoggerMessageProcessor\u0027 category but " + "the level and category can both be configured to suit your needs. message is specified then the current message is used."); logger.withOutput().ofType(typeLoader.load(void.class)); logger.withOutputAttributes().ofType(typeLoader.load(void.class)); logger.onDefaultParameterGroup() .withOptionalParameter("message") .ofType(typeLoader.load(String.class)) .describedAs("Message that will be logged. Embedded expressions can be used to extract value from the current message. " + "If no message is specified then the current message is used."); logger.onDefaultParameterGroup() .withOptionalParameter("level") .defaultingTo("DEBUG") .ofType(BaseTypeBuilder.create(JAVA).stringType() .enumOf("ERROR", "WARN", "INFO", "DEBUG", "TRACE").build()) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The logging level to be used. Default is DEBUG."); logger.onDefaultParameterGroup() .withOptionalParameter("category") .ofType(typeLoader.load(String.class)) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The log category to be used"); }
private void declareOnErrorRoute(ClassTypeLoader typeLoader, NestedRouteDeclarer onError) { onError.withChain(); onError.onDefaultParameterGroup() .withOptionalParameter("when") .ofType(typeLoader.load(String.class)) .describedAs("The expression that will be evaluated to determine if this exception strategy should be executed. " + "This should always be a boolean expression."); onError.onDefaultParameterGroup() .withOptionalParameter("type") .ofType(BaseTypeBuilder.create(JAVA).stringType() .enumOf("ANY", "REDELIVERY_EXHAUSTED", "TRANSFORMATION", "EXPRESSION", "SECURITY", "CLIENT_SECURITY", "SERVER_SECURITY", "ROUTING", "CONNECTIVITY", "RETRY_EXHAUSTED", "TIMEOUT") .build()) .withExpressionSupport(NOT_SUPPORTED) .describedAs("The full name of the error type to match against or a comma separated list of full names, " + "to match against any of them."); onError.onDefaultParameterGroup() .withOptionalParameter("logException") .ofType(typeLoader.load(boolean.class)) .defaultingTo(true) .describedAs("Determines whether the handled exception will be logged to its standard logger in the ERROR " + "level before being handled. Default is true."); onError.onDefaultParameterGroup() .withOptionalParameter("enableNotifications") .ofType(typeLoader.load(boolean.class)) .defaultingTo(true) .withExpressionSupport(NOT_SUPPORTED) .describedAs("Determines whether ExceptionNotifications will be fired from this strategy when an exception occurs." + " Default is true."); }