Mulesoft Anypoint Studio DevKit - #Connector vs #Module ( No need for config-ref ) - mule

I am trying to create a component that does not need a connection to another source or for that fact a connection strategy... but no matter what I try I cannot prevent the component from having a "Basic Settings" > "Connector Configuration" dropdown/create/edit section in the "Mule Properties" section when working with the components settings.
Does anyone know how I create an Anypoint DevKit Component that does not need a "Connector Configuration" ?
My understanding is that annotations play a big role in defining this and that the connecotr uses the #Connector and that someone has mentioned to me the need to substitute this with the #Module annotation as this indicates no need for a connection... but even when doing this the config options remain on the component.
Please see the following code:
( note : I am trying to create a custom logger and need only to have several inputs and a dropdown operation which I can already get working. )
package au.com.company.companylogger;
import org.mule.api.annotations.Configurable;
import org.mule.api.annotations.Module;
import org.mule.api.annotations.Processor;
import org.mule.api.annotations.param.Default;
import org.mule.api.annotations.param.Optional;
#Module(name="company-logger", friendlyName="companyLogger", schemaVersion="1.0.0-SNAPSHOT")
public class companyLoggerConnector {
#Processor(name="company-logger-trace", friendlyName="TRACE")
public String companyLoggerTrace(String strStep) {
/*
* MESSAGE PROCESSOR CODE GOES HERE
*/
return "TRACE : " + strStep;
}
#Processor(name="company-logger-debug", friendlyName="DEBUG")
public String companyLoggerDebug(String strStep) {
/*
* MESSAGE PROCESSOR CODE GOES HERE
*/
return "DEBUG : " + strStep;
}
}
I unfortunately do not have enough reputation to provide you with an image of the config I do not need.
Any help or suggestions are welcomed.

With Anypoint Devkit 3.6, the "config-ref" attribute on elements became required, so you NEED to create a global element definition for your connector. As far as I know, there isn't a way to get around this at this point.
HTH

The config element name can be changed using the configElementName attribute in #Connector or #Module
#Module(name="company-logger", friendlyName="companyLogger", configElementName="xx", schemaVersion="1.0.0-SNAPSHOT")
If you do not set this attribute, it will default to "config". May be if you provide an empty string or null then it will not show up. I haven't tried it before though.

Related

Grails Auto generated code is with warnings and errors

I am using Intellij IDEA Ultimate and have Grails plugin installed. When i auto generate, let's say controller i have warnings like so : "Cannot infer argument types " for this code :
multipartForm {
flash.message = message(code: 'default.created.message',
args: [message(code: 'tekEvent.label',
default: 'TekEvent'), tekEventInstance.id])//We need id to see in created message
redirect tekEventInstance //redirect will open show() view and populate it with instance's data
}
And an error for 'tekEvent.label' .
Have MANY errors in generated views as well. It's not just me. My 3 fellows in team have the same problem as well. Would like to get a "Light" from you and pass it to them as well . Thanks ^_^

quarkus reactive getting started PUT and DELETE operations

