public abstract class AbstractCompositeServiceBuilder<T extends Service<?,?>> extends Object
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);
...
}
}
CompositeServiceEntry| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCompositeServiceBuilder()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected AbstractCompositeServiceBuilder<T> |
service(CompositeServiceEntry<T> entry)
Binds the specified
CompositeServiceEntry. |
protected AbstractCompositeServiceBuilder<T> |
service(Route route,
T service)
|
protected AbstractCompositeServiceBuilder<T> |
service(String pathPattern,
T service)
Binds the specified
Service at the specified path pattern. e.g. |
protected List<CompositeServiceEntry<T>> |
services()
Returns the list of the
CompositeServiceEntrys added via service(String, Service),
serviceUnder(String, Service), service(Route, Service) and
service(CompositeServiceEntry). |
protected AbstractCompositeServiceBuilder<T> |
serviceUnder(String pathPrefix,
T service)
Binds the specified
Service under the specified directory.. |
String |
toString() |
protected AbstractCompositeServiceBuilder()
protected final List<CompositeServiceEntry<T>> services()
CompositeServiceEntrys added via service(String, Service),
serviceUnder(String, Service), service(Route, Service) and
service(CompositeServiceEntry).protected AbstractCompositeServiceBuilder<T> serviceUnder(String pathPrefix, T service)
Service under the specified directory..protected AbstractCompositeServiceBuilder<T> service(String pathPattern, T service)
Service 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)IllegalArgumentException - if the specified path pattern is invalidprotected AbstractCompositeServiceBuilder<T> service(Route route, T service)
protected AbstractCompositeServiceBuilder<T> service(CompositeServiceEntry<T> entry)
CompositeServiceEntry.Copyright © 2020 LeanCloud. All rights reserved.