org/objectweb/proactive/core/body/rmi/RmiRemoteBodyImpl.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.body.rmi;
00032 
00033 import java.io.IOException;
00034 import java.rmi.RemoteException;
00035 import java.rmi.server.RMIClientSocketFactory;
00036 import java.rmi.server.RMIServerSocketFactory;
00037 import java.security.PublicKey;
00038 import java.security.cert.X509Certificate;
00039 import java.util.ArrayList;
00040 
00041 import org.objectweb.proactive.Body;
00042 import org.objectweb.proactive.core.UniqueID;
00043 import org.objectweb.proactive.core.body.UniversalBody;
00044 import org.objectweb.proactive.core.body.ft.internalmsg.FTMessage;
00045 import org.objectweb.proactive.core.body.reply.Reply;
00046 import org.objectweb.proactive.core.body.request.Request;
00047 import org.objectweb.proactive.core.exceptions.NonFunctionalException;
00048 import org.objectweb.proactive.core.exceptions.manager.NFEListener;
00049 import org.objectweb.proactive.ext.security.Communication;
00050 import org.objectweb.proactive.ext.security.SecurityContext;
00051 import org.objectweb.proactive.ext.security.crypto.KeyExchangeException;
00052 import org.objectweb.proactive.ext.security.exceptions.RenegotiateSessionException;
00053 import org.objectweb.proactive.ext.security.exceptions.SecurityNotAvailableException;
00054 
00055 
00061 public class RmiRemoteBodyImpl extends java.rmi.server.UnicastRemoteObject
00062     implements RmiRemoteBody, java.rmi.server.Unreferenced {
00063 
00068     //    protected static RandomPortSocketFactory factory = new RandomPortSocketFactory(37002,
00069     //            5000);
00070     //  protected static BenchSocketFactory factory = new BenchSocketFactory();
00071 
00076     protected transient UniversalBody body;
00077 
00078     //
00079     // -- CONSTRUCTORS -----------------------------------------------
00080     //
00081     public RmiRemoteBodyImpl() throws RemoteException {
00082     }
00083 
00084     public RmiRemoteBodyImpl(UniversalBody body) throws RemoteException {
00085         //      super(0, factory, factory);
00086         this.body = body;
00087     }
00088 
00089     public RmiRemoteBodyImpl(UniversalBody body, RMIServerSocketFactory sf,
00090         RMIClientSocketFactory cf) throws RemoteException {
00091         super(0, cf, sf);
00092         this.body = body;
00093     }
00094 
00095     //
00096     // -- PUBLIC METHODS -----------------------------------------------
00097     //
00098     //
00099     // -- implements RmiRemoteBody -----------------------------------------------
00100     //
00101     public String getJobID() {
00102         return body.getJobID();
00103     }
00104 
00105     public int receiveRequest(Request r)
00106         throws java.io.IOException, RenegotiateSessionException {
00107         return body.receiveRequest(r);
00108     }
00109 
00110     public int receiveReply(Reply r) throws java.io.IOException {
00111         return body.receiveReply(r);
00112     }
00113 
00117     public void terminate() throws IOException {
00118         body.terminate();
00119     }
00120 
00121     public String getNodeURL() {
00122         return body.getNodeURL();
00123     }
00124 
00125     public UniqueID getID() {
00126         return body.getID();
00127     }
00128 
00129     public void updateLocation(UniqueID id, UniversalBody remoteBody)
00130         throws java.io.IOException {
00131         body.updateLocation(id, remoteBody);
00132     }
00133 
00134     public void unreferenced() {
00135         // System.out.println("RmiRemoteBodyImpl: unreferenced()");      
00136         // System.gc();
00137     }
00138 
00139     public void enableAC() throws java.io.IOException {
00140         body.enableAC();
00141     }
00142 
00143     public void disableAC() throws java.io.IOException {
00144         body.disableAC();
00145     }
00146 
00147     public void setImmediateService(String methodName)
00148         throws java.io.IOException {
00149         body.setImmediateService(methodName);
00150     }
00151 
00152     public void removeImmediateService(String methodName,
00153         Class[] parametersTypes) throws IOException {
00154         body.removeImmediateService(methodName, parametersTypes);
00155     }
00156 
00157     public void setImmediateService(String methodName, Class[] parametersTypes)
00158         throws IOException {
00159         body.setImmediateService(methodName, parametersTypes);
00160     }
00161 
00162     // SECURITY
00163     public void terminateSession(long sessionID)
00164         throws IOException, SecurityNotAvailableException {
00165         body.terminateSession(sessionID);
00166     }
00167 
00168     public X509Certificate getCertificate()
00169         throws SecurityNotAvailableException, IOException {
00170         X509Certificate cert = body.getCertificate();
00171         return cert;
00172     }
00173 
00174     public long startNewSession(Communication policy)
00175         throws SecurityNotAvailableException, IOException, 
00176             RenegotiateSessionException {
00177         return body.startNewSession(policy);
00178     }
00179 
00180     public PublicKey getPublicKey()
00181         throws SecurityNotAvailableException, IOException {
00182         return body.getPublicKey();
00183     }
00184 
00185     public byte[] randomValue(long sessionID, byte[] cl_rand)
00186         throws IOException, SecurityNotAvailableException, 
00187             RenegotiateSessionException {
00188         return body.randomValue(sessionID, cl_rand);
00189     }
00190 
00191     public byte[][] publicKeyExchange(long sessionID, byte[] my_pub,
00192         byte[] my_cert, byte[] sig_code)
00193         throws IOException, SecurityNotAvailableException, 
00194             RenegotiateSessionException, KeyExchangeException {
00195         return body.publicKeyExchange(sessionID, my_pub, my_cert, sig_code);
00196     }
00197 
00198     public byte[][] secretKeyExchange(long sessionID, byte[] tmp, byte[] tmp1,
00199         byte[] tmp2, byte[] tmp3, byte[] tmp4)
00200         throws IOException, SecurityNotAvailableException, 
00201             RenegotiateSessionException {
00202         return body.secretKeyExchange(sessionID, tmp, tmp1, tmp2, tmp3, tmp4);
00203     }
00204 
00205     /* (non-Javadoc)
00206      * @see org.objectweb.proactive.core.body.rmi.RmiRemoteBody#getCertificateEncoded()
00207      */
00208     public byte[] getCertificateEncoded()
00209         throws IOException, SecurityNotAvailableException {
00210         return body.getCertificateEncoded();
00211     }
00212 
00213     /* (non-Javadoc)
00214      * @see org.objectweb.proactive.core.body.rmi.RmiRemoteBody#getPolicy(org.objectweb.proactive.ext.security.SecurityContext)
00215      */
00216     public SecurityContext getPolicy(SecurityContext securityContext)
00217         throws IOException, SecurityNotAvailableException {
00218         return body.getPolicy(securityContext);
00219     }
00220 
00221     public ArrayList getEntities()
00222         throws SecurityNotAvailableException, IOException {
00223         return body.getEntities();
00224     }
00225 
00226     /* (non-Javadoc)
00227      * @see org.objectweb.proactive.core.body.rmi.RmiRemoteBody#receiveFTEvent(org.objectweb.proactive.core.body.ft.events.FTEvent)
00228      */
00229     public Object receiveFTMessage(FTMessage fte) throws IOException {
00230         return this.body.receiveFTMessage(fte);
00231     }
00232 
00233     public void changeProxiedBody(Body newBody) {
00234         this.body = newBody;
00235     }
00236 
00237     //-------------------------------
00238     //  NFEProducer implementation
00239     //-------------------------------
00240     public void addNFEListener(NFEListener listener) {
00241         body.addNFEListener(listener);
00242     }
00243 
00244     public void removeNFEListener(NFEListener listener) {
00245         body.removeNFEListener(listener);
00246     }
00247 
00248     public int fireNFE(NonFunctionalException e) {
00249         return body.fireNFE(e);
00250     }
00251 
00252     //
00253     // -- PRIVATE METHODS -----------------------------------------------
00254     //
00255     //
00256     // -- SERIALIZATION -----------------------------------------------
00257     //
00258     private void writeObject(java.io.ObjectOutputStream out)
00259         throws java.io.IOException {
00260         // long startTime=System.currentTimeMillis();
00261         //System.out.println("i am in serialization");
00262         out.defaultWriteObject();
00263         //System.out.println("i am in serialization");
00264         //long endTime=System.currentTimeMillis();
00265         //System.out.println(" SERIALIZATION OF REMOTEBODYIMPL lasted " + (endTime - startTime));
00266     }
00267 }

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