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

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