eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
652 stars 407 forks source link

Adding custom Objects definition at runtime #344

Closed dnav closed 7 years ago

dnav commented 7 years ago

Hi,

Before #299, I was adding custom Objects definition at runtime by providing a modified oma-objects-spec.json file. Now, this does not seems to work anymore. I provided the DDF file for my custom Object in the models folder but with no success.

What am I doing wrong ?

Regards

dnav commented 7 years ago

Here is the DDF I'm trying to add: (added the .txt extension to be able to include it in the issue)

Test.xml.txt

sbernard31 commented 7 years ago

How do you contribute this file (DDF/json) ? Does it concern leshan-demo (server/client) or the library itself ? If this is about demo since commit e017ef40759342dcbaad5667406fc532db30906d you can use command line option to do that.

dnav commented 7 years ago

Hi, This concern leshan-demo server. Using the command line option worked, thanks.

Previously, I was contributing the DDF or json file by patching the jar file from https://hudson.eclipse.org (jar -uf leshan-server-demo.jar oma-objects-spec.json)

Regards,

sbernard31 commented 7 years ago

So we can close this issue ?

dnav commented 7 years ago

I guess so. There is a workaround.

I find it strange that adding a new ddf file to the models folder inside the leshan-server-demo jarfile has no effect. Is there a list of files to parse somewhere ?

sbernard31 commented 7 years ago

It's not so easy to list files in folder in a generic way (I mean using the same code when code is packaged in jar or not) and we think that making this dynamic is not really useful as a packaged jar should not be modified.

So, files to load are listed in the code. When you are using Leshan as a library, you need to define which models you want (using ObjectLoader). By default only models from lwm2m core spec is loaded. (like this)

In case of Leshan demo, we load all models registered at OMA and so package additional ddf files in the leshan-demo-* jar. (see here and here )

If you want a custom jar of leshan-demo with your own ddf files, the best way seems to me to :

dnav commented 7 years ago

Thank you for the pointers.

Regards,