-
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
Add support of Startable
, Stoppable
and Destroyable
to LwM2mObjectEnabler.
#940
Add support of Startable
, Stoppable
and Destroyable
to LwM2mObjectEnabler.
#940
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Another small details, generally I try to keep commit title/summary to 72 characters max, if you need to add more information just add a blank line then a more complete description without size limitation)
@@ -55,6 +58,11 @@ | |||
* <p> | |||
* In case you really need the flexibility of this interface you should consider to inherit from | |||
* {@link BaseObjectEnabler}. | |||
* <p> | |||
* If you need to destroy or stop this instance on LeshanClient stopped/destroyed, | |||
* please also implement {@link Destroyable} and/or {@link Stoppable}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little detail but I think Implementing Stoppable
without Startable
doesn't make too much sense.
Because either you destroy because you don't want to be able to restart or you stop which let you able to restart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, reworded at bd7f86d
if (objectEnabler instanceof Startable) { | ||
((Startable) objectEnabler).start(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An idea is to add a start/stop/destroy method to LwM2mObjectEnabler
LwM2mObjectTree
and move the loop in this class ?
(This is maybe better in term of separation of concern)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. That sounds good, I'll do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbernard31 Do you mean LwM2mObjectTree
instead of LwM2mObjectEnabler
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uups, I wanted to say LwM2mObjectTree
😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, thanks for your advice! I did this at 603cb2a
if (objectEnabler instanceof Destroyable) { | ||
((Destroyable) objectEnabler).destroy(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For destroy there is special case where we implement Stoppable
but not Destroyable
. See LeshanServer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, I'm going to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed at bd7f86d
start()
, stop()
and destroy()
for each LwM2mObjectEnabler instance according to the status of LeshanClientStartable
, Stoppable
and Destroyable
to LwM2mObjectEnabler.
Move the interfaces `Destroyable`, `Startable` and `Stoppable` to `leshan-core` package from `leshan-server-core`. This commit aims to use these interfaces with `LwM2mObjectEnabler` to control the state of that. Ref: eclipse-leshan#933 (comment) Signed-off-by: moznion <[email protected]>
Now it calls `destroy()`, `stop()` and `start()` for each LwM2mObjectEnabler instance according to the LeshanClient status. For example, If it calls `LeshanClient#destroy()`, that method calls for each LwM2mObjectEnabler's `#destroy()`. And other methods are also similar. Signed-off-by: moznion <[email protected]>
According to this feedback: eclipse-leshan#940 (comment) Signed-off-by: moznion <[email protected]>
05b7dd6
to
b1cc299
Compare
If an instance of `LwM2mObjectEnabler` doesn't implement the `Destroyable` but that implements `Stoppable` instead, it calls `#stop()` on `LeshanClient#destroy()` instead of `destroy()`. Signed-off-by: moznion <[email protected]>
b1cc299
to
c334876
Compare
Thank you for your suggestion. I rebased this branch and reworded the long commit summary. |
These implemented methods are used in associated LeshanClient methods. Signed-off-by: moznion <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Integrated in master (commit fa0f58c and a275f2b) I did some little adjustment :
Thx @moznion 🙏 ! |
Many thanks for your supporting, @sbernard31 ! |
Rel: #933
Done
Destroyable
,Startable
andStoppable
class toleshan-core
fromleshan-server-core
to use these classes withLwM2mObjectEnabler
Destroyable
,Startable
andStoppable
onLwM2mObjectTree
LwM2mObjectTree#{stop(), start(), destroy()}
inLeshanClient#{stop(), start(), destroy()}