thrift/compiler/generate/templates/java2/Service.mustache (264 lines of code) (raw):
{{!
Copyright (c) Facebook, Inc. and its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
}}
{{> AutoGenerated}}
package {{service:javaPackage}};
import com.facebook.swift.codec.*;
import com.facebook.swift.codec.ThriftField.Requiredness;
import com.facebook.swift.service.*;
import com.facebook.thrift.client.*;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.*;
import java.util.*;
@SwiftGenerated
@com.facebook.swift.service.ThriftService("{{service:javaCapitalName}}")
public interface {{service:javaCapitalName}} extends java.io.Closeable{{#service:extends}}, {{service:javaPackage}}.{{service:javaCapitalName}}{{/service:extends}} {
static {{service:javaCapitalName}} createBlockingClient(
final com.facebook.thrift.client.RpcClientFactory _rpcClientFactory,
final java.net.SocketAddress _socketAddress,
final org.apache.thrift.ProtocolId _protocolId) {
{{service:javaCapitalName}}.Reactive _delegate = createReactiveClient(
_rpcClientFactory,
_socketAddress,
_protocolId);
return new {{service:javaCapitalName}}ReactiveBlockingWrapper(_delegate);
}
static {{service:javaCapitalName}} createBlockingClient(
final com.facebook.thrift.client.RpcClientFactory _rpcClientFactory,
final java.net.SocketAddress _socketAddress,
final org.apache.thrift.ProtocolId _protocolId,
final java.util.Map<String, String> _headers,
final java.util.Map<String, String> _persistentHeaders) {
{{service:javaCapitalName}}.Reactive _delegate = createReactiveClient(
_rpcClientFactory,
_socketAddress,
_protocolId,
_headers,
_persistentHeaders);
return new {{service:javaCapitalName}}ReactiveBlockingWrapper(_delegate);
}
static {{service:javaCapitalName}}.Async createAsyncClient(
final com.facebook.thrift.client.RpcClientFactory _rpcClientFactory,
final java.net.SocketAddress _socketAddress,
final org.apache.thrift.ProtocolId _protocolId) {
{{service:javaCapitalName}}.Reactive _delegate = createReactiveClient(
_rpcClientFactory,
_socketAddress,
_protocolId);
return new {{service:javaCapitalName}}ReactiveAsyncWrapper(_delegate);
}
static {{service:javaCapitalName}}.Async createAsyncClient(
final com.facebook.thrift.client.RpcClientFactory _rpcClientFactory,
final java.net.SocketAddress _socketAddress,
final org.apache.thrift.ProtocolId _protocolId,
final java.util.Map<String, String> _headers,
final java.util.Map<String, String> _persistentHeaders) {
{{service:javaCapitalName}}.Reactive _delegate = createReactiveClient(
_rpcClientFactory,
_socketAddress,
_protocolId,
_headers,
_persistentHeaders);
return new {{service:javaCapitalName}}ReactiveAsyncWrapper(_delegate);
}
static {{service:javaCapitalName}}.Reactive createReactiveClient(
final com.facebook.thrift.client.RpcClientFactory _rpcClientFactory,
final java.net.SocketAddress _socketAddress,
final org.apache.thrift.ProtocolId _protocolId) {
return new {{service:javaCapitalName}}ReactiveClient(
_protocolId,
_rpcClientFactory.createRpcClient(_socketAddress),
java.util.Collections.emptyMap(),
java.util.Collections.emptyMap());
}
static {{service:javaCapitalName}}.Reactive createReactiveClient(
final com.facebook.thrift.client.RpcClientFactory _rpcClientFactory,
final java.net.SocketAddress _socketAddress,
final org.apache.thrift.ProtocolId _protocolId,
final java.util.Map<String, String> _headers,
final java.util.Map<String, String> _persistentHeaders
) {
return new {{service:javaCapitalName}}ReactiveClient(
_protocolId,
_rpcClientFactory.createRpcClient(_socketAddress),
_headers,
_persistentHeaders);
}
@com.facebook.swift.service.ThriftService("{{service:javaCapitalName}}")
public interface Async extends java.io.Closeable{{#service:extends}}, {{service:javaPackage}}.{{service:javaCapitalName}}.Async{{/service:extends}} {
@java.lang.Override void close();
{{#service:singleRequestFunctions}}
@ThriftMethod(value = "{{function:name}}"{{#function:oneway?}},
oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}},
exception = { {{/first?}}
@ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}}
}{{/last?}}{{/function:exceptions}})
ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}});
default ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
default ListenableFuture<ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
{{^last?}}
{{/last?}}
{{/service:singleRequestFunctions}}
{{#service:interactions}}
@com.facebook.swift.service.ThriftInteraction("{{service:name}}")
public interface {{service:name}} extends java.io.Closeable {
{{#service:singleRequestFunctions}}
@ThriftMethod(value = "{{function:name}}"{{#function:oneway?}},
oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}},
exception = { {{/first?}}
@ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}}
}{{/last?}}{{/function:exceptions}})
ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}});
ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
RpcOptions rpcOptions);
ListenableFuture<ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
RpcOptions rpcOptions);
{{/service:singleRequestFunctions}}
@java.lang.Override
void close();
}
public {{service:name}} create{{service:name}}();
{{^last?}}
{{/last?}}
{{/service:interactions}}
}
@java.lang.Override void close();
{{#service:singleRequestFunctions}}
@ThriftMethod(value = "{{function:name}}"{{#function:oneway?}},
oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}},
exception = { {{/first?}}
@ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}}
}{{/last?}}{{/function:exceptions}})
{{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}){{!
Exceptions
}} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException;
default {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
RpcOptions rpcOptions){{!
Exceptions
}} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException {
throw new UnsupportedOperationException();
}
default ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}Wrapper({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
RpcOptions rpcOptions){{!
Exceptions
}} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException {
throw new UnsupportedOperationException();
}
{{/service:singleRequestFunctions}}
@com.facebook.swift.service.ThriftService("{{service:javaCapitalName}}")
interface Reactive extends reactor.core.Disposable{{#service:extends}}, {{service:javaPackage}}.{{service:javaCapitalName}}.Reactive{{/service:extends}} {
{{#service:singleRequestFunctions}}
@ThriftMethod(value = "{{function:name}}"{{#function:oneway?}},
oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}},
exception = { {{/first?}}
@ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}}
}{{/last?}}{{/function:exceptions}})
reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}});
default reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
default reactor.core.publisher.Mono<ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
{{/service:singleRequestFunctions}}
{{#service:streamingFunctions}}
reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}});
default reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
default reactor.core.publisher.Flux<ResponseWrapper<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
{{/service:streamingFunctions}}
{{#service:sinkFunctions}}
{{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#type:sink_elem_type}}{{ >BoxedType}}{{/type:sink_elem_type}}{{/function:return_type}}> payloads);
default {{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#type:sink_elem_type}}{{ >BoxedType}}{{/type:sink_elem_type}}{{/function:return_type}}> payloads, RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
default {{#function:return_type}}{{> SinkWrapperReturnType}}{{/function:return_type}} {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#type:sink_elem_type}}{{ >BoxedType}}{{/type:sink_elem_type}}{{/function:return_type}}> payloads, RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
{{/service:sinkFunctions}}
{{#service:interactions}}
@com.facebook.swift.service.ThriftInteraction("{{service:name}}")
public interface {{service:name}} extends reactor.core.Disposable {
{{#service:singleRequestFunctions}}
@ThriftMethod(value = "{{function:name}}"{{#function:oneway?}},
oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}},
exception = { {{/first?}}
@ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}}
}{{/last?}}{{/function:exceptions}})
reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}});
reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions);
reactor.core.publisher.Mono<ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions);
{{/service:singleRequestFunctions}}
{{#service:streamingFunctions}}
reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}});
default reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
default reactor.core.publisher.Flux<ResponseWrapper<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) {
throw new UnsupportedOperationException();
}
{{/service:streamingFunctions}}
@java.lang.Override
void dispose();
}
public {{service:name}} create{{service:name}}();
{{^last?}}
{{/last?}}
{{/service:interactions}}
}
{{#service:interactions}}
@com.facebook.swift.service.ThriftInteraction("{{service:name}}")
public interface {{service:name}} extends java.io.Closeable {
{{#service:singleRequestFunctions}}
@ThriftMethod(value = "{{function:name}}"{{#function:oneway?}},
oneway = true{{/function:oneway?}}{{#function:exceptions}}{{#first?}},
exception = { {{/first?}}
@ThriftException(type={{#field:type}}{{> Type}}{{/field:type}}.class, id={{field:key}}){{^last?}},{{/last?}}{{#last?}}
}{{/last?}}{{/function:exceptions}})
{{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}) throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException;
{{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
RpcOptions rpcOptions){{!
Exceptions
}} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException;
ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}Wrapper({{#function:args}}
@com.facebook.swift.codec.ThriftField(value={{field:key}}, {{#field:negativeId?}}isLegacyId=true, {{/field:negativeId?}}name="{{field:name}}", requiredness={{> Requiredness}}) final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
RpcOptions rpcOptions){{!
Exceptions
}} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException;
{{/service:singleRequestFunctions}}
@java.lang.Override
void close();
}
{{service:name}} create{{service:name}}();
{{^last?}}
{{/last?}}
{{/service:interactions}}
}