Mule Development structure - mule

I am trying to develop one mule application using eclipse plugin . Mule version is 3.1 . Which will be the base directory of my mule project (is it Mule_Home/apps folder) ?
Or I need to develop it outside of Mule bundle and place corresponding jar file under Mule_Home/lib/user directory ? If so then again need to place mule-config file under apps folder ?
Thank You

Here's the MuleStudio generated structure:
/lib
/mappings
/mule-project.xml
/src/main/api
/src/main/app
/src/main/java
/src/main/resources
/src/test
/src/test/resources
Your flows go in /src/main/app. Here's a sample pom file to build based on the structure above https://gist.github.com/tjsnell/8147194

You can refer below link for the format.
https://docs.mulesoft.com/mule-user-guide/v/3.7/application-format
Mule Application Format
The deployment unit of a Mule application encapsulates everything an >application needs to function, such as libraries, custom code, configuration, >deployment descriptor and any environment properties accompanying the >application. It exists in one of two formats:
.zip file (a regular archive with a 'zip' extension)
unpacked version of the same .zip file (exploded app)
\- classes // application-specific expanded resources (e.g. logging configuration files, properties, etc
|- lib // application-specific jars
|- plugins // application plugins files
\- lib // application shared plugin jars (FROM 3.7 and +)
|- mule-config.xml // Main Mule configuration file, also monitored for changes
|- mule-deploy.properties // Application deployment descriptor (optional)
|- mule-app.properties // custom properties to be added to the registry instance used by the application (optional)
|- *.grf files // produced by DataMapper to plot its data mapping
Mule supports the deployment of both packaged (zipped) and exploded (unzipped) applications.
You can share libraries between applications via the application deployment descriptor attribute.

It is better to know Mule Application Format

Tracy Snell is right. I use Anypoint Studio and the Mule source folder on the build path is src/main/app. That's where your mule-app.properties, mule.deploy.properties, and your project_name.xml go.

Mule-project.xml is the main xml to define your flow and you can add more xml's flows to your main xml if required and mule-app.properties and mule-deploy.properties will be loaded in the flow by default to acess the tokens.

You have to develop your new application in /src/main/app folder.
if you want to include any resources like static
properties that have to be developed in /src/main/resources folder.
if you want to include any java resources that has to be in /src/main/java.

Related

Adding External Files to Mulesoft AnyPoint Studio

I have a simple Hello World project in AnyPoint Studio. I have folder of additional files (a few jar files and some configuration files) I want to include with the project so they can get published to the cloud (CloudHub). How do I include these files into my project so when I publish my application the additional files are packaged with them.
Part 2 - Say I have a json file I want to read from my Mule application. What path do I reference the json file with after it is published?
Mule 4 projects are Maven based. You need to reference those jar files as Maven dependencies. You might need to install those projects in your local Maven repository. Search for Maven tutorials if needed. Ideally those JAR files are available in Maven repositories and you add only the dependency snippet in your pom.xml. If you are building yourself you can use mvn install command. If they are third party JAR files that you have the file only you have to use the mvn install but you need to define the coordinates (groupId, artifactId, version) yourself, which is not ideal and Maven won't be able to do automatic dependencies resolution for those JAR files. See this answer for details.
In your source project resource files should be in src/main/resources. At execution time you don't need to add a directory. If you add the file in a subdirectory of src/main/resources you need to use the subdirectory name only.

One properties configuration file for Multi Apps on Mule ESB runtime

Today I have the same properties configurated on mule-app.properties file for each Apps. Like this:
All Apps (+ that 5) are running on the same Mule ESB runtime (CE).
For example, when It is necessary to change a host or password, I need to change the properties file of the all apps.
I would like to have just one properties file on Mule ESB runtime shared by all apps.
Is there a form to make this?
Thanks!
You can create a new Mule project and call it "shared". Now, in this project, you can create a file src/main/resources/config.properties and there put all the settings you need.
To have these settings in your current project, just add the project "shared" in the "Projects" tab of the "Java Build Path". Then in the main file of your current project, write
< context: property-placeholder location="config.properties" />
Use a Spring Property Placeholder and read a single file from the filesystem:
<context:property-placeholder location="file:/path/to/myConfigFile.properties" />
https://docs.mulesoft.com/mule-user-guide/v/3.6/configuring-properties#properties-files

