org/objectweb/proactive/core/component/request/SynchronousComponentRequestReceiver.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.IOException;
00034 
00035 import org.apache.log4j.Logger;
00036 import org.objectweb.proactive.Body;
00037 import org.objectweb.proactive.core.body.request.Request;
00038 import org.objectweb.proactive.core.body.request.RequestReceiverImpl;
00039 import org.objectweb.proactive.core.component.body.ComponentBody;
00040 import org.objectweb.proactive.core.util.log.Loggers;
00041 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00042 
00043 
00056 public class SynchronousComponentRequestReceiver extends RequestReceiverImpl {
00057     protected static Logger logger = ProActiveLogger.getLogger(Loggers.COMPONENTS_REQUESTS);
00058     public final static int SHORTCUT = 1;
00059 
00060     public SynchronousComponentRequestReceiver() {
00061         super();
00062     }
00063 
00064     public int receiveRequest(Request r, Body bodyReceiver)
00065         throws IOException {
00066         if (r instanceof ComponentRequest) {
00067             if (!((ComponentRequest) r).isControllerRequest()) {
00068                 if ("true".equals(System.getProperty(
00069                                 "proactive.components.use_shortcuts"))) {
00070                     if (!((ComponentBody) bodyReceiver).getProActiveComponentImpl()
00071                               .getInputInterceptors().isEmpty() ||
00072                             !((ComponentBody) bodyReceiver).getProActiveComponentImpl()
00073                                   .getOutputInterceptors().isEmpty()) {
00074                         if (logger.isDebugEnabled()) {
00075                             logger.debug(
00076                                 "shortcut is stopped in this component, because functional invocations are intercepted");
00077                         }
00078 
00079                         // no shortcut if there is an interception
00080                         return super.receiveRequest(r, bodyReceiver);
00081                     }
00082 
00083                     ((ComponentRequest) r).shortcutNotification(r.getSender(),
00084                         bodyReceiver.getRemoteAdapter());
00085 
00086                     // TODO_M leave a ref of the shortcut
00087                     if (logger.isDebugEnabled()) {
00088                         logger.debug("directly executing request " +
00089                             r.getMethodCall().getName() +
00090                             ((r.getMethodCall().getComponentMetadata().getComponentInterfaceName() != null)
00091                             ? (" on interface " +
00092                             r.getMethodCall().getComponentMetadata().getComponentInterfaceName()) : ""));
00093                     }
00094                 }
00095                 bodyReceiver.serve(r);
00096                 // TODO_M check with FT
00097                 return SynchronousComponentRequestReceiver.SHORTCUT;
00098             }
00099         }
00100 
00101         // normal object invocations and controller requests are not subject to shortcuts
00102         return super.receiveRequest(r, bodyReceiver);
00103     }
00104 }

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