SlideShare a Scribd company logo
1 of 30
Download to read offline
@ArneLimburg @_openknowledge
Schnittstellenevolution
mit VeRSTVersioned Represental State Transfer
VeRST | Arne Limburg
REST-Schnittstelle
http://www.example.com/addresses/42
Liefert Addresse
{
street: {
"name": "Poststraße",
"number": "1",
}
"city": "26122 Oldenburg"
}
VeRST | Arne Limburg
Was tun bei Weiterentwicklung?
http://www.example.com/addresses/42
Attribut-Umbenennung
{
street: {
"name": "Poststraße",
"streetName": "Poststraße",
"number": "1",
"houseNumber": "1",
}
"city": "26122 Oldenburg"
}
VeRST | Arne Limburg
Abwärtskompatible Weiterentwicklung
http://www.example.com/addresses/42
Abwärtskompatible Änderungen: Umbenennen durch Kopieren
{
street: {
"name": "Poststraße",
"streetName": "Poststraße",
"number": "1",
"houseNumber": "1",
}
"city": "26122 Oldenburg"
}
VeRST | Arne Limburg
Abwärtskompatible Weiterentwicklung
http://www.example.com/v1/addresses/42
Abwärtskompatible Änderungen: Umbenennen durch Kopieren
{
street: {
"name": "Poststraße",
"streetName": "Poststraße",
"number": "1",
"houseNumber": "1",
}
"city": "26122 Oldenburg"
}
• Server muss mit beiden Varianten
als Parameter umgehen können
• Server muss beide Varianten als
Antwort liefern können
 Tolerant Reader Pattern
VeRST | Arne Limburg
Abwärtskompatible Weiterentwicklung
http://www.example.com/v1/addresses/42
Abwärtskompatible Änderungen: Umbenennen durch Kopieren
{
street: {
"name": "Poststraße",
"streetName": "Poststraße",
"number": "1",
"houseNumber": "1",
}
"city": "26122 Oldenburg"
}
• Server muss mit beiden Varianten
als Parameter umgehen können
• Server muss beide Varianten als
Antwort liefern können
 Tolerant Reader Pattern
„Be conservative in what you do, be liberal in what you
expect.“
Postels Law (Jon Postel)
VeRST | Arne Limburg
Abwärtskompatible Weiterentwicklung
http://www.example.com/v1/addresses/42
Abwärtskompatible Änderungen: Umbenennen durch Kopieren
{
street: {
"name": "Poststraße",
"streetName": "Poststraße",
"number": "1",
"houseNumber": "1",
}
"city": "26122 Oldenburg"
}
• Server muss mit beiden Varianten
als Parameter umgehen können
• Server muss beide Varianten als
Antwort liefern können
 Tolerant Reader Pattern
