Repository navigation
Split off api - #1378
Split off api#1378
Conversation
|
Thanks! Looks like a huge change :) I saw you moved some helper code into the memory mapping file, @devemux86 do you think this works with all the different Android versions?
Thanks for explaining this in-depth. This decision also makes sense and let's separate if there is a problem or if we have something else than JSON like pbf, kryo or whatever.
I think more a library but at the same time when doing some work for #1112 I was in the need to serialize EncodedValues as "something" and if we use JSON there everything is easier compared to string or properties but then the core&storage really requires JSON. Probably the best would be if the Java library contains JSON at some point :) |
Exactly! I think a good model for a Java-library-which-is-also-a-REST-service which is allowed to evolve is: At each point in time, there is one mapping of Things-which-go-over-the-internet to Java objects which we think is current and the best, and the code for that one goes directly next to the Java objects, so that the relationship between the REST API and the Java is clean and short and one-unique-way-to-do-things. Things for "other formats" or "backward-compatibility" or "developer-sugar" go somewhere else, in pre-processors or filters or converters or something. |
|
@karussell apparently you mean this. Regarding json, if I may express an opinion and if it's possible in the API, I'd vote for a separate module, so that core can remain pure Java. |
@devemux86 Because it was used by |
|
No it's not a binary selection, Android or not. Even in Android unfortunately there are several paths in those methods, depending the Android version. 🙁 |
|
Sorry, I'm new to this, I have no idea what this is about. :-) I just see a class that's called Why doesn't that work and what should I pay attention to? |
|
I didn't say it won't work! |
|
So either way, it will be as before.
|
|
Sorry, maybe also my fault because Helper7 is indeed for the compatibility issues and not Helper. So let's try .... and sorry for the bubbles. |
|
Arrrrrrgh! :-) |
This does three things about sub-modules of which 1.) and 2.) are necessary to cleanly finish the across-repository Dropwizardification, and 3.) happened on the way:
1.) Split off
web-bundlefromweb. This is minor and probably nobody will notice. Problem is thatwebbuilds into a shaded JAR (of which we don't use the shading), and such JARs are ugly to import from other projects, but we want to import the web services from other projects (to combine them to a single server), so the web services must go out of the module in which they are tied together.2.) Split off
apifromcore. This is, I think, a major win, also for our mobile platforms, because it means that theclient-hcnow doesn't pull in the entirecoreas a dependency, which it was doing before. I simply moved all the things needed by the client and the server and the core, transitively, until I could removecorefromclient-hc.3.) Then, I also started moving some of the serialization and deserialization code to
api, see #1137. But doing so requires a Jackson dependency inapi, which means we now also have it (transitively) incore, in contrast to what the latest discussion in #1291 says. Read on:It is possible to not put serialization / deserialization code into an
apimodule. But then, such code would have to go into yet another module. Not framing this as "what dependencies do I need" but as "what does the module specify", it would mean thatapicontains the Java data classes andrepresentation(or something) contains the wire format (JSON), of which there could be several. Again, this is possible, but the question is whether that would be practical, or maybe a bit purist. Actually, since GraphHopper is both a library and a REST service, it makes sense to say that our Java objects and our JSON representations are 1:1 and should be close together, see below.Allowing on top of that the JSON library to be replaced would be totally enterprisey and over-engineered. We use Dropwizard, and Dropwizard uses Jackson, and the whole idea is to remove technical/boring/distracting stuff like serialization from code that is supposed to be about routing, and in the age of frameworks, that is made harder by wrapping it in custom interfaces, not easier.
We are still not using JSON (de-)serialization in the
core, so we can split off the additionalrepresentationmodule any time if we must. Actually, this was totally easy to do, without the custom JSON facade:GraphHoppercore methods can just be passed deserialized objects likeJsonFeatureCollection, not JSON maps or filenames. Voilà. This is the start of another (different) discussion: Is GraphHoppercorea library, or is it supposed to be exactly likewebbut without the web?apiif we want, and from then on,GraphHopperonly knows about Java objects, not about JSON or strings or files (except forGraphHopperStorage).coreincludes Jackson now, and it can read JSON files by itself, and that's it.