Change Category for custom Connector using Anypoint Devkit in Mule ESB

By default, when you create a custom connector using Anypoint Devkit in the Mule ESB, the category of the custom connector will be the Connectors.

For example, I create an Anypoint Connector Project as follows:

Change Category for custom Connector using Anypoint Devkit in Mule ESB

After right-clicking on the project, selecting Anypoint Connector and selecting Install or Update, you will see this Connector appear in the Connectors category of Mule Palete as follows:

Change Category for custom Connector using Anypoint Devkit in Mule ESB

In the sense, if your Connector is connecting to a particular system, this default category seems correct. But if it does not do these things, then if we keep the default category for it, it will not be very reasonable.

In the Mule ESB, a connector has the following categories:

  • Connectors
  • Scopes
  • Endpoints
  • Components
  • Transformers
  • Filters
  • Flow Control
  • Error Handling
  • Miscellaneous
  • Security

Choosing the right category that our Connector belongs to, will help us when using our Connector feel more comfortable, more reasonable.

So how to change this default category? Anypoint Devkit allows us to do this by using the @Category annotation (org.mule.api.annotations.Category) in the main class of our Connector.

In this annotation @Category we have an attribute name, declaring the value of this name attribute will help us set the correct category for our Connector.

Here is a list of the values of the name attribute in the @Category annotation for each category:

  • Connectors (DEFAULT): org.mule.tooling.category.cloudconnector
  • Scopes: org.mule.tooling.category.scopes
  • Endpoints: org.mule.tooling.category.endpoints
  • 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
  • Miscellaneous: org.mule.tooling.ui.modules.core.miscellaneous
  • Security: org.mule.tooling.category.security

Assuming now, I want to set the Connector category in the example above to Components, I will edit the HuongDanJavaConnector class to add the @Category annotation as follows:

Then, you will see our Connector appear in the Components category of the Mule Palete as follows:

Change Category for custom Connector using Anypoint Devkit in Mule ESB

Change Category for custom Connector using Anypoint Devkit in Mule ESB
Đánh giá bài viết
Chia sẽ bài viết này ...Share on Facebook
Facebook
3Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.