Idee: Automatisierung durch Framework  VeRST
VeRST | Arne Limburg
Abwärtskompatible Weiterentwicklung
public class Address {
private Street street;
private String city;
}
public class Street {
private String name;
private String number;
}
VeRST | Arne Limburg
Transformation durch Annotations
public class Address {
private Street street;
private String city;
}
public class Street {
@Deprecated
private String name;
@MovedFrom("name")
private String streetName;
@Deprecated
private String number;
@MovedFrom("number")
private String houseNumber;
}
VeRST | Arne Limburg
Transformation durch Annotations
public class Address {
private Street street;
private String city;
}
public class Street {
@Deprecated
private String name;
@MovedFrom("name")
private String streetName;
@Deprecated
private String number;
@MovedFrom("number")
private String houseNumber;
}
VeRST | Arne Limburg
Herausforderungen
http://www.example.com/v1/addresses/42
Zusammenführen und Teilen von Attributen
{
street: {
...
"streetName": "Poststraße",
"houseNumber": "1",
"addressLine1": "Poststraße 1",
}
...
}
VeRST | Arne Limburg
Zusammenführen von Attributen
http://www.example.com/v1/addresses/42
Herausforderungen: Zusammenführen und Teilen von Attributen
{
street: {
...
"streetName": "Poststraße",
"houseNumber": "1",
"addressLine1": "Poststraße 1",
}
...
}
VeRST | Arne Limburg
Teilen von Attributen
http://www.example.com/v1/addresses/42
Herausforderungen: Zusammenführen und Teilen von Attributen
{
street: {
...
"addressLine1": "Poststraße 1",
}
"city": "26122 Oldenburg",
"zipCode": "26122",
"cityName": "Oldenburg"
}
VeRST | Arne Limburg
Zusammenführen und Teilen von Attributen
http://www.example.com/v1/addresses/42
Herausforderungen: Zusammenführen und Teilen von Attributen
{
street: {
...
"addressLine1": "Poststraße 1",
}
"city": "26122 Oldenburg",
"zipCode": "26122",
"cityName": "Oldenburg"
}
Idee: Komplexe Transformationen über Java-Code
VeRST | Arne Limburg
Transformation über Java-Code
public class Address {
private Street street;
@Removed(CityProvider.class)
private String city;
@Added(CitySplitProvider.class)
private String zipCode;
@Added(CitySplitProvider.class)
private String cityName;
}
public class Street {
...
@Removed(StreetNamePr...class)
private String streetName;
@Removed(HouseNumberP...class)
private String houseNumber;
@Added(AddressLinePro...class)
private String addressLine1;
@Added(defaultValue = "")
private String addressLine2;
}
VeRST | Arne Limburg
Transformation über Java-Code
public class CitySplitProvider implements Provider<String> {
public String get(VersionContext versionContext) {
Address address = versionContext.getParent(Address.class);
String city = address.getCity();
if (versionContext.getPropertyName().equals("zipCode")) {
return city.substring(0, 5);
} else if (versionContext.getPropertyName().equals("cityName")){
return city.substring(6).trim();
} else {
throw new IllegalArgumentException(...);
}}}
VeRST | Arne Limburg
Ebene von Attributen ändern
http://www.example.com/v1/addresses/42
Herausforderungen: Ebene von Attributen ändern
{
street: {
...
"addressLine1": "Poststraße 1"
}
"addressLine1": "Poststraße 1",
...
}
VeRST | Arne Limburg
Ebene von Attributen ändern
http://www.example.com/v1/addresses/42
Herausforderungen: Ebene von Attributen ändern
{
...
"zipCode": "26122",
"cityName": "Oldenburg",
"location": {
"zipCode": "26122",
"cityName": "Oldenburg"
}
}
VeRST | Arne Limburg
Ebene von Attributen ändern
public class Address {
private Street street;
@MovedFrom(
"street/addressLine1")
private String addressLine1;
...
private City location;
}
public class City {
@MovedFrom("../zipCode")
private String zipCode;
@MovedFrom("../cityName")
private String cityName;
}
VeRST | Arne Limburg
Default-Werte für Attribute
public class Address {
private Street street;
@MovedFrom(
"street/addressLine1")
private String addressLine1;
@Added(defaultValue = " ")
private String addressLine2;
...
private City location;
}
public class City {
@MovedFrom("../zipCode")
private String zipCode;
@MovedFrom("../cityName")
private String cityName;
}
VeRST | Arne Limburg
Default-Werte für Attribute
public class Address {
private Street street;
@MovedFrom(
"street/addressLine1")
private String addressLine1;
@Added(defaultValue = " ")
private String addressLine2;
...
private City location;
}
public class City {
@MovedFrom("../zipCode")
private String zipCode;
@MovedFrom("../cityName")
private String cityName;
}
VeRST | Arne Limburg
Abwärtskompatible Weiterentwicklung
{
street: {
"name": "Poststraße",
"streetName": "Poststraße",
"number": "1",
"houseNumber": "1",
"addressLine1": "Post... 1",
"addressLine2": ""
}
"addressLine1": "Poststraße 1",
"addressLine2": "",
"city": "26122 Oldenburg",
"zipCode": "26122",
"cityName": "Oldenburg",
"location": {
"zipCode": "26122",
"cityName": "Oldenburg"
}
}
http://www.example.com/v1/addresses/42
Bisher nur abwärtskompatible Änderungen
VeRST | Arne Limburg
Aufräumen
{
street: {
"name": "Poststraße",
"streetName": "Poststraße",
"number": "1",
"houseNumber": "1",
"addressLine1": "Post... 1",
"addressLine2": ""
}
"addressLine1": "Poststraße 1",
"addressLine2": "",
"city": "26122 Oldenburg",
"zipCode": "26122",
"cityName": "Oldenburg",
"location": {
"zipCode": "26122",
"cityName": "Oldenburg"
}
}
http://www.example.com/v1/addresses/42
Viele Attribute deprecated
VeRST | Arne Limburg
Aufräumen
{
street: {
"name": "Poststraße",
"streetName": "Poststraße",
"number": "1",
"houseNumber": "1",
"addressLine1": "Post... 1",
"addressLine2": ""
}
"addressLine1": "Poststraße 1",
"addressLine2": "",
"city": "26122 Oldenburg",
"zipCode": "26122",
"cityName": "Oldenburg",
"location": {
"zipCode": "26122",
"cityName": "Oldenburg"
}
}
http://www.example.com/v1/addresses/42
Bisher nur abwärtskompatible Änderungen
VeRST | Arne Limburg
Inkompatible Änderung
http://www.example.com/v2/addresses/42
Versionssprung
{
"addressLine1": "Poststraße 1",
"addressLine2": "",
"location": {
"zipCode": "26122",
"cityName": "Oldenburg"
}
}
VeRST | Arne Limburg
Version über URL
@Path("{version}/addresses")
public class AddressResource {
@GET
@Path("{id}")
public Address getAddress(@PathParam("id") String id) {
...
}
}
VeRST | Arne Limburg
Version über URL
@Path("{version}/addresses")
public class AddressResource {
@GET
@Path("{id}")
public Address getAddress(@PathParam("id") String id) {
...
}
}
VeRST | Arne Limburg
Versionierung über Annotations
@SupportedVersion(
version = "v2"
previous = AddressV1.class)
public class Address {
private Street street;
@MovedFrom("...")
private String addressLine1;
...
private City location;
}
public class City {
@MovedFrom("../zipCode")
private String zipCode;
@MovedFrom("../cityName")
private String cityName;
}
VeRST | Arne Limburg
Versionierung über Annotations
@SupportedVersion(
version = "v2"
previous = AddressV1.class)
public class Address {
private Street street;
@MovedFrom("...")
private String addressLine1;
...
private City location;
}
public class City {
@MovedFrom("../zipCode")
private String zipCode;
@MovedFrom("../cityName")
private String cityName;
}
@ArneLimburg @_openknowledge
Fragen?
Try it out
https://github.com/openknowledge/jaxrs-versioning

