简体   繁体   中英

How to make Spring Boot support Java-based language?

I'm working on a studies project and my objective is to extend Spring Boot framework so that it is able to handle Jolie language. My main problem is how to even enhance/extend Spring Boot to support other language - what needs to be created?

I think I am supposed to achieve something like Kotlin support for Spring Boot , but still I am not sure what conditions must be met in order to succeed at it.

I will give a go in answering your question. Let's start from the fact that the Jolie interpreter is coded in Java. This should make inserting Jolie into a Java-based framework as Spring Boot.

I imagine that you would like to create Jolie microservices and run them from inside your framework, on this note, there is an excellent Montesi Blog post that explains how to Run Jolie from Java .

In the post you can see the use the Interpreter to lunch your JOLIE code inside your host java application the class Interpreter can be found in the jolie.jar Another little hand on your project can come from a jolie2java this tool creates the java code for the message type.

jolie2java --addSource [true] --format [java|gwt] --packageName package_namespace [--targetPort inputPort_to_be_encoded] file.ol 

here is an example

    type op1Request :void{
      .name:string
      .surname:string
    }

    type op1Response :void{
      .registrationNumber:string
    }
    interface TestInterface {
    RequestResponse:
      op1(op1Request)(op1Response)
    }

and this are the resulting java classes



 package org.matiho.springboot;
    import java.util.List;
    import java.util.LinkedList;
    import jolie.runtime.Value;
    import jolie.runtime.ByteArray;

    public class op1Request {
    private String _surname;
    private String _name;

    public op1Request( Value v ){
    if (v.hasChildren("surname")){
    _surname= v.getFirstChild("surname").strValue();
    }
    if (v.hasChildren("name")){
    _name= v.getFirstChild("name").strValue();
    }
    }
    public op1Request(){
    }
    public String getSurname(){
    return _surname;
    }
    public void setSurname( String value ){
    _surname = value;
    }
    public String getName(){
    return _name;
    }
    public void setName( String value ){
    _name = value;
    }
    public Value getValue(){
    Value vReturn = Value.create();
    if((_surname!=null)){
    vReturn.getNewChild("surname").setValue(_surname);
    }
    if((_name!=null)){
    vReturn.getNewChild("name").setValue(_name);
    }
    return vReturn;
    }
    }

The response class

package org.matiho.springboot;
import java.util.List;
import java.util.LinkedList;
import jolie.runtime.Value;
import jolie.runtime.ByteArray;

public class op1Response {
private String _registrationNumber;

public op1Response( Value v ){
if (v.hasChildren("registrationNumber")){
  _registrationNumber= v.getFirstChild("registrationNumber").strValue();
}
}
public op1Response(){
}
public String getRegistrationNumber(){
  return _registrationNumber;
}
public void setRegistrationNumber( String value ){
  _registrationNumber = value;
}
public Value getValue(){
  Value vReturn = Value.create();
  if((_registrationNumber!=null)){
  vReturn.getNewChild("registrationNumber").setValue(_registrationNumber);
  }
return vReturn;
}
}

I can see you running into some problems with libraries compability when importing Jolie into a framework Hope it helps
PS: can you add the tag Jolie

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM