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

org.sapia.ubik.rmi.server.RMICommand Maven / Gradle / Ivy

The newest version!
package org.sapia.ubik.rmi.server;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

import org.sapia.ubik.net.Connection;
import org.sapia.ubik.net.ServerAddress;
import org.sapia.ubik.rmi.server.command.Command;


/**
 * This class models an executable command. Typically, a command object
 * is created on the client side, then sent to the server where it is executed.
 *
 * @author Yanick Duchesne
 * 
*
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
*
License:
Read the license.txt file of the jar or visit the * license page at the Sapia OSS web site
*
*/ public abstract class RMICommand extends Command implements Externalizable { protected transient Config _config; protected VmId _vmId = VmId.getInstance(); public RMICommand() { } /** * Initializes this instance with a CommandConfig upon its * arrival at the server. It is a server's responsability to call this * method once it receives a command. *

* When overriding this method, super.init(config) must * be called. If a command nests another one, it should also call * init() on the nested command. * * @param config CommandConfig */ public void init(Config config) { _config = config; } /** * Returns the identifier of the VM from which this command comes from. * * @return a VmId. */ public VmId getVmId() { return _vmId; } /** * Returns this command's target server address, which corresponds * to the server that received this command. * * @return this command's ServerAddress */ public ServerAddress getServerAddress() { return _config.getServerAddress(); } /** * Returns this command's connection. * * @return a Connection */ public final Connection getConnection() { return _config.getConnection(); } /** * Executes this command. * * @throws Throwable if an error occurs while executing this command */ public abstract Object execute() throws Throwable; /** * @see java.io.Externalizable#readExternal(ObjectInput) */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { _vmId = (VmId) in.readObject(); } /** * @see java.io.Externalizable#writeExternal(ObjectOutput) */ public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(_vmId); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy