Nav

How to Export Resources

Mule Applications, Mule Domains and Mule Policies contain a set of resources which may be properties files, DataWeave transformation files, Java classes, etc. By default, all of these files are internal to the artifact in which they are defined, and as a result, they are inaccessible from other artifacts. For instance, if a resource defined at the domain level is not explicitly exported, then it cannot be accessed from within any of the applications that belong to that shared domain. Another example is classes from an application that are meant to be used by the Java module. If those classes are not exported, then the Java module will not be able to access them.

How to export Java classes

To export Java classes, use the exportedPackages field of the mule-artifact.json file of your artifact. Keep in mind that only complete packages can be exported and not individual classes.


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
{
    "name": "MyApp",
    "minMuleVersion": "4.0.0",
    "classLoaderModelLoaderDescriptor": {
        "id": "mule",
        "attributes": {
            "exportedPackages": [
                "org.mule.myapp.api.customer",
                "org.mule.myapp.api.account"
            ]
        }
    }
}
Export the minimum number of classes required for your application to work. This will reduce the likelihood of conflicts with other artifacts, such as modules or connectors, that you may be using within your application.
Try to use .api. within public packages and .internal. within your non-public packages.

How to Export Resource Files

To export resources, use the exportedResources field of the mule-artifact.json file for your artifact.


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
    "name": "MyApp",
    "minMuleVersion": "4.0.0",
    "classLoaderModelLoaderDescriptor": {
        "id": "mule",
        "attributes": {
            "exportedResources": [
                "/org/mule/myapp/customer-to-user.dwl",
                "/org/mule/myapp/beans.xml"
            ]
        }
    }
  }
}
This same mechanism applies to every artifact, including custom extensions developed with the Mule SDK.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+