More Related Content

More from OPEN KNOWLEDGE GmbH

More from OPEN KNOWLEDGE GmbH (20)

Warum der Computer "Nein" sagt - Mehr Nachvollziehbarkeit dank Explainable AI
Warum der Computer "Nein" sagt - Mehr Nachvollziehbarkeit dank Explainable AIWarum der Computer "Nein" sagt - Mehr Nachvollziehbarkeit dank Explainable AI
Warum der Computer "Nein" sagt - Mehr Nachvollziehbarkeit dank Explainable AI
 
Machine Learning? Ja gerne! Aber was und wie? Eine Kurzanleitung für den erfo...
Machine Learning? Ja gerne! Aber was und wie? Eine Kurzanleitung für den erfo...Machine Learning? Ja gerne! Aber was und wie? Eine Kurzanleitung für den erfo...
Machine Learning? Ja gerne! Aber was und wie? Eine Kurzanleitung für den erfo...
 
From Zero to still Zero: Die schönsten Fehler auf dem Weg in die Cloud
From Zero to still Zero: Die schönsten Fehler auf dem Weg in die CloudFrom Zero to still Zero: Die schönsten Fehler auf dem Weg in die Cloud
From Zero to still Zero: Die schönsten Fehler auf dem Weg in die Cloud
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
FEHLENDE DATEN? (K)EIN PROBLEM!: Die Kunst der Data Imputation
FEHLENDE DATEN? (K)EIN PROBLEM!: Die Kunst der Data ImputationFEHLENDE DATEN? (K)EIN PROBLEM!: Die Kunst der Data Imputation
FEHLENDE DATEN? (K)EIN PROBLEM!: Die Kunst der Data Imputation
 
