org/objectweb/proactive/core/component/request/Shortcut.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
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; // the list of crossed membranes; TODO_M transient 
00070 
00071     // FIXME replace with a custom list with custom serialization of contained bodies 
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         // it is the first encountered interface while creating the shortcut
00121         return new ItfID(fcFunctionalInterfaceName,
00122             steps.get(0).getID());
00123     }
00124 
00129     public ItfID getShortcutInterfaceID() {
00130         // it is the last encountered interface while creating the shortcut
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     // -- PRIVATE METHODS FOR SERIALIZATION -----------------------------------------------
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(); // it is actually a UniversalBody
00156     }
00157 }

Generated on Mon Jan 22 15:16:07 2007 for ProActive by  doxygen 1.5.1