@Category
|
Anypoint Studio and the doclet use the @Category annotation to organize message processors. You can use @Category annotation at class definition level (Connector or Module) to select under which category you want your extension to be listed in:
@Connector(name = "ldap", schemaVersion = "3.5",
friendlyName="LDAP", minMuleVersion="3.5",
description="The LDAP connector connects to a
LDAP server and performs LDAP operations")
@Category(name = "org.mule.tooling.category.core",
description = "Components")
public class LDAPConnector
{
...
}
-
You can only add the connector to one of the existing Studio categories (this means you cannot define your own category)
-
The values for name and description attributes of @Category can only have these values:
-
Endpoints: org.mule.tooling.category.endpoints
-
Scopes: org.mule.tooling.category.scopes
-
Components: org.mule.tooling.category.core
-
Transformers: org.mule.tooling.category.transformers
-
Filters: org.mule.tooling.category.filters
-
Flow Control: org.mule.tooling.category.flowControl
-
Error Handling: org.mule.tooling.ui.modules.core.exceptions
-
Cloud Connectors (DEFAULT): org.mule.tooling.category.cloudconnector
-
Miscellaneous: org.mule.tooling.ui.modules.core.miscellaneous
-
Security: org.mule.tooling.category.security
You can use the following to specify the permitted categories:
import org.mule.api.annotations.Category;
@Category(name = "org.mule.tooling.category.endpoints", description = "Endpoints")
@Category(name = "org.mule.tooling.category.scopes", description = "Scopes")
@Category(name = "org.mule.tooling.category.core", description = "Components")
@Category(name = "org.mule.tooling.category.transformers", description = "Transformers")
@Category(name = "org.mule.tooling.category.filters", description = "Filters")
@Category(name = "org.mule.tooling.category.flowControl", description = "Flow Control")
@Category(name = "org.mule.tooling.ui.modules.core.exceptions", description = "Error Handling")
@Category(name = "org.mule.tooling.category.cloudconnector", description = "Cloud Connectors")
@Category(name = "org.mule.tooling.ui.modules.core.miscellaneous", description = "Miscellaneous")
@Category(name = "org.mule.tooling.category.security", description = "Security")
|
@Configurable
|
Marks a field inside a @Connector as being configurable. The @Configurable annotation signals the generator to create a property configurable for each instance of your connector through XML syntax or a connector configuration dialog box. In addition to the @Configurable annotation, you need at least one public get and set function.
@Configurable
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
|
@Connector
|
Defines a class that exports its functionality as a Mule connector.
This class-level annotation identifies a Java class as a Cloud Connector.
@Connector(name = "hello", schemaVersion = "1.0", friendlyName = "Hello", minMuleVersion = "3.5")
public class HelloConnector {
...
}
|
@Expr
|
Binds a parameter in a @Processor method to an expression.
Binding a parameter to an expression works similar to @Payload in the sense that the user of the module won’t be able to alter the expression or the value of the parameter from the XML. A binding is hardcoded and the user cannot change it.
The following example maps the myFlowVarXXX parameter to the result of the expression flowVars['xxx'] :
@Processor
public String myProcessor(@Expr("flowVars['xxx']")
String myFlowVarXXX) {
...
}
|
@ExpressionLanguage
|
Defines a class that exports its functionality as a Mule Expression Language.
@ExpressionLanguage restrictions on which types are valid:
@ExpressionLanguage(name = "expr")
public class ExprExpressionLanguage {
@ExpressionEvaluator
public Object evaluate() {
}
|
@ExpressionEnricher |
Marks a method inside an @ExpressionLanguage as the responsible for enriching mule messages based on an expression.
The following example shows how to use the @ExpressionEnricher annotation to set the payload (which is expected to be a map) in the enrich() method using the “map-payload” expression language:
@ExpressionLanguage(name = "map-payload")
public class MapPayloadExpressionLanguage {
@ExpressionEnricher
public void enrich() {
}
|
@Filter
|
Marks a method inside a @Connector as a callable from within a Mule flow that filters a message. Each parameter on this method is featured as an attribute on the Mule XML invocation.
By adding this annotation to a method inside @Connector , a filter is created which may be used from within a Mule flow to filter messages based on implementation of this method.
@Filter
public boolean shouldFilter() throws Exception {
...
}
|
@Ignore
|
Ignores a filed inside a complex object.
public class MyComplexType
{
private String color;
@Ignore
private String description;
}
@Processor
public void receiveAComplexType(MyComplexType myComplexType) { ... }
|
@Mime
|
Defines a class that exports its functionality as a Mule module.
The class level annotation @Module indicates that a Java class needs to be processed by the DevKit Annotation Processing Tool and considered as a Mule Module.
@Module cannot be applied to:
-
Interfaces
-
Final classes
-
Parameterized classes
-
Non-public classes
@Module(name="animal-search", schemaVersion="3.5.1")
public class AnimalSearchModule { ... }
|
@Ognl
|
(Object graph navigation language). Note: @ognl is deprecated in Mule version 3.6 and is being removed in version 4.0. |
@Paged
|
Marks a method inside a @Connector as an operation that returns a paged result set. Methods annotated with this interface must also be annotated with @Processor and must return an instance of @ProviderAwarePagingDelegate .
@Processor
@Paged
public ProviderAwarePagingDelegate paginationTestOperation (String ble, PagingConfiguration pagingConfiguration) throws WrongParameterConfiguredException { ... }
|
@Processor
|
Marks a method as an operation in a connector. An @Processor method generates a general purpose message processor
@Processor
public String putInBarn(String animal) {
return animal + " has been placed in the barn";
}
|
@Source
|
Marks a method inside a @Connector as a callable from within a Mule flow and capable of generating Mule events.
This annotation marks a method inside a Module as callable from within a Mule flow and capable of generating Mule events. Each marked method has an org.mule.api.source.MessageSource generated. The method must receive a SourceCallback as one of its arguments. It does not matter which parameter it is as long it is there.
@Source
public void subscribeTopic(String topic,
final SourceCallback callback) {
getBayeuxClient().subscribe(topic,
new ClientSessionChannel.MessageListener() {
@Override
public void onMessage(ClientSessionChannel channel,
Message message) {
try {
callback.process(message.getData());
} catch (Exception e) {
LOGGER.error(e);
}
}
});
}
|
@Transformer
|
Marks a method as a Transformer of data-types or as data formats in the context of the connector.
This annotation identifies a method that becomes a Mule transformer.
@Transformer(sourceTypes = { Object[].class })
public static List transformArrayToList(@Payload Object[] payload)
|
@TransformerResolver
|
Finds transformers that match a criteria in the registry. Implementations of this interface use some or all of the information passed in to discover a matching transformer.
Register implementations of this interface with the registry before an implementation can be picked up. Typically this is done using registry-bootstrap.properties .
@TransformerResolver
public static org.mule.api.transformer.Transformer
transformerResolver(DataType source, DataType result,
MuleContext muleContext) throws Exception {
if(source.getType().equals(Book.class) &&
result.getType().equals(String.class)) {
BookToString bookToString = new BookToString();
muleContext.getRegistry().
applyProcessorsAndLifecycle(bookToString);
return bookToString;
}
return null;
}
|