title: Add/Override behavior on Jaxb generated classes by extending them
body: <p>I have a web server responding with xml data and a client consuming it.
  Both share the same domain code. One of the domain objects looks like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
  @XmlRootElement(name = "image")
  public class Image {
  
      private String filename;
      private ImageTypeEnum type;
  
      @XmlElement(name = "imageUri")
      public String getAbsoluteUri() {
          // some complex computation
          return uri;
      }
  }
  </code></pre>
  
  <p>When I try to unmarshal the response from the server into this object, since there's no setter for absoluteUri, I don't have the imageUri in the class. So I extend it like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class FEImage extends Image{
  private String imageUri;
      public String getAbsoluteUri() {
          return imageUri;
      }
      public void setAbsoluteUri(String imageUri) {
          this.imageUri = imageUri;
      }   
  }
  </code></pre>
  
  <p>My ObjectFactory</p>
  
  <pre class="lang-java prettyprint-override"><code>@XmlRegistry
  public class ObjectFactory {
      public Image createImage(){
          return new FEImage();
      }
  }
  </code></pre>
  
  <p>My code to unmarshal is here:</p>
  
  <pre class="lang-java prettyprint-override"><code>JAXBContext context = JAXBContext.newInstance(ObjectFactory.class);
  Unmarshaller unmarshaller = context.createUnmarshaller();
  unmarshaller.setProperty("com.sun.xml.bind.ObjectFactory",new ObjectFactory());         
  ((JAXBElement)unmarshaller.unmarshal((InputStream) response.getEntity())).getValue();
  </code></pre>
  
  <p>However, the <code>setAbsoluteUri</code> doesn't seem to be getting called in <code>FEImage</code> while unmarshalling. When I add a dummy <code>setAbsoluteUri</code> in <code>Image.java</code>, everything works as expected. </p>
  
  <p>Can someone tell me how can I cleanly extend from <code>Image.java</code>?</p>