I'm going through the quarkus reactive getting started page and PUT and DELETE method implementations are missing.
Seem like it assumes we already know quarkus and are just reading the guide to switch from non-reactive to reactive. Why they don't provide a full example, I don't know. I mean where would you learn if not by a guide or someone showing you how it's done?
PUT should replace an entry and DELETE should delete one.
PUT /{id} = replace
DELETE /{id} = delete
Instead of Fruit my entity is named Profile.
package de.icod.reso.resources;
import de.icod.reso.entities.Profile;
import io.quarkus.hibernate.reactive.panache.Panache;
import io.quarkus.panache.common.Sort;
import io.smallrye.mutiny.Uni;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.net.URI;
import java.util.List;
import java.util.UUID;
#Path("/profile")
#ApplicationScoped
#Produces(MediaType.APPLICATION_JSON)
#Consumes(MediaType.APPLICATION_JSON)
public class ProfileResource {
#GET
public Uni<List<Profile>> get() {
return Profile.listAll(Sort.by("name"));
}
#GET
#Path("/{id}")
public Uni<Profile> getSingle(UUID id) {
return Profile.findById(id);
}
#POST
public Uni<Response> create(Profile profile) {
return Panache.<Profile>withTransaction(profile::persist)
.onItem().transform(inserted -> Response.created(URI.create("/profile" + inserted.id)).build());
}
#PUT
#Path("/{id}")
public Uni<Response> replace(UUID id, Profile profile) {
// error: incompatible types: incompatible parameter types in method reference
return Panache.<Profile>withTransaction(profile::update)
.onItem().transform(updated -> Response.ok(URI.create("/profile" + updated.id)).build());
}
#DELETE
#Path("/{id}")
public Uni<Response> delete(UUID id) {
// delete entity by id
}
}
Can you fill the 2 missing functions?
I'm aware there is Quarkus Getting Started (w/ Reactive): PostGres/Docker CRUD Application -- Missing POST, PUT, and DELETE REST URLs
but the contents are different from what's written in the getting started page.
Generally speaking, the Getting Started and the quickstarts might be slightly different. The reason is that the purpose of the Getting Started is to help a new user to set up a small working project quickly and the quickstart is a place to showcase different functionalities of the extensions involved.
We try to make sure that the documentation is always up to date but nothing beats a working example like the quickstart.
In this case I don't understand your complains.
An example of PUT and DELETE is available in the Hibernate Reactive with panache quickstart:
#PUT
#Path("{id}")
public Uni<Response> update(Long id, Fruit fruit) {
return Panache
.withTransaction(() -> Fruit.<Fruit> findById(id)
.onItem().ifNotNull().invoke(entity -> entity.name = fruit.name)
)
.onItem().ifNotNull().transform(entity -> Response.ok(entity).build())
.onItem().ifNull().continueWith(Response.ok().status(NOT_FOUND)::build);
}
#DELETE
#Path("{id}")
public Uni<Response> delete(Long id) {
return Panache.withTransaction(() -> Fruit.deleteById(id))
.map(deleted -> deleted
? Response.ok().status(NO_CONTENT).build()
: Response.ok().status(NOT_FOUND).build());
}
For your use case you need to use Profile instead of Fruit, and UUID instead of Long for the id. I don't think you need anything else to make it work.
// error: incompatible types: incompatible parameter types in method reference
The error message is telling you the cause of the problem: the syntax Panache.withTransaction(profile::update) is not correct.
This won't work because profile.update(...) expects additional parameters that you are not passing when using method reference with withTransaction.
On the other hand, one can use Panache.withTransaction(profile::persist) because profile.persist() is a method that doesn't require parameters.
This is how method reference works in Java.
That said, the documentation is never done and it will get better over time based on the feedback we receive.
Also, StackOverflow might not be the best place for this type of questions.
I would have probably asked this on the users stream on Zulip first. It's even faster to receive an answer if you push an example of the code that's giving you trouble somewhere, so that we can run it and give you precise help about what's wrong with it.
I'm aware there is Quarkus Getting Started (w/ Reactive): PostGres/Docker CRUD Application -- Missing POST, PUT, and DELETE REST URLs
The example in this question is 2 years old and things have changed since then. In fact, the same quickstart and tutorial referenced in that question now match the code I've used.
You can find the information you are asking for at https://quarkus.io/guides/hibernate-orm-panache#writing-a-jax-rs-resource.
You can also compare reactive vs. non-reactive versions of the same application by looking at the Hibernate Reactive Panache Quickstart and the Hibernate ORM Panache Quickstart

Howto tell PowerBuilder to pass options to a JVM when starting?

