00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.component.request;
00032
00033 import java.io.Serializable;
00034 import java.util.List;
00035 import java.util.Vector;
00036
00037 import org.apache.log4j.Logger;
00038 import org.objectweb.proactive.core.body.UniversalBody;
00039 import org.objectweb.proactive.core.component.representative.ItfID;
00040 import org.objectweb.proactive.core.util.log.Loggers;
00041 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00042
00043
00066 public class Shortcut implements Serializable {
00067 public static Logger logger = ProActiveLogger.getLogger(Loggers.COMPONENTS_REQUESTS);
00068 private transient UniversalBody sender;
00069 private List<UniversalBody> steps;
00070
00071
00072 private String fcFunctionalInterfaceName;
00073
00074 public Shortcut() {
00075 }
00076
00077 public Shortcut(String functionalInterfaceName, UniversalBody sender,
00078 UniversalBody intermediate) {
00079 fcFunctionalInterfaceName = functionalInterfaceName;
00080 steps = new Vector<UniversalBody>();
00081 this.sender = sender;
00082 steps.add(intermediate);
00083 }
00084
00085 public UniversalBody getSender() {
00086 return sender;
00087 }
00088
00089 public void setSender(UniversalBody sender) {
00090 this.sender = sender;
00091 }
00092
00099 public int length() {
00100 return steps.size();
00101 }
00102
00103 public void updateDestination(UniversalBody destination) {
00104 if (logger.isDebugEnabled()) {
00105 logger.debug("adding a new step to the shortcut chain");
00106 }
00107 steps.add(destination);
00108 }
00109
00110 public String getFcFunctionalInterfaceName() {
00111 return fcFunctionalInterfaceName;
00112 }
00113
00119 public ItfID getLinkedInterfaceID() {
00120
00121 return new ItfID(fcFunctionalInterfaceName,
00122 steps.get(0).getID());
00123 }
00124
00129 public ItfID getShortcutInterfaceID() {
00130
00131 return new ItfID(fcFunctionalInterfaceName,
00132 steps.get(steps.size() - 1).getID());
00133 }
00134
00139 public UniversalBody getShortcutTargetBody() {
00140 return steps.get(steps.size() - 1);
00141 }
00142
00143
00144
00145
00146 private void writeObject(java.io.ObjectOutputStream out)
00147 throws java.io.IOException {
00148 out.defaultWriteObject();
00149 out.writeObject(sender.getRemoteAdapter());
00150 }
00151
00152 private void readObject(java.io.ObjectInputStream in)
00153 throws java.io.IOException, ClassNotFoundException {
00154 in.defaultReadObject();
00155 sender = (UniversalBody) in.readObject();
00156 }
00157 }