eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
862 stars 783 forks source link

Create separate API bundles that extensions/external apps can be compiled against. #3126

Open RyanRamchandar opened 7 years ago

RyanRamchandar commented 7 years ago

There are many places where we receive JSON via the REST API or EventSource and we need to deserialize and consume JSON for various smarthome types. For example Items can have various ItemTypes, and in turn these ItemTypes can only accept certain PayloadTypes to store its state.

Currently, we need to write a lot of redundant code on our client to parse and validate this data which already exists in smarthome. It would be nice if we could use the core classes and methods directly from eclipse smarthome in our client.

Copying the entire (or subsets) of the smarthome repo into our project doesn't seem like a smart solution.

Having an artifact we can include as a dependency, that is versioned along with smarthome, would be helpful.

kaikreuzer commented 7 years ago

I'd assume that we could extract certain packages from the smarthome.core and smarthome.io.rest.core bundles to separate OSGI bundles, which then must not have any further dependencies.

The main classes that you will need are probably all the DTOs and EnrichedDTOs, right? Could you come up with a list of what you would expect in the client lib?

kaikreuzer commented 7 years ago

I am afraid it is not as easy as I had hoped; as our current API relies heavily on abstract classes, the API and the implementation are not cleanly separated.

With Java8 and default implementations on interfaces, we might have better mechanisms at hand now for our API design. But in order to come up with independent "API bundles", we will have to refactor (and break) a couple of existing APIs. This should clearly be done before an 1.0 ESH release.

I adapt the issue title to reflect that "bigger" goal correctly.