All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.baserpc.ServerToClientData Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

//@(#) $Id: ServerToClientData.java 2089 2007-11-28 13:56:13Z s3460 $
package at.spardat.xma.baserpc;

import java.io.IOException;

import at.spardat.enterprise.exc.BaseException;
import at.spardat.xma.serializer.XmaInput;
import at.spardat.xma.serializer.XmaOutput;

/**
 * Models the data transferred from server to client in a base rpc.
 * 
 * @author YSD, 28.09.2004  
 */
public class ServerToClientData extends RemoteData {

    /**
     * An exception occured in the course of executing the request
     */
    private BaseException          fException;
    
    
    
    /**
     * Writes this to the provided ObjectOutput
     */
    protected void externalize (XmaOutput o) throws IOException {
        super.externalize(o);
        // first a boolean that indicates if an exception occured
        o.writeBoolean ("ynExc", fException != null);
        if (fException != null) o.writeObject ("exception", fException);
    }

    /**
     * Reads the stuff written by externalize
     */
    protected void internalize (XmaInput in) throws IOException, ClassNotFoundException {
        super.internalize (in);
        // is there an exception?
        if (in.readBoolean()) {
            fException = (BaseException) in.readObject();
        }
    }
    
    /**
     * Sets a throwable that is going to be transferred to the client.
     * 
     * @param x the Exception returned to the client. BaseExeption.prepareMigration
     *           and BaseException.truncateSubclasses must have been called on x.  
     */
    public void setException (BaseException x) {
        fException = x;
    }
    
    /**
     * Returns the exception that has been set at the server or null if none.
     */
    public BaseException getException () {
        return fException;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy