Is there a way to convert thrift IDL into wsdl spec? - wsdl

Is there any open source library or online service that could automagicaly generate wsdl spec on the base of the thrift IDL?
The goal is to build facade API on the top of existing thrift API that would allow coupling with ansient systems via SOAP protocol.

There are a couple of ready to use tools that allow to convert Thrift IDL into WSDL. The rest of the answer assumes we live in the Java world with JDK and Maven at hand and internet connection available.
The first one is Swift Code Generator Tool. As it's readme states, one have to:
download the latest version:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -DremoteRepositories=central::default::http://repo1.maven.apache.org/maven2 -Dartifact=com.facebook.swift:swift-generator-cli:RELEASE:jar:standalone -Ddest=/tmp/
run downloaded jar in the directory containing thrift files:
java -jar /tmp/swift-generator-cli-0.23.1-standalone.jar -use_java_namespace -out ../java *.thrift
assuming standard
- src
- main
- java
- thrift
Maven project layout. Swift Code Generator will generate a Java interface for each Thrift service entry. Every Thrift source file must declare a 'java' namespace, like this:
namespace java com.acme
The generated interface will include nested Async interface for asynchronous invocation. Remove Async subinterface. Automation of Async removal is left as an exercise for the reader.
Compile generated java files with javac or your favourite build tool (ant, maven, gradle, etc.). Do not forget to include com.facebook.swift:swift-annotations:0.23.1 as a compile dependency.
Finally use Apache Axis2' java2wsdl utility available within Axis2 binary distribution, like this:
/tmp/axis2-1.7.4/bin/java2wsdl.sh -cn com.acme.TargetService -cp build/classes/main
to generate wsdl for the Thrift service TargetService {...} entry.

Related

GraalVM native image reflection doesn't work