Nie wieder Log-Files!
Nie wieder Log-Files!Nie wieder Log-Files!
Nie wieder Log-Files!
 
Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!
 
From Zero to still Zero: The most beautiful mistakes going into the cloud.
From Zero to still Zero: The most beautiful mistakes going into the cloud. From Zero to still Zero: The most beautiful mistakes going into the cloud.
From Zero to still Zero: The most beautiful mistakes going into the cloud.
 
API Expand Contract
API Expand ContractAPI Expand Contract
API Expand Contract
 
Ready for the Future: Jakarta EE in Zeiten von Cloud Native & Co
Ready for the Future: Jakarta EE in Zeiten von Cloud Native & CoReady for the Future: Jakarta EE in Zeiten von Cloud Native & Co
Ready for the Future: Jakarta EE in Zeiten von Cloud Native & Co
 
Shared Data in verteilten Architekturen
Shared Data in verteilten ArchitekturenShared Data in verteilten Architekturen
Shared Data in verteilten Architekturen
 
Machine Learning mit TensorFlow.js
Machine Learning mit TensorFlow.jsMachine Learning mit TensorFlow.js
Machine Learning mit TensorFlow.js
 
KI und Architektur
KI und ArchitekturKI und Architektur
KI und Architektur
 
It's not Rocket Science: Neuronale Netze
It's not Rocket Science: Neuronale NetzeIt's not Rocket Science: Neuronale Netze
It's not Rocket Science: Neuronale Netze
 
Shared Data in verteilten Systemen
Shared Data in verteilten SystemenShared Data in verteilten Systemen
Shared Data in verteilten Systemen
 
Business-Mehrwert durch KI
Business-Mehrwert durch KIBusiness-Mehrwert durch KI
Business-Mehrwert durch KI
 
Mehr Sicherheit durch Automatisierung
Mehr Sicherheit durch AutomatisierungMehr Sicherheit durch Automatisierung
Mehr Sicherheit durch Automatisierung
 
API-Design, Microarchitecture und Testing
API-Design, Microarchitecture und TestingAPI-Design, Microarchitecture und Testing
API-Design, Microarchitecture und Testing
 
Supersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: QuarkusSupersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: Quarkus
 
Hilfe, ich will meinen Monolithen zurück!
Hilfe, ich will meinen Monolithen zurück!Hilfe, ich will meinen Monolithen zurück!
Hilfe, ich will meinen Monolithen zurück!
 

Recently uploaded

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 

Recently uploaded (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 

Vorstellung von VeRST, einem Framework zur Schnittstellenversionierung

  • 2. VeRST | Arne Limburg REST-Schnittstelle http://www.example.com/addresses/42 Liefert Addresse { street: { "name": "Poststraße", "number": "1", } "city": "26122 Oldenburg" }
  • 3. VeRST | Arne Limburg Was tun bei Weiterentwicklung? http://www.example.com/addresses/42 Attribut-Umbenennung { street: { "name": "Poststraße", "streetName": "Poststraße", "number": "1", "houseNumber": "1", } "city": "26122 Oldenburg" }
  • 4. VeRST | Arne Limburg Abwärtskompatible Weiterentwicklung http://www.example.com/addresses/42 Abwärtskompatible Änderungen: Umbenennen durch Kopieren { street: { "name": "Poststraße", "streetName": "Poststraße", "number": "1", "houseNumber": "1", } "city": "26122 Oldenburg" }
  • 5. VeRST | Arne Limburg Abwärtskompatible Weiterentwicklung http://www.example.com/v1/addresses/42 Abwärtskompatible Änderungen: Umbenennen durch Kopieren { street: { "name": "Poststraße", "streetName": "Poststraße", "number": "1", "houseNumber": "1", } "city": "26122 Oldenburg" } • Server muss mit beiden Varianten als Parameter umgehen können • Server muss beide Varianten als Antwort liefern können  Tolerant Reader Pattern
  • 6. VeRST | Arne Limburg Abwärtskompatible Weiterentwicklung http://www.example.com/v1/addresses/42 Abwärtskompatible Änderungen: Umbenennen durch Kopieren { street: { "name": "Poststraße", "streetName": "Poststraße", "number": "1", "houseNumber": "1", } "city": "26122 Oldenburg" } • Server muss mit beiden Varianten als Parameter umgehen können • Server muss beide Varianten als Antwort liefern können  Tolerant Reader Pattern „Be conservative in what you do, be liberal in what you expect.“ Postels Law (Jon Postel)
  • 7. VeRST | Arne Limburg Abwärtskompatible Weiterentwicklung http://www.example.com/v1/addresses/42 Abwärtskompatible Änderungen: Umbenennen durch Kopieren { street: { "name": "Poststraße", "streetName": "Poststraße", "number": "1", "houseNumber": "1", } "city": "26122 Oldenburg" } • Server muss mit beiden Varianten als Parameter umgehen können • Server muss beide Varianten als Antwort liefern können  Tolerant Reader Pattern Idee: Automatisierung durch Framework  VeRST
  • 8. VeRST | Arne Limburg Abwärtskompatible Weiterentwicklung public class Address { private Street street; private String city; } public class Street { private String name; private String number; }
  • 9. VeRST | Arne Limburg Transformation durch Annotations public class Address { private Street street; private String city; } public class Street { @Deprecated private String name; @MovedFrom("name") private String streetName; @Deprecated private String number; @MovedFrom("number") private String houseNumber; }
  • 10. VeRST | Arne Limburg Transformation durch Annotations public class Address { private Street street; private String city; } public class Street { @Deprecated private String name; @MovedFrom("name") private String streetName; @Deprecated private String number; @MovedFrom("number") private String houseNumber; }
  • 11. VeRST | Arne Limburg Herausforderungen http://www.example.com/v1/addresses/42 Zusammenführen und Teilen von Attributen { street: { ... "streetName": "Poststraße", "houseNumber": "1", "addressLine1": "Poststraße 1", } ... }
  • 12. VeRST | Arne Limburg Zusammenführen von Attributen http://www.example.com/v1/addresses/42 Herausforderungen: Zusammenführen und Teilen von Attributen { street: { ... "streetName": "Poststraße", "houseNumber": "1", "addressLine1": "Poststraße 1", } ... }
  • 13. VeRST | Arne Limburg Teilen von Attributen http://www.example.com/v1/addresses/42 Herausforderungen: Zusammenführen und Teilen von Attributen { street: { ... "addressLine1": "Poststraße 1", } "city": "26122 Oldenburg", "zipCode": "26122", "cityName": "Oldenburg" }
  • 14. VeRST | Arne Limburg Zusammenführen und Teilen von Attributen http://www.example.com/v1/addresses/42 Herausforderungen: Zusammenführen und Teilen von Attributen { street: { ... "addressLine1": "Poststraße 1", } "city": "26122 Oldenburg", "zipCode": "26122", "cityName": "Oldenburg" } Idee: Komplexe Transformationen über Java-Code
  • 15. VeRST | Arne Limburg Transformation über Java-Code public class Address { private Street street; @Removed(CityProvider.class) private String city; @Added(CitySplitProvider.class) private String zipCode; @Added(CitySplitProvider.class) private String cityName; } public class Street { ... @Removed(StreetNamePr...class) private String streetName; @Removed(HouseNumberP...class) private String houseNumber; @Added(AddressLinePro...class) private String addressLine1; @Added(defaultValue = "") private String addressLine2; }
  • 16. VeRST | Arne Limburg Transformation über Java-Code public class CitySplitProvider implements Provider<String> { public String get(VersionContext versionContext) { Address address = versionContext.getParent(Address.class); String city = address.getCity(); if (versionContext.getPropertyName().equals("zipCode")) { return city.substring(0, 5); } else if (versionContext.getPropertyName().equals("cityName")){ return city.substring(6).trim(); } else { throw new IllegalArgumentException(...); }}}
  • 17. VeRST | Arne Limburg Ebene von Attributen ändern http://www.example.com/v1/addresses/42 Herausforderungen: Ebene von Attributen ändern { street: { ... "addressLine1": "Poststraße 1" } "addressLine1": "Poststraße 1", ... }
  • 18. VeRST | Arne Limburg Ebene von Attributen ändern http://www.example.com/v1/addresses/42 Herausforderungen: Ebene von Attributen ändern { ... "zipCode": "26122", "cityName": "Oldenburg", "location": { "zipCode": "26122", "cityName": "Oldenburg" } }
  • 19. VeRST | Arne Limburg Ebene von Attributen ändern public class Address { private Street street; @MovedFrom( "street/addressLine1") private String addressLine1; ... private City location; } public class City { @MovedFrom("../zipCode") private String zipCode; @MovedFrom("../cityName") private String cityName; }
  • 20. VeRST | Arne Limburg Default-Werte für Attribute public class Address { private Street street; @MovedFrom( "street/addressLine1") private String addressLine1; @Added(defaultValue = " ") private String addressLine2; ... private City location; } public class City { @MovedFrom("../zipCode") private String zipCode; @MovedFrom("../cityName") private String cityName; }
  • 21. VeRST | Arne Limburg Default-Werte für Attribute public class Address { private Street street; @MovedFrom( "street/addressLine1") private String addressLine1; @Added(defaultValue = " ") private String addressLine2; ... private City location; } public class City { @MovedFrom("../zipCode") private String zipCode; @MovedFrom("../cityName") private String cityName; }
  • 22. VeRST | Arne Limburg Abwärtskompatible Weiterentwicklung { street: { "name": "Poststraße", "streetName": "Poststraße", "number": "1", "houseNumber": "1", "addressLine1": "Post... 1", "addressLine2": "" } "addressLine1": "Poststraße 1", "addressLine2": "", "city": "26122 Oldenburg", "zipCode": "26122", "cityName": "Oldenburg", "location": { "zipCode": "26122", "cityName": "Oldenburg" } } http://www.example.com/v1/addresses/42 Bisher nur abwärtskompatible Änderungen
  • 23. VeRST | Arne Limburg Aufräumen { street: { "name": "Poststraße", "streetName": "Poststraße", "number": "1", "houseNumber": "1", "addressLine1": "Post... 1", "addressLine2": "" } "addressLine1": "Poststraße 1", "addressLine2": "", "city": "26122 Oldenburg", "zipCode": "26122", "cityName": "Oldenburg", "location": { "zipCode": "26122", "cityName": "Oldenburg" } } http://www.example.com/v1/addresses/42 Viele Attribute deprecated
  • 24. VeRST | Arne Limburg Aufräumen { street: { "name": "Poststraße", "streetName": "Poststraße", "number": "1", "houseNumber": "1", "addressLine1": "Post... 1", "addressLine2": "" } "addressLine1": "Poststraße 1", "addressLine2": "", "city": "26122 Oldenburg", "zipCode": "26122", "cityName": "Oldenburg", "location": { "zipCode": "26122", "cityName": "Oldenburg" } } http://www.example.com/v1/addresses/42 Bisher nur abwärtskompatible Änderungen
  • 25. VeRST | Arne Limburg Inkompatible Änderung http://www.example.com/v2/addresses/42 Versionssprung { "addressLine1": "Poststraße 1", "addressLine2": "", "location": { "zipCode": "26122", "cityName": "Oldenburg" } }
  • 26. VeRST | Arne Limburg Version über URL @Path("{version}/addresses") public class AddressResource { @GET @Path("{id}") public Address getAddress(@PathParam("id") String id) { ... } }
  • 27. VeRST | Arne Limburg Version über URL @Path("{version}/addresses") public class AddressResource { @GET @Path("{id}") public Address getAddress(@PathParam("id") String id) { ... } }
  • 28. VeRST | Arne Limburg Versionierung über Annotations @SupportedVersion( version = "v2" previous = AddressV1.class) public class Address { private Street street; @MovedFrom("...") private String addressLine1; ... private City location; } public class City { @MovedFrom("../zipCode") private String zipCode; @MovedFrom("../cityName") private String cityName; }
  • 29. VeRST | Arne Limburg Versionierung über Annotations @SupportedVersion( version = "v2" previous = AddressV1.class) public class Address { private Street street; @MovedFrom("...") private String addressLine1; ... private City location; } public class City { @MovedFrom("../zipCode") private String zipCode; @MovedFrom("../cityName") private String cityName; }
  • 30. @ArneLimburg @_openknowledge Fragen? Try it out https://github.com/openknowledge/jaxrs-versioning