at.spardat.xma.rpc.RemoteReply Maven / Gradle / Ivy
/*******************************************************************************
* 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: RemoteReply.java 2089 2007-11-28 13:56:13Z s3460 $
package at.spardat.xma.rpc;
import at.spardat.enterprise.exc.BaseException;
/**
* Models the answer the XMA server sends to the XMA client in a {@link RemoteCall}.
*
* @author YSD, 26.05.2003 11:05:05
*/
public class RemoteReply extends RemoteOperation {
public static int PARAM_GLOBAL_EVENTS = -1;
/**
* The data transferred back from server to client
*/
private RemoteReplyData data_;
/**
* Indicates that changes on the models by the server side event method should be rolled back
*/
private boolean rollbackModelChanges_ = false;
/**
* Constructor for the client side
*/
RemoteReply () {
data_ = new RemoteReplyData();
}
/**
* May be called if you want to undo all changes in widget models that have
* been done in the course of executing a server side event. All widget models
* of the executing component are reset to the state at which the server side
* event method has been called when the server side event method terminates.
*/
public void rollbackModelChanges () {
rollbackModelChanges_ = true;
}
/**
* Returns if model changes should be rolled back at the end of the execution
* of the server side event method.
*/
public boolean getRollbackModelChanges () {
return rollbackModelChanges_;
}
/**
* Adds a parameter to this reply that is transferred to the client and may
* be accessed via getParameter there.
*
* Note that this feature is usually not necessary with XMA since data
* is automatically transferred via widget models. You should ask yourself
* seriously if you are doing things right.
*
* @param id a numeric id of the parameter. Must not be less than zero and greater than 127.
* @param parameter the parameter data which has to implement java.io.Serializable
* and must be successfully be serialized. It cannot be null.
* @throws IllegalArgumentException if any before mentioned condition is violated.
*/
public void setParameter (int id, Object parameter) {
data_.setParameter (id, parameter);
}
/**
* Retrieves a parameter for a given id.
*
* @param id the id that has been used in setParameter.
* @return the same object set via setParameter or null if there
* is no parameter with the given id.
*/
public Object getParameter (int id) {
return data_.getParameter (id);
}
/**
* Returns the RemoteReplyData object for package internal usage. Never null.
*/
RemoteReplyData getReplyData () {
return data_;
}
/**
* Something at the server side execution throwed an exception.
*
* @param ex the exception thrown in the server event method. ex must
* not be used anymore after this call.
*/
void setException (BaseException ex) {
data_.exception_ = ex.truncateSubclasses();
}
/**
* Returns the exception set at the server or null if none has been set.
*/
BaseException getException () {
return data_.exception_;
}
}