-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some Idea to try to improve API to create CaliforniumServerEndpointsProvider #1395
Comments
The CoapsServerEndpointFactoryBuilder (C) proposal seems the most readable API to me. It allows to set dedicated options without having to read, understand and override the whole CoapsServerEndpointFactory class. |
Reading your answer, I feel that maybe I was not clear enough. So just to be sure, proposition A), B) and C) are not exclusive and doesn't target same goal. About C), the full snippet of code would be : LeshanServerBuilder serverBuilder = new LeshanServerBuilder();
CaliforniumServerEndpointsProvider.Builder endpointsBuilder = new CaliforniumServerEndpointsProvider.Builder(
new CoapServerProtocolProvider(), new CoapsServerProtocolProvider());
// to add default endpoint for COAP and COAPS
endpointsBuilder.addEndpoint(Protocol.COAP);
endpointsBuilder.addEndpoint(Protocol.COAPS);
// to add another COAPS endpoint which custom config.
endpointsBuilder.addEndpoint(new CoapsServerEndpointFactoryBuilder() //
.uri(5784) //
.loggingTagPrefix("Custom Coaps") //
.dtlsConfig(c -> c.setSessionStore(new CustomSessionStore())) //
.endpointConfig(c -> c.setTokenGenerator(new CustomTokenGenerator())) //
.configuration(c -> c.set(CoapConfig.ACK_TIMEOUT , 1, TimeUnit.SECONDS)) //
.build());
// so the endpoints provider will provide 3 endpoints, 1 for coap and 2 for coaps.
serverBuilder.setEndpointsProvider(endpointsBuilder.build()); |
This ideas are implemented at : #1407 |
This is now integrated in |
After discussion at #1383, I tried to think about how to improve API to create
CaliforniumServerEndpointsProvider
.Here some ideas, where Coaps is used as example but could be generalized to all kind of protocol based on Californium :
A)
Being able to customize dtlsConfig on CoapsProtocolProvider. (See #1382 for more details)
e.g. proposed API :
B)
Currently the way to customize a Californium configuration looks like this :
Maybe it would be better to propose this way instead (or in addition) :
C)
The "normal way" to create californium based endpoint is :
If default endpoint created by ProtocolProvider is not enough, you can :
But currently there is no easy way to configure the CoapsServerEndpointFactory without creating a new class which inherits it.
An alternative could be to create a Builder which could like like :
The text was updated successfully, but these errors were encountered: