Skip to content
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

Conversation

moznion
Copy link
Contributor

@moznion moznion commented Nov 26, 2020

Rel: #933

Done

  • Moves Destroyable, Startable and Stoppable class to leshan-core from leshan-server-core to use these classes with LwM2mObjectEnabler
  • Implements Destroyable, Startable and Stoppable on LwM2mObjectTree
    • These implemented methods call the associated objectEnablers' method inside
  • Calls LwM2mObjectTree#{stop(), start(), destroy()} in LeshanClient#{stop(), start(), destroy()}

Copy link
Contributor

@sbernard31 sbernard31 left a 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}.
Copy link
Contributor

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.

Copy link
Contributor Author

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();
}
}
Copy link
Contributor

@sbernard31 sbernard31 Nov 26, 2020

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)

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 ?

Copy link
Contributor

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 😅

Copy link
Contributor Author

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();
}
}
Copy link
Contributor

@sbernard31 sbernard31 Nov 26, 2020

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed at bd7f86d

@sbernard31 sbernard31 changed the title Move some classes into core and call start(), stop() and destroy() for each LwM2mObjectEnabler instance according to the status of LeshanClient Add support of Startable, Stoppable and Destroyable to LwM2mObjectEnabler. Nov 26, 2020
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]>
@moznion moznion force-pushed the 933_better_handle_unexpected_error_move_package branch from 05b7dd6 to b1cc299 Compare November 27, 2020 11:39
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]>
@moznion moznion force-pushed the 933_better_handle_unexpected_error_move_package branch from b1cc299 to c334876 Compare November 27, 2020 11:40
@moznion
Copy link
Contributor Author

moznion commented Nov 27, 2020

(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)

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]>
Copy link
Contributor

@sbernard31 sbernard31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sbernard31
Copy link
Contributor

Integrated in master (commit fa0f58c and a275f2b)

I did some little adjustment :

Thx @moznion 🙏 !

@sbernard31 sbernard31 closed this Nov 27, 2020
@moznion moznion deleted the 933_better_handle_unexpected_error_move_package branch November 27, 2020 14:46
@moznion
Copy link
Contributor Author

moznion commented Nov 27, 2020

Many thanks for your supporting, @sbernard31 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants