Class AbstractCompositeServiceBuilder<T extends Service<?,?>>
java.lang.Object
com.linecorp.armeria.server.composition.AbstractCompositeServiceBuilder<T>
- Direct Known Subclasses:
SimpleCompositeRpcServiceBuilder
,SimpleCompositeServiceBuilder
public abstract class AbstractCompositeServiceBuilder<T extends Service<?,?>> extends Object
A skeletal builder implementation for
AbstractCompositeService
and its subclasses.
Extend this class to implement your own Service
builder. e.g.
public class MyServiceBuilder extends AbstractCompositeServiceBuilder<MyServiceBuilder> {
private int propertyA;
private String propertyB;
public MyServiceBuilder propertyA(int propertyA) {
this.propertyA = propertyA;
return this;
}
public MyServiceBuilder propertyB(String propertyB) {
this.propertyB = propertyB;
return this;
}
public MyService build() {
serviceUnder("/foo/", new FooService(propertyA));
serviceUnder("/bar/", new BarService(propertyB));
serviceUnder("/", new OtherService());
List<CompositeServiceEntry> services = services();
return new MyService(services);
}
}
public class MyService extends AbstractCompositeService {
MyService(Iterable<CompositeServiceEntry> services) {
super(services);
...
}
}
- See Also:
CompositeServiceEntry
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractCompositeServiceBuilder()
Creates a new instance. -
Method Summary
Modifier and Type Method Description protected AbstractCompositeServiceBuilder<T>
service(CompositeServiceEntry<T> entry)
Binds the specifiedCompositeServiceEntry
.protected AbstractCompositeServiceBuilder<T>
service(Route route, T service)
protected AbstractCompositeServiceBuilder<T>
service(String pathPattern, T service)
Binds the specifiedService
at the specified path pattern. e.g.protected List<CompositeServiceEntry<T>>
services()
Returns the list of theCompositeServiceEntry
s added viaservice(String, Service)
,serviceUnder(String, Service)
,service(Route, Service)
andservice(CompositeServiceEntry)
.protected AbstractCompositeServiceBuilder<T>
serviceUnder(String pathPrefix, T service)
Binds the specifiedService
under the specified directory..String
toString()
-
Constructor Details
-
AbstractCompositeServiceBuilder
protected AbstractCompositeServiceBuilder()Creates a new instance.
-
-
Method Details
-
services
Returns the list of theCompositeServiceEntry
s added viaservice(String, Service)
,serviceUnder(String, Service)
,service(Route, Service)
andservice(CompositeServiceEntry)
. -
serviceUnder
Binds the specifiedService
under the specified directory.. -
service
Binds the specifiedService
at the specified path pattern. e.g./login
(no path parameters)/users/{userId}
(curly-brace style)/list/:productType/by/:ordering
(colon style)exact:/foo/bar
(exact match)prefix:/files
(prefix match)glob:/~*/downloads/**
(glob pattern)regex:^/files/(?<filePath>.*)$
(regular expression)
- Throws:
IllegalArgumentException
- if the specified path pattern is invalid
-
service
-
service
Binds the specifiedCompositeServiceEntry
. -
toString
-