1*f585d8a3SJacky Wang /* 2*f585d8a3SJacky Wang * Copyright (C) 2016 The Dagger Authors. 3*f585d8a3SJacky Wang * 4*f585d8a3SJacky Wang * Licensed under the Apache License, Version 2.0 (the "License"); 5*f585d8a3SJacky Wang * you may not use this file except in compliance with the License. 6*f585d8a3SJacky Wang * You may obtain a copy of the License at 7*f585d8a3SJacky Wang * 8*f585d8a3SJacky Wang * http://www.apache.org/licenses/LICENSE-2.0 9*f585d8a3SJacky Wang * 10*f585d8a3SJacky Wang * Unless required by applicable law or agreed to in writing, software 11*f585d8a3SJacky Wang * distributed under the License is distributed on an "AS IS" BASIS, 12*f585d8a3SJacky Wang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*f585d8a3SJacky Wang * See the License for the specific language governing permissions and 14*f585d8a3SJacky Wang * limitations under the License. 15*f585d8a3SJacky Wang */ 16*f585d8a3SJacky Wang 17*f585d8a3SJacky Wang package dagger.grpc.server; 18*f585d8a3SJacky Wang 19*f585d8a3SJacky Wang import java.lang.annotation.Documented; 20*f585d8a3SJacky Wang import java.lang.annotation.ElementType; 21*f585d8a3SJacky Wang import java.lang.annotation.Target; 22*f585d8a3SJacky Wang 23*f585d8a3SJacky Wang /** 24*f585d8a3SJacky Wang * Annotates a class that implements a gRPC service. 25*f585d8a3SJacky Wang * 26*f585d8a3SJacky Wang * <p>Generates several types when annotating a class {@code Foo}: 27*f585d8a3SJacky Wang * 28*f585d8a3SJacky Wang * <ul> 29*f585d8a3SJacky Wang * <li>Interfaces {@code FooComponent} and {@code FooComponent.Factory}. 30*f585d8a3SJacky Wang * <li>{@linkplain dagger.Module Modules} {@code FooGrpcProxyModule} and {@code 31*f585d8a3SJacky Wang * FooGrpcServiceModule}. 32*f585d8a3SJacky Wang * </ul> 33*f585d8a3SJacky Wang * 34*f585d8a3SJacky Wang * <p>To use these types to configure a server: 35*f585d8a3SJacky Wang * 36*f585d8a3SJacky Wang * <ol> 37*f585d8a3SJacky Wang * <li>Create a {@linkplain dagger.Subcomponent subcomponent} that implements {@code FooComponent} 38*f585d8a3SJacky Wang * and installs {@code FooGrpcServiceModule}. 39*f585d8a3SJacky Wang * <li>Install {@link NettyServerModule} or another {@link ServerModule} subclass and {@code 40*f585d8a3SJacky Wang * FooGrpcProxyModule} into your {@link javax.inject.Singleton @Singleton} {@linkplain 41*f585d8a3SJacky Wang * dagger.Component component}. 42*f585d8a3SJacky Wang * <li>Bind an implementation of {@code FooComponent.Factory} in your {@link 43*f585d8a3SJacky Wang * javax.inject.Singleton @Singleton} {@linkplain dagger.Component component}. The 44*f585d8a3SJacky Wang * implementation will typically inject the {@link javax.inject.Singleton @Singleton} 45*f585d8a3SJacky Wang * {@linkplain dagger.Component component} and call subcomponent factory methods to instantiate 46*f585d8a3SJacky Wang * the correct subcomponent. 47*f585d8a3SJacky Wang * </ol> 48*f585d8a3SJacky Wang */ 49*f585d8a3SJacky Wang @Documented 50*f585d8a3SJacky Wang @Target(ElementType.TYPE) 51*f585d8a3SJacky Wang public @interface GrpcService { 52*f585d8a3SJacky Wang /** The class that gRPC generates from the proto service definition. */ grpcClass()53*f585d8a3SJacky Wang Class<?> grpcClass(); 54*f585d8a3SJacky Wang } 55