001/**
002 * Copyright 2014 Tampere University of Technology, Pori Department
003 * 
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 *   http://www.apache.org/licenses/LICENSE-2.0
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package core.tut.pori.http;
017
018import javax.xml.bind.annotation.XmlAccessType;
019import javax.xml.bind.annotation.XmlAccessorType;
020import javax.xml.bind.annotation.XmlRootElement;
021
022/**
023 * The base class for HTTP Response data. 
024 * 
025 * Sub-classes of this class can be used in combination with HTTP Response to provide automatic marshalling of object content to XML output.
026 * 
027 * Note: implemented as abstract class because JAXB does not handle interfaces well.
028 */
029@XmlRootElement
030@XmlAccessorType(XmlAccessType.NONE)
031public abstract class ResponseData {
032  private final transient Class<?>[] _defaultClasses;
033  
034  /**
035   * The default implementation equals to calling getClass(), override this if your class requires other classes
036   * for serialization purposes (which cannot be directly resolved).
037   * 
038   * In general, overriding the default class definitions should not be needed, and in many cases an attempt to do so may be a sign of bad design,
039   * though there might also be valid cases where the functionality is required.
040   * 
041   * @return the list of classes present in this data
042   */
043  public Class<?>[] getDataClasses(){
044    return _defaultClasses;
045  }
046  
047  /**
048   * no-args constructor, you should provide one for serialization purposes
049   */
050  protected ResponseData(){
051    _defaultClasses = new Class<?>[]{getClass()};
052  }
053}