I'm trying to create a GraalVM native image using the maven plugin but having some issues.
Here the config for the maven plugin
I'm using GraalVM JDK (installed through Sdkman):
$ java -version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment GraalVM CE 21.1.0 (build 16.0.1+9-jvmci-21.1-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.1.0 (build 16.0.1+9-jvmci-21.1-b05, mixed mode, sharing)
I have a done simple main class like:
package it.r;
public class Main {
public static void main(String[] args) {
System.out.println("********");
System.out.println(Main.class.getConstructors().length);
System.out.println("********");
}
}
When executing it using mvn exec:java -Dexec.mainClass=it.r.Main I get as a result:
********
1
********
But when doing mvn package and then executing the created executable, I have as result:
********
0
********
Why is this happening?
Here the git repo to reproduce
This issue seems to impact Jackson deserialization, as in another example I have an error from jackson that cannot deserialize a yaml file because it can't find constructors for my class.
When GraalVM native image builds your application into a native binary it statically analyzes your application.
The analysis is static, so several dynamic features your application might use require explicit configuration, for example:
reflection
serialization
method handles
using resources (like classloader.getResource())
JNI
This explicit configuration is provided as json configuration files, for example,
You can provide the config files manually, but you can also run your application using a javaagent which will record usages of features requiring configuration.
In a nutshell, you run your application like this:
java -agentlib:native-image-agent=config-output-dir=/path/to/config-dir/
and exercise the code paths that use the code you want to be configured. This is important because the tracing agent can only record the config for the code it actually saw running.
Then the output directory will contain a json file, for example looking like this:
[
{
"name":"StringCapitalizer",
"methods":[{"name":"capitalize","parameterTypes":["java.lang.String"] }]
},
{
"name":"StringReverser",
"methods":[{"name":"reverse","parameterTypes":["java.lang.String"] }]
}
This file lists the classes that need to be included into the analysis and the binary result and their members that need to be accessed.
It’s fairly straightforward but a bit tedious to create manually that’s why the agent approach is preferred.
There’s also a programmatic way to configure classes and members be registered for reflection, but using it means you need to include a dependency on the GraalVM code into your app.
Classes using reflections need to be registered in order to include them in the native image built, more info in the docs

How to run swagger-codegen for OpenAPI 3.0.0

looks like official swagger for openapi specification V3 support is near release https://blog.readme.io/an-example-filled-guide-to-swagger-3-2/, and the swagger-codegen has 3.0.0 support developed and passing some level of testing https://github.com/swagger-api/swagger-codegen on the 3.0.0 branch
I have a swagger spec (generated from my existing 2.0 spec via https://github.com/mermade/swagger2openapi, output looks good)
Is there an easy way to run the swagger-codegen without having to package the jar myself?
this is the single result i found: https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen-cli/3.0.0-SNAPSHOT/ but running that seems to be broken (from the output, possibly actually running 2.0 not 3.0.0?):
[main] INFO io.swagger.parser.Swagger20Parser - reading from /input/myspec.openapi3.json
[main] INFO io.swagger.codegen.ignore.CodegenIgnoreProcessor - No .swagger-codegen-ignore file found.
Exception in thread "main" java.lang.RuntimeException: missing swagger input or config!
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:685)
at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
It looks like the swagger-codegen repo has a somewhat supported way to run a docker container after you build; I'm just hoping/guessing there is a supported way to do this without needing to compile locally, as I need to set this up in several places.
OpenAPI Generator (found by top contributors of Swagger Codegen) supports both OpenAPI specification v2 and v3.
You can use the docker images, Java JAR (SNAPSHOT), Brew or npm to give it a try.
For more information about OpenAPI Generator, please refer to the project's README
If you need any help, please open an issue and we'll look into it.
UPDATE: 1st stable version 3.0.0 has been released: https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.0
Swagger-codegen 3.0.0 snapshots now include a limited number of targets for code generation from OpenAPI 3.0 definitions. https://github.com/swagger-api/swagger-codegen/issues/6598#issuecomment-333428808
There is an alternative experimental implementation of the codegen engine, using the original swagger-codegen 2.x templates, written in Node.js: https://github.com/mermade/openapi-codegen - if your language is not yet supported, a config file just needs to be created for it mapping the template files to outputs.

Maven dependency list for stardog examples

Could someone please post the maven dependencies needed to run the stardog 2.1.3 client examples? These critical ones keep coming up undefined
import com.complexible.common.openrdf.OpenRdfIO;
import com.complexible.common.protocols.server.Server;
import com.complexible.stardog.Stardog;
Server and Stardog are in the ${STARDOG}\server directory of the distribution; these are not installed by the maven install script because they're server dependencies and normally not needed in a client application. The complete end-to-end examples, because they include both client & server code, require both sets of dependencies.
The OpenRdfIO class no longer exists, you are using out of data code. If you use the version of the example in the distribution, it will have the correct class name.

How to write flume custom sink and source in version 1.3.1

I am trying to write my own sink and source in flume version 1.3.It doesn't have config file flume-site.xml. How could I use this custom sink after I compile my java file?
You need to put jar with your compiled sink somewhere to flume CLASSPATH. In version 1.3.1, simply lib/ should be sufficient. For newer version you will have option to use "plugins.d" directory, checkout FLUME-1735 [1] for more details (fixed in trunk and will be part of 1.4.0).
To configure flume to actually use your sink, use fully qualified name of your class (e.g. package.ClassName) in the configuration. For example if your class is in package "earth.europe" and the class name is "WorldSink", then you need to use following configuration fragment:
a1.sinks = s1
a1.sinks.s1.type = earth.europe.WorldSink
Jarcec
Links:
1: https://issues.apache.org/jira/browse/FLUME-1735

how to generate javadocs of my blackberry java files

I have developed one blackberry simple application and wants to generate javadocs of my source code. How to generate javadocs of my java file?
I don't know much about blackberry, but if they are (at least syntactically) normal Java source files, you can use this command:
javadoc -d outputdir -sourcepath src my.first.package my.second.package ...
Have a look at the Javadoc documentation for more options. It might be that you have to add the blackberry library jar files with -classpath.

Resources