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

jadex.base.service.remote.commands.RemoteDGCAddReferenceCommand Maven / Gradle / Ivy

Go to download

The Jadex platform base package contains functionality useful for constructing platforms.

The newest version!
package jadex.base.service.remote.commands;

import jadex.base.service.remote.IRemoteCommand;
import jadex.base.service.remote.RemoteReference;
import jadex.base.service.remote.RemoteServiceManagementService;
import jadex.bridge.IComponentIdentifier;
import jadex.bridge.service.annotation.Security;
import jadex.commons.future.IIntermediateFuture;
import jadex.commons.future.IntermediateFuture;
import jadex.micro.IMicroExternalAccess;

/**
 *  Distributed garbage collection 'addRef(rr)' command.
 */
public class RemoteDGCAddReferenceCommand extends AbstractRemoteCommand
{
	//-------- attributes --------
	
	/** The remote reference. */
	protected RemoteReference rr;
	
	/** The reference holder (rms). */
	protected IComponentIdentifier holder;

	/** The callid. */
	protected String callid;
	
	//-------- constructors --------
	
	/**
	 *  Create a new add reference command.
	 */
	public RemoteDGCAddReferenceCommand()
	{
	}

	/**
	 *  Create a new add reference command.
	 */
	public RemoteDGCAddReferenceCommand(RemoteReference rr, IComponentIdentifier holder, String callid)
	{
//		System.out.println("result command: "+result);
		this.rr = rr;
		this.holder = holder;
		this.callid = callid;
	}
	
	//-------- methods --------
	
	/**
	 *  Get the security level of the request.
	 */
	public String	getSecurityLevel()
	{
		// No security issues here.
		return Security.UNRESTRICTED;
	}
	
	/**
	 *  Execute the command.
	 *  @param lrms The local remote management service.
	 *  @return An optional result command that will be 
	 *  sent back to the command origin. 
	 */
	public IIntermediateFuture execute(IMicroExternalAccess component, RemoteServiceManagementService rsms)
	{
		final IntermediateFuture ret = new IntermediateFuture();
		try
		{
			rsms.getRemoteReferenceModule().addRemoteReference(rr, holder);
			ret.addIntermediateResult(new RemoteResultCommand(null, null, null, 
				callid, false, null, getNonFunctionalProperties()));
			ret.setFinished();
//			ret.setResult(new RemoteResultCommand(null, null, callid, false));
		}
		catch(Exception e)
		{
			e.printStackTrace();
			ret.setException(e);
		}
		return ret;
	}
	
	//-------- getter/setter methods --------
	
	/**
	 *  Get the remote reference.
	 *  @return The remote reference.
	 */
	public RemoteReference getRemoteReference()
	{
		return rr;
	}

	/**
	 *  Set the rr.
	 *  @param rr The rr to set.
	 */
	public void setRemoteReference(RemoteReference rr)
	{
		this.rr = rr;
	}
	
	/**
	 *  Get the holder.
	 *  @return the holder.
	 */
	public IComponentIdentifier getHolder()
	{
		return holder;
	}

	/**
	 *  Set the holder.
	 *  @param holder The holder to set.
	 */
	public void setHolder(IComponentIdentifier holder)
	{
		this.holder = holder;
	}

	/**
	 *  Get the callid.
	 *  @return the callid.
	 */
	public String getCallId()
	{
		return callid;
	}

	/**
	 *  Set the callid.
	 *  @param callid The callid to set.
	 */
	public void setCallId(String callid)
	{
		this.callid = callid;
	}
	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy