javacompatibilityversioningrpchessian

hessian, compatibility when server interface upgrade


We are using hessian for java client server remoting. Now we need to change a interface to add a new field.

Is there any other way except to add a new interface.

the interface looks like

public void process(fieldA, fieldB)

we want to just to change the interface for adding a new field and add some logic to handle for backward compatibility like

public void process(fieldA, fieldB, fieldC){

if (StringUtils.isBlank(fieldC)){

   old logic

} else{

   new logic
}

Solution

  • Why can't you just add another method?

    @Deprecated
    public void process(fieldA, fieldB);
    
    public void process(fieldA, fieldB, fieldC);
    

    This should preserve backward compatibility.