What I want to do?
I want to create and consume java objects in PowerBuilder and call methods on it. This should happen with less overhead possible.
I do not want to consume java webservices!
So I've a working sample in which I can create a java object, call a method on this object and output the result from the called method.
Everything is working as expected. I'm using Java 1.8.0_31.
But now I want to attach my java IDE (IntelliJ) to the running JVM (started by PowerBuilder) to debug the java code which gets called by PowerBuilder.
And now my question.
How do I tell PowerBuilder to add special options when starting the JVM?
In special I want to add the following option(s) in some way:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
The JVM is created like following:
LONG ll_result
inv_java = CREATE JavaVM
ll_result = inv_java.CreateJavaVM("C:\Development\tms java\pbJavaTest", FALSE)
CHOOSE CASE ll_result
CASE 1
CASE 0
CASE -1
MessageBox ( "", "jvm.dll was not found in the classpath.")
CASE -2
MessageBox ( "", "pbejbclient90.jar file was not found." )
CASE ELSE
MessageBox ( "", "Unknown result (" + String (ll_result ) +")" )
END CHOOSE
In the PowerBuilder help I found something about overriding the static registry classpath. There is something written about custom properties which sounds like what I'm looking for.
But there's no example on how to add JVM options to override default behavior.
Does anyone have a clue on how to tell PowerBuilder to use my options?
Or does anyone have any advice which could guide me in the right direction?
Update 1
I found an old post which solved my initial issue.
If someone else want to know how it works take a look at this post:
http://nntp-archive.sybase.com/nntp-archive/action/article/%3C46262213.6742.1681692777#sybase.com%3E
Hi, you need to set some windows registry entries.
Under HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\Powerbuilder\9.0\Java, there
are two folders: PBIDEConfig and PBRTConfig. The first one is used when
you run your application from within the IDE, and the latter is used
when you run your compiled application. Those two folders can have
PBJVMconfig and PBJVMprops folders within them.
PBJVMconfig is for JVM configuration options such as -Xms. You have to
specify incremental key values starting from "0" by one, and one special
key "Count" to tell Powerbuilder how many options exists to enumerate.
PBJVMprops is for all -D options. You do not need to specify -D for
PBJVMProps, just the name of the property and its value, and as many
properties as you wish.
Let me give some examples:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\PowerBuilder\9.0\Java\PBIDEConfig\PBJVMprops]
"java.security.auth.login.config"="auth.conf"
"user.language"="en"
[HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\PowerBuilder\9.0\Java\PBRTConfig\PBJVMconfig]
"0"="-client"
"1"="-Xms128m"
"2"="-Xmx512m"
"Count"="3"
[HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\PowerBuilder\9.0\Java\PBRTConfig\PBJVMprops]
"java.security.auth.login.config"="auth.conf"
"user.language"="en"
Regards,
Gokhan Demir
But now there's another issue...
PB isn't able to create EJB Proxies for my sample class which is really simple with java 1.8.0_31. They were created with the default version, which is 1.6.0_24.
public class Simple
{
public Simple()
{
}
public static String getValue()
{
return "blubber";
}
public int getInt32Value()
{
return 123456;
}
public double getDoubleVaue()
{
return 123.123;
}
public static void main(String[] args)
{
System.out.println(Simple.getValue());
}
}
The error is the following. :D
---------- Deploy: Deploy of project p_genapp_ejbclientproxy (15:35:18)
Retrieving PowerBuilder Proxies from EJB...
Generation Errors: Error: class not found: (
Deployment Error: No files returned for package/component 'Simple'. Error code: Unknown. Proxy was not created.
Done.
---------- Finished Deploy of project p_genapp_ejbclientproxy (15:35:19)
So the whole way isn't a option because we do not want to change the JAVA settings in PB back and forth just to generate new EJB Proxies for changed JAVA objects in the future...
So one option to test will be creating COM wrappers for JAVA classes to use them in PB...

Get pluginId stored in the IPreferenceNode in Eclipse

I am developing a plugin, in my plugin I want to get another plugin ID. I use the following code:
PreferenceManager pm = PlatformUI.getWorkbench( ).getPreferenceManager();
List<IPreferenceNode> list = pm.getElements(PreferenceManager.PRE_ORDER);
String pluginid;
// restoreDefValues("org.eclipse.ant.ui");
for(IPreferenceNode node : list){
the code to find the node related to the plugin;
}
When I debug the program, I can clearly see that in variable node(IPreferenceNode), it has the value of the pluginId. However, I check the document of IPreferenceNode, it seems that the neither IPreferenceNode nor the class PreferenceNode, provide a method to return the value of pluginId. I tried node.toString() as well, couldn't get the pluginId. So what should I do? Is there any other ways to get a plugin ID from another plugin?
Preference nodes created using the org.eclipse.ui.preferencePages extension point will actually be instances of org.eclipse.ui.internal.dialogs.WorkbenchPreferenceNode. The super class of this (WorkbenchPreferenceExtensionNode) contains the plugin id.
These classes are internal so you should not try to use them directly. However they implement org.eclipse.ui.IPluginContribution which can be used and has a getPluginId() method.
So something like:
if (node instanceof IPluginContribution) {
pluginId = ((IPluginContribution)node).getPluginId();
}
should work.

JFrame in remote between JDK 5 (Server) and 6 (Client - VisualVM)

So I have a little trouble on the opening of a JFrame. I searched extensively on the net, but I really can not find a solution ...
I explained the situation:
I need to develop an application that needs to retrieve information tracking application while meeting new safety standards. For that I use JMX that allows monitoring and VisualVM to see these information.
I therefore I connect without problems (recently ^ ^) to JMX since VisualVM.
There is thus in a VisualVM plugin for recovering information on MBean, including those on Methods (Operations tab in the plugin).
This allows among others to stop a service or create an event.
My problem then comes when I try to display a result of statistics.
In fact, I must show, at the click of a button from the list of methods in the "Operations", a window with a table in HTML (titles, colors and everything else).
For that I use a JFrame:
public JFrame displayHTMLJFrame(String HTML, String title){
JFrame fen = new JFrame();
fen.setSize(1000, 800);
fen.setTitle(title);
JEditorPane pan = new JEditorPane();
pan.setEditorKit(new HTMLEditorKit());
pan.setEditable(false);
pan.setText(HTML);
fen.add(pan);
return fen;
}
I call it in my method:
public JFrame displayHtmlSqlStatOK_VM(){
return displayHTMLJFrame(displaySQLStat(sqlStatOK, firstMessageDate), "SqlStatOK");
}
The method must therefore giving me back my JFrame, but she generates an error:
Problem invoking displayHtmlSqlStatOK_VM : java.rmi.UnmarshalException: error unmarshalling return; nested
exception is:
java.io.InvalidClassException: javax.swing.JFrame; local class incompatible: stream classdesc serialVersionUID =
-5208364155946320552, local class serialVersionUID = -2386951414768123374
I saw on the internet that this was a version problem (Serialization), and I believe strongly that it comes from the fact that I have this:
Server - JDK5 <----> Client (VisualVM) - JDK6
Knowing that I can not to change the server version (costs too important ...) as advocated by some sites and forums.
My question is as follows:
Can I display this damn window keeping my current architecture (JDK5 server side and client side JDK6)?
I could maybe force the issue? Tell him that there's nothing bad that can run my code? Finally I'm asking him but he does not answer me maybe to you he will tell you ... (Yes I crack ^^).
Thank you very much to those who read me and help me!
If you need more info do not hesitate.
EDIT
The solution to my problem might be elsewhere, because in fact I just want a table with minimal formatting (this is just for viewing application for an for an officer to have his little table him possibly putting critical data in red...).
But I have nowhere found a list of types that I can return with VisualVM ... This does not however seem to me too much to ask.
After I had thought of a backup solution, which would be to create a temporary HTML file and open it automatically in the browser, but right after that is perhaps not very clean ... But if it can work ^^
I am open to any area of ​​research!
It looks like you are sending instance javax.swing.JFrame over the JMX connection - this is a bad idea.
Well good I found myself, as a great :)
Thank you bye!
..........
Just kidding of course I will give the solution that I found ^ ^
So here's what I did:
My display to be done on the client (normal...) my code to display a JFrame that I had set up on the server was displayed obviously ... On the server xD
I didn't want to change the customer (VisualVM) to allow users maximum flexibility. However I realized that to display my HTML table to be rendered usable (with colors and everything) I had to change the client (as JMX does not support the type JFrame as type back an operation).
My operation running from the MBeans plugin for VisualVM, it was necessary that I find the source code for it to say "Be careful if you see that I give you the HTML you display it in a JFrame".
Here is my approach:
- Get the sources
The link SVN to get sources VisualVM is as follows:
https: //svn.java.net/svn/visualvm~svn/branches/release134
If like me you have trouble with the SVN client includes in NetBeans because you are behind a proxy, you can do it by command line:
svn --config-option servers:global:http-proxy-host=MY_PROXY_HOST --config-option servers:global:http-proxy-port=MY_PROXY_PORT checkout https: //svn.java.net/svn/visualvm~svn/branches/release134 sources-visualvm
Putting you on your destination folder of course (cd C:\Users\me\Documents\SourcesVisualVM example).
- Adding the platform VisualVM
NetBeans needs the platform VisualVM to create modules (plugins) for it. For this, go to "Tools" -> "NetBeans Platforms".
Then click "Add Platform ..." at the bottom left of the window and select the folder to the bin downloaded at this address: http:// visualvm.java.net/download.html
You should have this:
http://img15.hostingpics.net/pics/543268screen1.png
- Adding sources in the workspace (NetBeansProjects)
Copy/paste downloaded sources (SVN from the link above) to your NetBeans workspace (by default in C:\Users\XXX\Documents\NetBeansProjects).
- Ouverture du projet du plugin MBeans
In NetBeans, right click in the Project Explorer (or go to the menu "Files") and click "Open Project ...".
You will then have a list of projects in your workspace.
Open the project "mbeans" found in "release134" -> "Plugins", as below:
http://img15.hostingpics.net/pics/310487screen2.png
- Changing the file "platform.properties"
To build plugin you must define some variables for your platform.
To do this, open the file platform.properties in the directory release134\plugins\nbproject of your workspace.
Replace the content (by changing the paths compared to yours):
cluster.path=\
C:\\Program Files\\java6\\visualvm_134\\platform:\
C:\\Program Files\\java6\\visualvm_134\\profiler
# Deprecated since 5.0u1; for compatibility with 5.0:
disabled.clusters=
nbjdk.active=default
nbplatform.active=VisualVM_1.3.4
suite.dir=${basedir}
harness.dir= C:\\Program Files\\NetBeans 7.1.2\\harness
- Changing the class XMBeanOperations
To add our feature (displaying an HTML table), you must change the class that processes operations, namely the class XMBeanOperations in package com.sun.tools.visualvm . modules.mbeans.
At line 173, replace:
if (entryIf.getReturnType() != null &&
!entryIf.getReturnType().equals(Void.TYPE.getName()) &&
!entryIf.getReturnType().equals(Void.class.getName()))
fireChangedNotification(OPERATION_INVOCATION_EVENT, button, result);
By :
if (entryIf.getReturnType() != null &&
!entryIf.getReturnType().equals(Void.TYPE.getName()) &&
!entryIf.getReturnType().equals(Void.class.getName())) {
if (entryIf.getReturnType() instanceof String) {
String res = result + "";
if (res.indexOf("<html>") != -1) {
JFrame frame = displayHTMLJFrame(res, button.getText());
frame.setVisible(true);
}
else
fireChangedNotification(OPERATION_INVOCATION_EVENT, button, result);
} else
fireChangedNotification(OPERATION_INVOCATION_EVENT, button, result);
}
With the method of creating the JFrame that you place above "void performInvokeRequest (final JButton button)" for example:
// Display a frame with HTML code
public JFrame displayHTMLJFrame(String HTML, String title){
JFrame fen = new JFrame();
fen.setSize(1000, 800);
fen.setTitle(title);
JEditorPane pan = new JEditorPane();
pan.setEditorKit(new HTMLEditorKit());
pan.setEditable(false);
pan.setText(HTML);
fen.add(pan);
return fen;
}
We can see that we already did a test on the return type, if it is a String which is returned, if the case, if we see in this string the balise , then we replace the result of the click by opening a JFrame with the string you put in, what makes us display our HTML code!
- Creating a .nbm
The file .nbm is the deployment file of your plugin. Simply right-click your project (in the Project Explorer) and click on "Create NBM".
Your file .nbm will be created in the folder "build" the root of your project.
- Installing the plugin in VisualVM
To install your plugin, you must just go in VisualVM, go into "Tools" -> "Plugins" tab and then "Downloaded", click "Add Plugins ...". Select your plugin .nbm then click "Install". Then follow the instructions.
Useful Sources
http: //docs.oracle.com/javase/6/docs/technotes/guides/visualvm/
http: //visualvm.java.net/"]http://visualvm.java.net/
http: //visualvm.java.net/api-quickstart.html (Créer un plugin VisualVM avec NetBeans)
Thank you very much for your help Tomas Hurka ;)