How to make a property file available to EJB in WebSphere Application Server 8

I created a JAX-WS Web Service and an EJB skeleton from a WSDL file by following a Tutorial in the Rational Application Developer for WebSphere 8.0.4 help.
It created an EJB project to contain my EJB code.
It created an EJBEar project to build an ear file.
It created a RouterWebProject to create a war file.
The RouterWebProject provides servlet information so that I can post an HTTP soap request to the servlet to be routed to my web service code in the EJB.
The EJB service code calls a class in the same EJB project that uses a ResourceBundle to read a property file with the name AppSDKExamples.properties
static {
ResourceBundle props = ResourceBundle.getBundle("AppSDKExamples", Locale.getDefault());
brokerPartnerId = props.getString("broker.partner.id");
buyPartnerId = props.getString("svc.dealer.partner.id");
sellPartnerId = props.getString("platform.partner.id");
sellPartnerId2 = props.getString("platform.partner.id2");
accountNumber = props.getString("account.number");
}
I have tried placing the AppSDKExamples.properties file everywhere I can think of but I always get a java.util.MissingResourceException.
How do I make this property file available to the EJB code?
Currently the EJB ear looks like this:
lib/AppSDKExamples.properties
lib/AppSDKExamples_en_US.properties
lib/other jar files
META-INF/MANIFEST.MF (this does not contain a class path I can't figure out how to set it.)
EJB.jar
WebProject.war
The EJB.jar looks like this:
com/activant/web/services/examples/class files that look for the property file
com/activant/web/services/iaptest/class files for the web service
META-INF/MANIFEST.MF (this has the AppSDKExamples.properties and AppSDKExamples_en_US.properties in the classpath)
AppSDKExamples.properties
AppSDKExamples_en_US.properties
The war file looks like this:
lib contains same jar files as the EJB.jar files has
META-INF (Class-Path: /lib EJB.jar)
WEB-INF/classes this folder contains both the propertie files.
WEB-INF/lib this folder contains both the properties files.
WEB-INF/ibm-web-bnd.xml
WEB-INF/ibm-web-ext.xml
WEB-INF/web.xml
Any help on this would be greatly appreciated.
Thanks.
If the properties files are at the root of the EJB, then the EJB class should be able to find the properties files. If you're running with Java 2 security enabled, then you'll need to grant FilePermission; see PROFILE_HOME/config/cells/CELL/nodes/NODE/app.policy for ${webComponent} and ${ejbComponent}.
Simply placing the properties files in EAR/lib won't work because the EAR/lib/ directory is not on the classpath, only the .jar files within it are on the classpath. It might work to add Class-Path: lib/ to the EJB jar MANIFEST.MF, but directory class paths are not required by the JavaEE spec, so I do not know if they are supported by WebSphere Application Server.
Referencing the properties files directly in the MANIFEST.MF Class-Path also doesn't work because only JARs and directories are supported (see above for JavaEE caveat regarding directories).
In general, it's probably best to remove the leading slash from /lib. It's unclear from the JavaEE platform specification whether this should refer to the lib directory in the EAR or to a directory in the root of the machine file system.

In what .targets file is the "Package" MSBuild target defined?

This pertains to Web Deploy and/or Web Deployment Projects (not sure what the relation is between those). Simply curious about the constituent Tasks that I might be able to recompose into a customized package Target.
The publishing targets for generating msdeploy web packages can be located at :
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets
In addition to playing with the tasks, there are a variety of properties you can use to redirect the packaging output name, location and configuration....

How do I get artifacts from one Maven module included in the resources of another in my build?

I have Maven modules that produce a Flex application as an SWF file. I want to include that file in a web application that is made with another Maven module from the same build. I'm wondering how and at which lifecycle phase I get Maven to grab the artifact from the other module and put it insode the appropriate folder of the webapp module. Would I use a separate assembly module?
The web app is running on a Jetty server in an OSGi environment (using Pax), the server side of the web app uses Struts. The final artifact as I see it would be a WAR file including my Action etc classes, JSP templates, static contents such as CSS or JS, and the SWF movies. I might be better off with these split over some other setup, but right now, I wouldn't know which.
I'm wondering how and at which lifecycle phase I get Maven to grab the artifact from the other module and put it insode the appropriate folder of the webapp module.
What about using dependency:unpack dependency:copy during prepare-package?