Closed andrau closed 10 years ago
ping @msangoi @sbernard31 can you review it? I'm off next days :)
I just have a look to your code, but I'm not sure to understand what you aim with this contribution. Can you help me by adding here more details, please ? :)
The intention is to intercept events like registration/deregistration or observe notification for extending leshan without intrusive changes to the existing classes, e.g. for logging or displaying data in a special way. Of course, the EventServlet itself could be dispatching the events, but that would seem a little strange. In my case, I use the events for logging and monitoring what devices do, but other applications like updating a custom UI are also conceivable. Basically, the point is to be able to extend leshan without creating a dependency from leshan to the extension in order to still being able to follow core development because the extension point is well-defined. I can implement the formal changes suggested by jvermillard if you give me a go ;-)
OK, I have made the changes as per the comments and merged with core, what's next?
Leshan is composed of 2 parts :
To be clear leshan-standalone is not really intended to be reused. So we don't aim to make it extensible without modification. But If you still want to reuse it, you could create your own LeshanMain and reuse our servlets. In this case, you could add listener directly on ClientRegistry
. For observation, you point an issue, we could only have one listener by observation. We should propose a better API for that. Maybe by adding listeners on ObservationRegistry
.
Understood, but since leshan-standalone is a very nice and useful sample which you keep working on, it would still be great to be able to extend it as suggested. Given that the extension is quite simple, I would appreciate if you could integrate it. BTW, I also have an idea for an extension point on the UI side and by prominently offering the possibility for extensions, you might inspire people to build interesting extensions, don't you think?
Hello Andreas,
I agree with Simon point since the core part already provides a listener mechanism to be notified of client registrations/deregistrations and resource observations. From my point of view, the standalone part is not really meant to be extended. It is a simple web-app on top of leshan-core that can be used as an example to build your own application. If you want to use leshan-standalone as a starting point for you own webapp, you could probably fork it and do some minor changes (or write your own main method) to use the current leshan-core API. What do you think ?
As mentioned by Simon, the current mechanism for listening observation events should be enhanced to provide a way to register several listeners. Would it match your use case ?
Manu
intended for non-intrusive extensions of leshan, comments welcome