wso2 custom mediator inside carbon app - esb

I developed a custom mediator and its corresponding Factory/Serializer classes so that I can configure complex configuration options for it inside a sequence. This was made with a carbon app project using carbon studio.
The thing is that the only way I can make the configuration element to work is by deploying the jar file outside the .car file.
Can I just deploy the .car file to make it work? Where do I have to put the META-INF/services folder in order to work properly?
Here's my CarbonAppProject structure
CarbonApp
+--artifacts
+--lib
+--library
+--bundle
+--jXLS <-- Java Library Artifact
+--synapse
+--mediator
+--XlsToObjectMediator <-- Custom Mediator Artifact
+--builder
+--META-INF
+--services
+--org.apache.synapse.config.xml.MediatorFactory <-- FILE
+--org.apache.synapse.config.xml.MediatorSerializer <-- FILE
+--src
+--main
+--java
+--<package> <-- mediator, factory and serializer clases
Any help will be much appreciated.

You cannot get this to work with this version of Carbon Studio but it is possible to get it work with newer version of it. You can get the newer version from http://builder1.us1.wso2.org/~developerstudio/developer-studio/2.0.0/RC1/wso2-developer-studio_2.0.0.RC1.zip
Steps.
Create a ESB Custom mediator project and create your mediator sources there
Copy the META-INF/services folder to the src/main/resources folder of the same project.
Build the Custom Mediator project with Maven
Create a Java Library Artifact project and make sure to add jXLS library to it.
Build the Java Library Artifact Project with Maven
Create Carbon Application Project
Add the Custom Mediator Project and Java Library Artifact project as dependencies of the Carbon Application Project.
Build the C-App project with Maven
Now you will be able to get the ESB Custom Mediator running in ESB without any issue.
.
|-- pom.xml
`-- src
`-- main
|-- java
| `-- ddd
| `-- dd.java
`-- resources
`-- META-INF
`-- services
|-- org.apache.synapse.config.xml.MediatorFactory
`-- org.apache.synapse.config.xml.MediatorSerializer
Your mediator project structure would be similar to above
Hope this helps!!
Thankss.
/Harshana

I don't think declaring a project level dependency between JavaLibraryArtifact project and Custom mediator project will solve this.
But you can achieve this by adding the dependency to the actual 3rd Party Library from the mediator project.
Steps:
Right click on the Custom mediator project, select Build Path -> Configure Build Path
Go to Libraries Tab and Select "Add Jars" button. This will populate the Project Browser dialog
Expand the JavaLibraryArtifact Project in the Project Browser and select the jXLS library from the file list in there and click on "Ok"
Now you have added the jXLS to your Custom mediator project buildpath. So you won't see any errors in your Custom Mediator project.
If you open the .Classpath file of the Custom mediator project, you will see an entry similar to following.
<classpathentry kind="lib" path="/JavaLibArtifactProject/jXLS.jar"/>
To avoid compilation errors from Maven, you need to add a Dependency to jXLS library in the Custom mediator project pom.xml.
By following the above steps you can avoid duplicating the JXLS library in your projects.
Hope this helps!!
Thanks.
/Harshana

Related

Is there a way to host HTML within hybris 6.7?

I have setup a custom storefront for my hybris project.
I have added a react project(package.json is the custom storefront's folder) within WEB-INF folder.
Using webpack to bundle and code split my js and css.
Is there a way to host the HTML file within Hybris 6.7?
P.S - can't do a separate frontend project, hence this question.
I'm not sure I understand what you are looking for, but you can create a new extension with a web module. This web module can have a page.
See Extension Modules: https://help.sap.com/viewer/b490bb4e85bc42a7aa09d513d0bcb18e/6.7.0.0/en-US/3a3b92d4900b4b3685157b806a73eab2.html

MSBuild doing OctoPack before Publish

I have a C# .NET v4.6.1 compiled Azure Function, I am using Microsoft.NET.Sdk.Functions and I deploy it using my usual CI/CD Pipeline.
That being, a TeamCity MSBuild Build Step to create an OctoPack (because I have installed the OctoPack 3.6.3 NuGet package.
I then publish the resulting *.nupkg file to Octopus and Create a Release.
This is how I do all my Azure App Services, however as is nicely described in this post, compiled Azure Functions create a few extra files/folders when they are published to describe the entry point for the Function.
I can see (in the TeamCity build logs) that these extra files/folders are created by MSBuild (15.3.409.57025) but only AFTER it has prepared the OctoPack. Meaning my OctoPack artifact does not contain the necessary function specific folder(s) with the function.json file nor the functionsSdk.out.
I have managed to get around this issue by doing an extra TeamCity NuGet Pack Build Step to build the OctoPack again. I also had to create a *.nuspec file in the project root, where I tell NuGet Pack to include everything (see below) because using just the *.csproj file also ignored the extra folder/files.
<files>
<file src="bin\Release\net461\**\*.*" />
</files>
This works because it runs after the MSBuild Step and the extra folders/files are present. It will also be robust enough to support other Functions when are added to the Project going forward.
The need for this extra step and the *.nuspec file seems unnecessary. Can anyone see where I went wrong and why MSBuild seems to have the sequence of Publish and OctoPak wrong?
This could be a reason:
If the section exists, OctoPack by default won't attempt to
automatically add any extra files to your package, so you'll need to
be explicit about which files you want to include. You can override
this behavior with /p:OctoPackEnforceAddingFiles=true which will
instruct OctoPack to package a combination of files using its
conventions, and those defined by your section.
https://octopus.com/docs/packaging-applications/creating-packages/nuget-packages/using-octopack
Another idea — broken .csproj file. Please check it.
Maybe, during the merge these two lines were reordered:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\OctoPack.3.6.3\build\OctoPack.targets" Condition="Exists('..\packages\OctoPack.3.6.3\build\OctoPack.targets')" />
There should be Microsoft.CSharp.targets first. Order matters.
Workaround: OctoPack running after publish
<Target Name="SetRunOctoPack">
<PropertyGroup>
<RunOctoPack>true</RunOctoPack>
</PropertyGroup>
</Target>
<Target Name="AfterPublish" DependsOnTargets="SetRunOctoPack">
<CallTarget Targets="OctoPack"/>
</Target>

Package HTML, CSS, JS in Jar or ZIP

Is it possible to either pack only html, css and JS files in jar (no java binaries) which would then be packed into war for deployment to Tomcat?
or
Can I pack html, css, js files (no java classes) into a zip and pack it into a war for deployment to Tomcat? With this option, would Tomcat unpack the zip as needed?
If you are deploying to Tomcat (and there is presumably some java or JSP code associated with this) then you should use a .war file.
To incorporate purely web assets into the building of a .war, then you need to use an "overlay". There are various Maven plugins and Ant tools which do specifically this.
However, one other possible consideration, is to deploy your web assets directly to your HTTP server (ie. Apache) and then configure it to serve /css/*, /js/*, etc, from there, and every other request can be forwarded to Tomcat.

Can't add the Mobile Apps Tracking bindings to my project

I'm trying to use the MAT bindings in my project however it seems that the .jar file is not included on: http://libgdx.badlogicgames.com/robovm-ios-bindings/
I have also tried adding it to my project by downloading the repository from: https://github.com/BlueRiverInteractive/robovm-ios-bindings/tree/master/mobileapptracking and adding the project to my Robovm build path but it's not working as well.
Any idea how to solve this ?
Thanks,
ASM
I have made a bindings project into a jar file doing the following. I am sure there is an easier way to get the framework in the correct folder, but I have not yet found it.
load bindings project in eclipse
export the source folder (you should get org/robovm/bindings/mobileapptracking/) to .jar file
open the jar file with winrar or similar program
add folder: robovm/ios/libs/ in META-INF folder
add the .framework(s) to this folder
now you should have a similar .jar file as on the libgdx site!

Deploying Resources with Play! Framework

My web application uses MyBatis ORM. As a part of this, I have the typical mybatis.xml config file along with mappers for my SQL. When running the Play! server, the directory with these resources is not picked up and added to the classes directory.
Is there a way to configure Play! to include this directory in it's load/deploy process?
With Play 1.x the simplest way to do this is to put your files in the conf directory which is in the classpath