desperado1992 / swift

An annotation-based Java library for creating Thrift serializable types and services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swift

Swift is an easy-to-use, annotation-based Java library for creating Thrift serializable types and services.

Swift Codec

Swift Codec is a simple library specifying how Java objects are converted to and from Thrift. This library is similar to JaxB (XML) and Jackson (JSON), but for Thrift. Swift codec supports field, method, constructor, and builder injection. For example:

@ThriftStruct
public class LogEntry
{
    private final String category;
    private final String message;

    @ThriftConstructor
    public LogEntry(String category, String message)
    {
        this.category = category;
        this.message = message;
    }

    @ThriftField(1)
    public String getCategory()
    {
        return category;
    }

    @ThriftField(2)
    public String getMessage()
    {
        return message;
    }
}

Swift Service

Swift Service is a simple library annotating services to be exported with Thrift. For example:

@ThriftService("scribe")
public class InMemoryScribe
{
    private final List<LogEntry> messages = new ArrayList<>();

    public List<LogEntry> getMessages()
    {
        return messages;
    }

    @ThriftMethod("Log")
    public ResultCode log(List<LogEntry> messages)
    {
        this.messages.addAll(messages);
        return ResultCode.OK;
    }
}

Swift Generator

Swift Generator is a library that creates Java code usable with the Swift codec from Thrift IDL files and vice versa.

Swift Generator CLI and Swift2Thrift Generator CLI are command-line front-ends to this generator.

Swift Maven plugin

Swift Maven plugin allows using the code generator from a maven build and generate source code on the fly.

About

An annotation-based Java library for creating Thrift serializable types and services.

License:Apache License 2.0


Languages

Language:Java 85.1%Language:Thrift 12.8%Language:HTML 1.2%Language:GAP 0.9%