Class JavaInvokeOperations
java.lang.Object
org.mule.extensions.java.internal.operation.JavaInvokeOperations
Defines the operations of
JavaModule related to invocation of class or instance methods using reflection.- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioninvoke(MethodIdentifier identifier, Object instance, Map<String, org.mule.runtime.api.metadata.TypedValue<Object>> args, String outputMimeType, String outputEncoding, String defaultEncoding) Operation that allows the user to invoke methods with the providedargson the giveninstance.invokeStatic(StaticMethodIdentifier identifier, Map<String, org.mule.runtime.api.metadata.TypedValue<Object>> args, String outputMimeType, String outputEncoding, String defaultEncoding) Operation that allows the user to invoke static methods with the provided arguments.
-
Constructor Details
-
JavaInvokeOperations
public JavaInvokeOperations()
-
-
Method Details
-
invokeStatic
@Throws(JavaStaticInvokeErrorProvider.class) @OutputResolver(output=StaticMethodTypeResolver.class) @Execution(BLOCKING) public org.mule.runtime.extension.api.runtime.operation.Result<Object,Void> invokeStatic(@ParameterGroup(name="Method") @MetadataKeyId(StaticMethodTypeResolver.class) StaticMethodIdentifier identifier, @Optional @NullSafe @Content @TypeResolver(StaticMethodTypeResolver.class) Map<String, org.mule.runtime.api.metadata.TypedValue<Object>> args, @Optional @Placement(tab="MIME Type") @Summary("The mime type of the payload that this invocation will output") String outputMimeType, @Optional @Placement(tab="MIME Type") @Summary("The encoding of the payload that this invocation will output") String outputEncoding, @DefaultEncoding String defaultEncoding) throws ClassNotFoundModuleException, ArgumentMismatchModuleException, InvocationModuleException, NoSuchMethodModuleExceptionOperation that allows the user to invoke static methods with the provided arguments. The identifier of theMethodto be invoked includes theclassandmethodnames, being themethoda full description of its signature including the types of each parameter.For example, if we want to invoke the static method
echowith signaturepublic static String echo(String msg)which belongs toClassorg.bar.Foo, then the identifier of the method will be"echo(String)"- Parameters:
identifier- the unique identifier for the method to be invoked.args- the arguments used to invoke the givenMethod. This parameter must be a map with the names of the method arguments as keys, and each of the argument values as values. For example, given a methodechowith signaturepublic String echo(String msg, String volume)a possible value for args is: #[{ msg : 'This is a message to echo', volume : 'Loud' }] In order to use those argument names the java class must be compiled with -parameters, in other case you have to use the canonical names for the arguments: #[{ arg0 : 'This is a message to echo', arg1 : 'Loud' }] You can always use the canonical name for the arguments, even if the source code was compiled with -parameters.outputMimeType- The mime type of the payload that this invocation will outputoutputEncoding- The encoding of the payload that this invocation will output- Returns:
- the result of the
Methodinvocation with the givenargs - Throws:
ClassNotFoundModuleException- if the givenclassis not found in the current contextNoSuchMethodModuleException- if the givenclassdoes not declare a method with the given signatureArgumentMismatchModuleException- if themethodrequires a different set of arguments than the ones providedInvocationModuleException- if an error occurs during the execution of the method
-
invoke
@Throws(JavaInvokeErrorProvider.class) @OutputResolver(output=InstanceMethodTypeResolver.class) @Execution(BLOCKING) public org.mule.runtime.extension.api.runtime.operation.Result<Object,Void> invoke(@ParameterGroup(name="Method") @MetadataKeyId(InstanceMethodTypeResolver.class) MethodIdentifier identifier, Object instance, @Optional @NullSafe @Content @TypeResolver(InstanceMethodTypeResolver.class) Map<String, org.mule.runtime.api.metadata.TypedValue<Object>> args, @Optional @Placement(tab="MIME Type") @Summary("The mime type of the payload that this invocation will output") String outputMimeType, @Optional @Placement(tab="MIME Type") @Summary("The encoding of the payload that this invocation will output") String outputEncoding, @DefaultEncoding String defaultEncoding) throws ClassNotFoundModuleException, WrongTypeModuleException, ArgumentMismatchModuleException, InvocationModuleException, NoSuchMethodModuleExceptionOperation that allows the user to invoke methods with the providedargson the giveninstance. The identifier of theMethodto be invoked includes theclassandmethodnames, being themethoda full description of its signature including the types of each parameter.For example, if we want to invoke the method
echowith signaturepublic String echo(String msg)which belongs toClassorg.bar.Foo, then the identifier of the method will be"echo(String)"- Parameters:
identifier- the unique identifier for the method to be invokedinstance- the instance on which themethodwill be invokedargs- the arguments used to invoke the givenMethod. This parameter must be a map with the names of the method arguments as keys, and each of the argument values as values. For example, given a methodechowith signaturepublic String echo(String msg, String volume)a possible value for args is: #[{ msg : 'This is a message to echo', volume : 'Loud' }] In order to use those argument names the java class must be compiled with -parameters, in other case you have to use the canonical names for the arguments: #[{ arg0 : 'This is a message to echo', arg1 : 'Loud' }] You can always use the canonical name for the arguments, even if the source code was compiled with -parameters.outputMimeType- The mime type of the payload that this invocation will outputoutputEncoding- The encoding of the payload that this invocation will output- Returns:
- the result of the
Methodinvocation with the givenargs - Throws:
ClassNotFoundModuleException- if the givenclassis not found in the current contextNoSuchMethodModuleException- if the givenclassdoes not declare a method with the given signatureArgumentMismatchModuleException- if themethodrequires a different set of arguments than the ones providedWrongTypeModuleException- if the giveninstanceis not an instance of the expectedclassInvocationModuleException- if an error occurs during the execution of the method
-